blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
b942302e280c289fceac406b562b7fb05b7cab36
36rahu/codewar_works
/22-4-2015/product_of_diagonal.py
341
4.3125
4
''' Description: Given a list of rows of a square matrix, find the product of the main diagonal. Examples: main_diagonal_product([[1,0],[0,1]]) => 1 main_diagonal_product([[1,2,3],[4,5,6],[7,8,9]]) => 45 ''' def main_diagonal_product(mat): result = 1 for i in range(len(mat[0])): result *= mat[i][...
true
153705a0ea3ff05d7e59fcd5bee4f28ac60ce413
muhammeta7/CodeAcademyPython
/strings_cons_output.py
1,542
4.375
4
# Create a string by surrounding it with quotes string = "Hello there " # For words with apostrophe's us a backslash \ print "There isn\'t flying, this is falling with style!" # Accesing by index print fifth_letter = "MONTY"[4] # Will return Y # String methods parrot = "Parrot" print len(parrot) # will return numb...
true
598768ac97d73068511606617b003142fcbcc7c1
anbarasanv/PythonWB
/Merge Sort Recursive.py
890
4.21875
4
#Time complexity O(n log n) def merge(left,right): '''This Function will merge 2 array or list''' result = [] i,j = 0,0 #Comparing two list for smallest element while i < len(left) and j < len(right): if left[i] <= right[j]: result.append(left[i]) i +=1 else: ...
true
3000f9b65ad6926b0274a5d94ea41a7e2608781f
bimri/programming_python
/chapter_1/person_start.py
1,107
4.125
4
"Step 3: Stepping Up to OOP" 'Using Classes' class Person: def __init__(self, name, age, pay=0, job=None): self.name = name self.age = age self.pay = pay self.job = job if __name__ == '__main__': bob = Person('Bob Smith', 42, 30000, 'software') sue = Person('Sue Jone...
true
9ae6c269b41521b7ededa35ccae246557185174f
bimri/programming_python
/chapter_7/gui2.py
492
4.28125
4
"Adding Buttons and Callbacks" import sys from tkinter import * widget = Button(None, text='Hello GUI world!', command=sys.exit) widget.pack() widget.mainloop() ''' Here, instead of making a label, we create an instance of the tkinter Button class. For buttons, the command option is the place where we specify a ca...
true
f46676e4e06c7657a92b10f6ac48f8a13f199d02
bimri/programming_python
/chapter_1/tkinter102.py
964
4.15625
4
"Step 5: Adding a GUI" 'Using OOP for GUIs' ''' In larger programs, it is often more useful to code a GUI as a subclass of the tkinter Frame widget—a container for other widgets. ''' from tkinter import * from tkinter.messagebox import showinfo class MyGui(Frame): def __init__(self, parent=None): Frame._...
true
73e6e2712fc736f21f7818bef2c63815de570750
hymhanraj/lockdown_coding
/range.py
266
4.40625
4
''' Given start and end of a range, write a Python program to print all negative numbers in given range. Example: Input: start = -4, end = 5 Output: -4, -3, -2, -1 Input: start = -3, end = 4 Output: -3, -2, -1 ''' for num in range(-3,4): if num<0: print(num)
true
040cdf085336c553e8b0951a59a25028577999f7
helper-uttam/Hacktober2020-5
/Python/calc.py
1,011
4.1875
4
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") while True: num1 = int(input("Enter first number: ")) num2 = int(...
true
20e5713218979589bc452c464c4e9d52216d2b2b
mishra28soumya/Hackerrank
/Python/Basic_Data_Types/second_largest.py
673
4.125
4
#Find the Runner-Up Score! # Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. # You are given n scores. Store them in a list and find the score of the runner-up. # Input Format # The first line contains N. The second line contains an array A[] of N in...
true
91e6153e75db60860bd2f486effad5dd468c456a
nath-btx/hi-python
/ex03_rps/rps.py
1,377
4.125
4
import random moves=['rock','paper','scissors'] def convert_input(move): if (move == "r"): return 'rock' elif(move == "p"): return 'paper' elif(move == "s"): return 'scissors' else: return move def game(): tie = True while tie: tie = False AI_move = random.choice(moves) ...
false
8763f32cd9ae69553a4554c0223283a51c5522be
crypto4808/PythonTutorial_CoreySchafer-master1
/intro.py
1,731
4.3125
4
#import as a smaller name so you don't have to type 'my_modules' each time # import my_modules # #from my_module import find_index # courses = ['history', 'math' , 'physics' , 'compsci' ] # index = my_modules.find_index(courses,'math')# # print(index) #Use shorthand for my_modules so you don't have to type it out al...
true
ec022a502128acdcdc7b933a49ee215814f39c71
statusyaza/hacktoberfest2021-5
/Python/diamond_star.py
481
4.125
4
rows = int(input("Enter you number:")) n = 0 for i in range(1, rows + 1): n = 0 # loop to print spaces n = (rows - i) print(" " * n, end = "") # loop to print star n = (2 * i - 1) print(str(i) * n, end = "") print() #### for i in range(rows-1, 0, -1): # loop to...
false
b9b1a64e80fe8d1a4e9038e36d98f84b56f75ba8
Cassie-bot/Module-3
/Area.py
340
4.40625
4
#Casandra Villagran #1/30/2020 #This is a program that computes the area of a circle using the radius and it prints a message to the user with the answer. radius = int(input ("What is the radius of the circle? ")) Area= 3.14 * radius ** 2 print ("I loved helping you find the area of this circle, here i...
true
13091fa05d4d93a37a34f95520e6de8746a93763
avijitkumar2011/My-Python-programs
/middle_letter.py
213
4.1875
4
#To find middle letter in a string def middle(strg): if len(strg) % 2 == 1: n = len(strg)//2 print('Middle letter in string is:', strg[n]) else: print('enter string of length odd number') middle('kuma')
true
dcd1d7304fd1d7dbf55602f6f95150d98d92ea66
Ma11ock/cs362-asgn4
/avg_list.py
226
4.125
4
#!/usr/bin/env python # Calculate the average of elements in a list. def findAvg(lst): if(len(lst) == 0): raise ValueError("List is empty") avg = 0 for i in lst: avg += i return avg / len(lst)
true
af211c4fb797589561c443a8593c3cc3bf122d47
purnimagupta17/python-excel-func
/string_indexing_slicing_usingpython.py
967
4.65625
5
print('Hello World') #to shift the 'World' to next line, we can use \n in the symtax as follows: print('Hello \nWorld') #to count the number of characters in a string, we use len function as follows: str1="Hello" print(len(str1)) #to assign the index number to a string, for example: ss="Hello World" print(ss[0]) pri...
true
7a71cc280ae6302fc83eebd003a4693c17f8bc2a
krallnyx/NATO_Alphabet_Translation
/main.py
527
4.1875
4
import pandas data = pandas.read_csv("nato_phonetic_alphabet.csv") alphabet = {row.letter: row.code for (index, row) in data.iterrows()} def generate_phonetic(): to_translate = input("Please enter the word you want to translate into NATO Alphabet.\n").upper() try: output = [alphabet[letter] for lette...
true
eb7076d9c7d75d4b0ce59b5a1f74c6cdfe311b7e
jessiecantdoanything/Week10-24
/CodesAndStrings.py
1,531
4.125
4
# strings # concatenation firstName = "Jesus" lastName = "Monte" print(firstName + " " + lastName) name = firstName + " " + lastName lastFirst = lastName + ", " + firstName print(lastFirst) # repition print("uh "*2 + "AAAAAAAAA") def imTiredofSchool(): print("me, "*3 + "young Jessie,") print("is extreme...
false
efb19779c940b3f7d1f8999d089c2b2849764f1c
rckc/CoderDojo
/Python-TurtleGraphics/PythonIntro2-1Sequences.py
1,435
4.5625
5
# Author: Robert Cheung # Date: 29 March 2014 # License: CC BY-SA # For CoderDojo WA # Python Intro Turtle Graphics # Python has a rich "library" of functions. # We are going to use "turtle" to do some simple graphics. import turtle # see https://docs.python.org/2/library/turtle.html#filling if __name__ ...
true
786073c2e842f81fd71fc391628f6161546b5a9e
yyuuliang/codingchallenges
/hackerrank/Reverse-a-doubly-linked-list.py
2,556
4.15625
4
''' File: Reverse-a-doubly-linked-list.py Source: hackerrank Author: yyuuliang@github ----- File Created: Thursday, 12th March 2020 4:21:54 pm Last Modified: Thursday, 12th March 2020 4:21:58 pm ----- Copyright: MIT ''' # Reverse a doubly linked list # https://www.hackerrank.com/challenges/reverse-a-doubly-linked-lis...
true
7b04023a27193cf35c7c4db27c72cbb265193ddf
manusoler/code-challenges
/projecteuler/pe_1_multiples_3_and_5.py
364
4.3125
4
""" If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ def multiples_of(*nums, max=1000): return [i for i in range(max) if any([i % n == 0 for n in nums])] if __name__ == "_...
true
74b4f4975aff361161aaa469e959a1652b22a77d
manusoler/code-challenges
/projecteuler/pe_9_special_pythagorean_triplet.py
723
4.3125
4
import functools from math import sqrt from utils.decorators import timer """ A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a**2+b**2=c**2 a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product ab...
true
ab110fc6c142c9981d0e034eba28dbae82a5afa6
dersenok/python3_Les2
/venv/HomeworkLes2/Les_2_HW_8.py
717
4.125
4
# 8. Посчитать, сколько раз встречается определенная цифра в # # # введенной последовательности чисел. Количество вводимых # # # чисел и цифра, которую необходимо посчитать, # # # задаются вводом с клавиатуры. n = int(input("Сколько будет чисел? ")) d = int(input("Какую цифру считать? ")) count = 0 for i in range(1, ...
false
d3c3a3cf50793588756306288b30433842460b60
littlejoe1216/Chapter-6-Exercies
/Python Chapter 6 Exercises/Chp 6 Excercise 4.py
596
4.21875
4
#Exercise 4: #There is a string method called count that is similar to the function in the previous exercise. #Read the documentation of this method at https://docs.python.org/3.5/library/stdtypes.html#string-methods #and write an invocation that counts the number of times the letter a occurs in "banana". word ...
true
e3ddbeb215a0d6419b2ae83f2a0933ffc6fcb459
mmengote/CentralParkZoo
/sketch_181013b/sketch_181013b.pyde
971
4.34375
4
#this library converts the random into integers from random import randint #lists of animals included in the simulation #divided into two types, the zoo animals will have a starting state position of zoolocation. #local animals will have a starting position of something else. zoo_animals = ["Penguins", "Zebra...
true
4f03b52ca0f1f596bfe78b065f44ee8eb0f3b10c
markcharyk/data-structures
/tests/insert_sort_tests.py
1,085
4.125
4
import unittest from data_structures.insert_sort import insertion_sort class TestInsertSort(unittest.TestCase): def setUp(self): """Set up some lists to be sorted""" self.empty = [] self.single = [5] self.sorted = [1, 2, 3, 10] self.unsorted = [8, 1, 94, 43, 33] def te...
true
9689a252589118db6d6623abb196aff8c3efa9ab
vielma24/playground
/bank.py
1,337
4.40625
4
#!/usr/bin/python '''Program will intake customer information and account information. Account management will also be added.''' from datetime import date #******************************************************************************* class person: """ Returns a ```Person``` object with the given name, DO...
true
9d625b9f273e27a48db58a2694b0b8e1eb537063
dolapobj/interviews
/Data Structures/Array/MaximumProductSubarray.py
1,155
4.3125
4
#Maximum Product Subarray #LC 152 """ Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: Input: [2,3,-2,4] Output: 6 Explanation: [2,3] has the largest product 6. Example 2: Input: [-2,0,-1] Output: 0 Explanation: The ...
true
4076f61a183fac23c05fbf162dde7289caff5a74
sndp2510/PythonSelenium
/basic/_04Geometry.py
432
4.28125
4
sideCount=int(input("Enter Number of side: ")) if(sideCount==1): print("Its square") side=int(input("Enter length of side : ")) print("Area of the square is : " , (side*side)) elif(sideCount==2): print("Its Rectangle") length = int(input("Enter length of side : ")) breadth =int(input("Enter len...
true
d60ccaf31fe2c293d566effaf936c5c17e6064e3
ksu-is/Commute-Traffic-Twitter-Bot
/Practice/user_funct.py
1,027
4.28125
4
## will create text file for new users with info on each line. (not able to do OOP yet reliably so this is the best I've got) # do you have an account? user_ask = input("Before we start, lets specify what user this is for\nHave you used this program before?\nType 'y' or 'n' only: ") if user_ask.lower() == "n": ...
true
1e3cc57af263476e1346cccf480a6ed62e7c891d
jenshurley/python-practice
/python_early_examples.py
1,836
4.125
4
# Initial variable to track game play user_play = "y" # While we are still playing... while user_play == "y": # Ask the user how many numbers to loop through user_number = input("How many numbers? ") # Loop through the numbers. (Be sure to cast the string into an integer.) for x in range(int(user_num...
true
0be835d18fae63f8b63fbae296f65250f8b38ac4
koaning/scikit-fairness
/skfair/common.py
1,752
4.4375
4
import collections def as_list(val): """ Helper function, always returns a list of the input value. :param val: the input value. :returns: the input value as a list. :Example: >>> as_list('test') ['test'] >>> as_list(['test1', 'test2']) ['test1', 'test2'] """ treat_sing...
true
7a5d6f9bdd12a2aa3d4d1ce7c50723742a23cd46
Azoad/Coursera_py4e
/chapter7/ex_07_01.py
220
4.375
4
"""Take a file as input and display it at uppercase""" fname = input('Enter the file name: ') try: file = open(fname) except: print('Error in file!') quit() for line in file: print(line.strip().upper())
true
7b6fd1b192bf2fdacb41ce57cef67bd6ca3db41c
Azoad/Coursera_py4e
/test.py
1,944
4.1875
4
print('this is the first one:') print('let\'s do this!') print('add 5 and -3') f = 5 t = -3 print('addition of',str(f),'and',str(t),'is :',str(f+t)) print('-----------------------------') print('this is the second one:') x = 'It is not America but it is Bangladesh' lens = len(x) print('Length of \'' +x+ '\'...
false
6dafc193f5e2f1731df5462295131e2cee3236b8
victorrayoflight/Foudil
/Examen 2019-02-18/6.py
582
4.15625
4
x = True y = False z = False # False OR True == True # True OR False == True # True OR True == True # False OR False == False # True AND True = True # True AND False = False # False AND True = False # False AND False = False # False XOR True == True # True XOR False == True # True XOR True == False # False XOR False...
true
8b6e4666bf75fc6b7023e8c93717384f56183890
hayuzi/py-first
/base/dealwithexp.py
2,766
4.25
4
# 异常处理 # 语法错误是错误 # 异常是 语法正确,但是执行时候出现错误。 # 异常处理使用 try except 格式 # 与其他一些语言一样,责任链的模式,如果不做 except获取,会反馈到上一层. while True: try: x = int(input("Please enter a number: ")) break except ValueError: print("that was no valid number, try again ") # 一个except子句可以同时处理多个异常,这些异常将被放在一个括号里成为一个元组,例如 # ...
false
9d848849b6d688b2872bd9923a86319e3ad73807
Anchals24/InterviewBit-Practice
/Topic - String/Longest Common Prefix.py
1,216
4.25
4
#Longest Common Prefix. #Arr = ["aa" , "aab" , "aabvde"] """ Problem Description >> Given the array of strings A, you need to find the longest string S which is the prefix of ALL the strings in the array. Longest common prefix for a pair of strings S1 and S2 is the longest string S which is the prefix of both S1...
true
ac81f1e984700b6b3993e1b60e29812dc82e69c4
emlemmon/emlemmon.github.io
/python/Week6/check06b.py
1,121
4.4375
4
class Phone: """Parent class that has 3 member variables and 2 methods""" def __init__(self): self.area_code = 0 self.prefix = 0 self.suffix = 0 def prompt_number(self): self.area_code = input("Area Code: ") self.prefix = input("Prefix: ") self.suffix = inpu...
true
0e821086fd74aebd7e245509f1507fc3ac6ccec2
Jrufino/ListaRepeticaoPython
/ex22.py
638
4.21875
4
sair='N' divisivel=[] while sair !='S': num=int(input('Digite um numero inteiro: ')) if num==2 or num==3 or num==5 or num==7: print('Primo') else: if num%2==0 or num%3==0 or num%5==0 or num%7==0: if num%2==0: divisivel.append(2) if num%3==0: ...
false
41f61ba806ae6942a62b114ae624ab00ce0d6b7d
kobecow/algo
/NoAdjacentRepeatingCharacters/problem.py
543
4.15625
4
""" Given a string, rearrange the string so that no character next to each other are the same. If no such arrangement is possible, then return None. Example: Input: abbccc Output: cbcbca """ def rearrangeString(s: str) -> str or None: pass print(rearrangeString("gahoeaddddggrea")) # no order required # ahg...
true
b6a1309a07f6203b3d183552e30e4e05c5582713
Kishy-nivas/ds-in-python
/linked list.py
522
4.15625
4
# linked list implementation class Node(object): def__init__(self,value,pointer=None) self.value =value self.next =None class LinkedList(object): def __init__(self): self.head =None self.tail =None def add(self,value ): if self.head==None: self.head =self.tail = Node(value ) self.head.next =se...
false
c47370697303df60b4e50e91092a5564b047a718
stephenforsythe/crypt
/shift.py
1,172
4.125
4
""" This is essentially a substitution cypher designed to avoid fequency analysis. The idea is to shift the char to the right by an increasing number, until n = 25, at which time the loop will start again. Spaces are treated as a character at the end of the alphabet. """ import string FULL_ALPHABET = string.lowercas...
true
dfed06b4bbf51b8d57511753a08f09e26e3605d0
MuhammetEser/Class4-PythonModule-Week4
/4- Mis Calculator.py
2,631
4.28125
4
# As a user, I want to use a program which can calculate basic mathematical operations. So that I can add, subtract, multiply or divide my inputs. # Acceptance Criteria: # The calculator must support the Addition, Subtraction, Multiplication and Division operations. # Define four functions in four files ...
true
444256bdb2ae5b3aa29aec5acf93bfbb5875a8c7
ivanakonatar/MidtermExample
/task4.py
985
4.21875
4
""" =================== TASK 4 ==================== * Name: Convert To Upper * * Write a function `convert_2_upper` that will take * a string as an argument. The function should * convert all lowercase letter to uppercase without * usage of built-in function `upper()`. * Note: Please describe in details possible ...
false
5cae2691b29e74917c55007405b67e7fcf1a60de
KennethNielsen/presentations
/python_and_beer_lesser_known_gems/ex6_namedtuple.py
2,143
4.21875
4
"""namedtuple example""" from __future__ import print_function from collections import namedtuple def arange(start, end, step): """Arange dummy function""" print('arange', start, end, step) def get_data_from_db(data_id): """Get data from db dummy function""" print('get_data_from_db', data_id) def ...
true
de31bc761ac04f9c15ac4a74328d74b907fbd822
oliviamillard/CS141
/coinAdder.py
1,690
4.28125
4
#Olivia Millard - Lab 3a #This program will add up a user's coins based off of their input. #Short welcome message. print("Hello. This program will add up all of your change!\nCool! Let's get started.\n") """ This function, first, take input from the user asking how many coins they have. Next, it takes input for what...
true
e287eb63af5781999f148ef1aecf4dc2752e2ed1
a-ruzin/python-base2
/lesson_11/homework/task5.py
2,064
4.15625
4
""" 5. Продолжить работу над первым заданием. Разработайте методы, которые отвечают за приём оргтехники на склад и передачу в определённое подразделение компании. Для хранения данных о наименовании и количестве единиц оргтехники, а также других данных, можно использовать любую подходящую структуру (например, словарь). ...
false
52c44bc5f786ab5c741fce402acf47ee901c5818
a-ruzin/python-base2
/lesson_3/homework/task3.py
1,367
4.15625
4
""" 3. Написать функцию thesaurus(), принимающую в качестве аргументов имена сотрудников и возвращающую словарь, в котором ключи — первые буквы имен, а значения — списки, содержащие имена, начинающиеся с соответствующей буквы. Например: >>> thesaurus("Иван", "Мария", "Петр", "Илья") { "И": ["Иван", "Илья"], "М"...
false
4660fcbd2bc5df305214bffd4b4bc073abe6c1f5
samwata/Python-Is-Easy
/Dictionaries-And-Sets/dictionary-assignment.py
531
4.1875
4
#Songs dictionary Songs = {"Laugh Now, Cry Later":"Drake","Dark Lane Demo Tapes":"Drake", "Sounds from the Other Side":"Wizkid","Joro":"Wizkid","jeje":"Diamond Platnumz","A Boy from Tandale":"Diamond Platnumz", "Tambarare":"Eunice Njeri"} #Function to check if the Song exists in Songs dictionary while (True): Song...
false
173ecefb3bd3070bff1b3cd83e91dab2dd2eb4bd
renan-suetsugu/WorkshopPythonOnAWS
/Labs/Loops/lab_6_step_1_Simple_Loops.py
545
4.125
4
#fruit = ['apples','oranges','bananas'] #for item in fruit: # print(f'The best fruit now is {item}') #numbers = [0,1,2,3,4,5,6,7,8,9,10] #for number in numbers: # print(f'The next number is {number}') #for number in range(10): # print(f'The next number is{number}') #for number in range(10): #...
true
2a4dd3b8574142a991f73761bd43d6e2688c83a0
blackicetee/Python
/python_games/simple_games/MyValidator.py
451
4.125
4
"""This self written python module will handle different kinds of user input and validate it""" # This is a module for regular expressions see python documentation "Regular expression operations" import re class MyValidator: @staticmethod def is_valid_from_zero_to_three(user_input): regex_pattern = r...
true
8190dd1f19c1c918cd16997aae5a2c0b77c60607
CoitThomas/Milestone_7
/7.1/test_string.py
480
4.3125
4
"""Verify the correct returned string value of a list of chars given to the funtion string(). """ from reverse_string import string def test_string(): """Assert the correct returned string values for various lists of chars given to the string() function. """ # Anticipated input. assert string(['H',...
true
f4ad480c6b9e7d8754506f060649b77b99049268
taisei-s/nlp100
/swings/swing09.py
1,051
4.15625
4
# coding:utf-8 """ 09. Typoglycemia スペースで区切られた単語列に対して,各単語の先頭と末尾の文字は残し,それ以外の文字の順序をランダムに並び替えるプログラムを作成せよ.ただし,長さが4以下の単語は並び替えないこととする.適当な英語の文(例えば"I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind .")を与え,その実行結果を確認せよ. """ import random def shuffle_inside(word): ...
false
313947b60813bec8b6956a808f7c5ee1efed7618
scottwedge/code_hilfen
/ONLINE-KURSE/Become a Python Developer/5 - Learning the Python 3 Standard Library/code-training/3 - Python Input_Output/input_output.py
2,875
4.1875
4
#1 - Command line arguments #python3 input_output.py 0 1 2 #in CLI ist alles immer ein String import sys #um auf die CLI-Param zugreifen zu können sys.argv print("Number of arguments: " + str(len(sys.argv))) print("Arguments: ", sys.argv) #<- erstes Argument ist Name (bzw. Pfad der Datei) sys.argv.remove(sys.argv[...
false
52e700eccf6b8b453f6680c9a991b150774033e4
scottwedge/code_hilfen
/ONLINE-KURSE/Become a Python Developer/4 - Python Essential Training/code-training/11 - String Objects/string_objects.py
1,442
4.28125
4
# 1 - Overview of string objects #String sind Objekte # Strin-Methoden, print("TestString".upper()) print("TestString".swapcase()) print("TestString {}".format(4)) print('''Test Str ing {}'''.format(4)) s = "Test String {}" print(s.format(4)) class myString(str): def __str__(self): return self[::-1] s =...
false
bc58fb8b971f9a907786caac451b8d603a7ec1c0
llduyll10/backup
/Backup/BigOGreen/classPython.py
1,960
4.34375
4
#Create Class class MyClass: x=5 print(MyClass) #Create object p1 = MyClass() print(p1.x) #__innit__() function class Person: def __init__(self,name,age): self.name = name self.age = age p1 = Person("DuyNND",22) print(p1.name) print(p1.age) #Object METHOD #Object can also cotain method clas...
true
56dac0836a399dfb331f7dad49cde574aea01446
Clobbster/hackerrank
/Python/If_Else/test_sample_code.py
529
4.3125
4
# For a input variable, write if/then ladder for the following: # If is odd, print Weird # If is even and in the inclusive range of to , print Not Weird # If is even and in the inclusive range of to , print Weird # If is even and greater than , print Not Weird N = int(input("Please enter a number: ")) if N % 2 ...
false
b210549d4b32f01909c03f2a85f0127a3c4c3c1f
Clobbster/hackerrank
/Python/Write_A_Function/test_sample_code.py
406
4.25
4
# Write a function that determines if a given input year is a leap year. def is_leap(year): leap = "" # Write your logic here if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: leap = True else: leap = False else: le...
false
950af6a1c4cd4ffe12ff99061bb44cfd0104fec6
regismagnus/challenge_python
/is_list_palindrome.py
1,390
4.15625
4
''' Note: Try to solve this task in O(n) time using O(1) additional space, where n is the number of elements in l, since this is what you'll be asked to do during an interview. Given a singly linked list of integers, determine whether or not it's a palindrome. Note: in examples below and tests preview linked lists a...
true
0f9ba273804db8997bd5ec73e7c233c11d58eac5
regismagnus/challenge_python
/longest_word.py
611
4.34375
4
''' Define a word as a sequence of consecutive English letters. Find the longest word from the given string. Example For text = "Ready, steady, go!", the output should be longestWord(text) = "steady". best solution by dnl-blkv: return max(re.split('[^a-zA-Z]', text), key=len) ''' def longestWord(text): rex='[\[...
true
bee95c39ec36fa669a574732be32e6a85d024117
bvishny/basic-algos
/mergesort_inversions.py
2,008
4.25
4
# Basic Merge Sort Implementation # Components # 1. split_array(array) array array - takes an array and splits it at the midpoint into two other arrays # 2. merge(array, array) array - takes two split arrays and merges them together sorted # 3. mergesort(array) array - takes an array and sorts it using mergesort def s...
true
b98c45e58694e05b7fadee7721ce57a4e625c603
shubhamPrakashJha/selfLearnPython
/6.FunctionalProgramming/6.Recursion.py
328
4.1875
4
def factorial(x): if x == 1: return 1 else: return x*factorial(x-1) print(factorial(int(input("enter the number: ")))) def is_even(x): if x == 0: return True else: return is_odd(x-1) def is_odd(x): return not is_even(x) print(is_even(23)) print(is_odd(1)) print(is...
true
f9a34ec2cd69deb1bc020afd803e3abd5f3ac877
juechen-zzz/LeetCode
/python/0207.Course Schedule.py
2,706
4.125
4
""" There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and a list of prerequisite pairs, is it possible for yo...
true
837c95fb0a7b12b26dd16d0c3c693ac16ed1bfd1
juechen-zzz/LeetCode
/python/0075.Sort Colors.py
1,075
4.21875
4
''' Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. Note: You are not suppose to use the l...
true
de7e65a78aeb655fb91579b349f8f2c2c697e0aa
Phoenix795/lesson1
/ld.py
986
4.1875
4
# step 5(Комплексные типы данных: списки) my_list = [3,5,7,9,10.5] print('My list: ', my_list) my_list.append('Python') print('Length of my_list: ', len(my_list)) print('First element: ', my_list[0]) print('Last element: ', my_list[-1]) print('From second to fourth element: ',my_list[1:4]) print('My list: ', my_list) d...
false
c22a3a2358c43fa2010303fa125199b77168d3b5
colemai/coding-challenges
/leetcode_challenges/L267-PalindromeP2.py
2,627
4.28125
4
#!/usr/bin/env python3 """ Author: Ian Coleman Input: Output: Challenge: Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form. For example: Given s = "aabb", return ["abba", "baab"]. Given s = "abc", return []. """ from...
true
afc794d1882bbfb28ea270f7b4a723762b3a246c
envisioncheng/python
/pyworkshop/1_intro_python/chapter5/exercise.py
553
4.21875
4
# Part 1 10 > 5 5 > 10 10 > 10 10 >= 10 5 < 10 5 < 5 5 <= 5 5 == 5 5 != 10 # Part 2 5 == True # The number 5 does not equal True, but... if 5: print("The number 5 is truthy!") # The number 5 is truthy for an if test! # Part 3 1 == True 0 == False # Part 4 True or False [] or [1, 2, 3] "Hello" or None True a...
false
0c0e23c15708325ec523a31bd9b7bea1044ad2e4
prameya21/python_leetcode
/Valid_Palindrome.py
800
4.25
4
''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Output: false ''' class...
true
92cc8732044e9fc0a64a3d7de55ec4393b6b4beb
kangwonlee/16pfa_kangwonlee
/ex29_if/ex29.py
714
4.1875
4
# -*-coding:utf8 # http://learnpythonthehardway.org/book/ people = 10 cats = 30 dogs = 15 if people < cats: print("Too many cats! The world is doomed!") if people > cats: print("No many cats! The world is saved!") if people < dogs: print("The world is drooled on!") if people > dogs: print("The worl...
true
24dad66dd22395fc2a92f2a403de09dcb82fbfe4
Maschenka77/100_Day_Python
/day_2_tip_project_calculator.py
625
4.21875
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 #Format the result to 2 decimal places = 33.60 #Tip: You might need to do some research in Google to figure out how to do this. print("Welcome to the tip calculator!") total_bill = float(input("What is t...
true
9d0dec604ab6ca5aefcec6aca0a3766082e1419d
Aravind-39679/tri.py
/triangle.py
658
4.125
4
t=True while(t): A=int(input('Enter first side of the triangle:')) B=int(input('Enter second side of the triangle:')) C=int(input('Enter third side of the triangle:')) if(A+B>C and B+C>A and A+C>B): print("It is a triangle") if(A==B==C): print('It is an equailateral t...
true
cae0951dcb0aaed9aa287c1e924211365b6bcf80
Lynch08/pands-problem-sheet
/squareroot.py
1,061
4.3125
4
#Programme that uses a function so when you input a number it will return the square root #Author Enda Lynch #REF https://medium.com/@sddkal/newton-square-root-method-in-python-270853e9185d #REF https://www.youtube.com/watch?v=WsQQvHm4lSw - Understand Calculas #REF https://www.homeschoolmath.net/teaching/square-root-al...
true
b96c473a1b366efebf30f888dcfe9aba5e53b2c6
VladKrupin/DemoGit
/Calculator v1.0.py
419
4.1875
4
from math import pow a = float(input("Enter the first number:")) op = input("Input the operation:") b = float(input("Enter the second number:")) result = None if op == "+": result = a+b elif op == "/": result = a/b elif op == "-": result = a-b elif op == "*": result = a*b elif op == "pow": result=po...
false
53b9d3683feff9adfa34c88be6c856db960072ad
sheelabhadra/LeetCode-Python
/1033_Moving_Stones_Until_Consecutive.py
2,232
4.21875
4
"""PROBLEM: Three stones are on a number line at positions a, b, and c. Each turn, you pick up a stone at an endpoint (ie., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints. Formally, let's say the stones are currently at positions x, y, z with x < y < z. Y...
true
22e6457a4791af6292a17bbb294566aefdb9834e
sheelabhadra/LeetCode-Python
/728_Self_Dividing_Numbers.py
1,425
4.125
4
#A self-dividing number is a number that is divisible by every digit it contains. # For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. # Also, a self-dividing number is not allowed to contain the digit zero. # Given a lower and upper number bound, output a list of every ...
true
8f977472fd05fb250e180589c6545a545805a2ac
zahraaassaad/holbertonschool-machine_learning
/math/0x06-multivariate_prob/0-mean_cov.py
854
4.28125
4
#!/usr/bin/env python3 """ calculates the mean and covariance of a data set """ import numpy as np def mean_cov(X): """ X is a numpy.ndarray of shape (n, d) containing the data set: n is the number of data points d is the number of dimensions in each data point Returns: mean, cov: mean num...
true
e4a322de533519abc12a1819ef9bcea84113c488
kwierman/Cards
/Source/Shuffle.py
1,032
4.125
4
""" @package Shuffle Performs shuffling operations on decks """ import Deck ## splits the deck into two decks # @param deck The deck to be split # @param split_point how many cards from the top of the deck to split it def split_deck(deck, split_point=26): deck_1 = Deck.Deck() deck_2 = Deck.Deck() for x, card in ...
true
5fd87282bd2429a43a83feb00c542b07da1a4259
simiyub/python
/interview/practice/code/arrays/SortedSquareFromSortedArray.py
642
4.28125
4
""" Given an array of sorted integers, this function returns a sorted array of the square of the numbers """ def sorted_square_array(array): result = [0 for _ in array] smaller_value_index = 0 larger_value_index = len(array) - 1 for index in reversed(range(len(array))): smaller_value = array[...
true
6e713b61bedbe73121c1326b8d17ae7cd5d1ef06
simiyub/python
/interview/practice/code/recursion/Permutations.py
1,724
4.15625
4
""" Requirement:This function will receive an array of integers and create an array of unique permutations or ordering of integers that can be created from the integers in the array. Implementation: We build all permutations for the array within the array in place using pointers. We select the first element in the arra...
true
61066f828ffa00dd2652b07ea8e546e255682cf8
simiyub/python
/interview/practice/code/linked_lists/ReverseLinkedList.py
1,248
4.15625
4
""" Requirement: Given a linked list where each node points to the next node, this function will return the linked list in reverse order Implementation: Conceptually, a node is reversed when the next pointer points to the previous node. However, as this is a singly linked list, we do not have a pointer to the previous ...
true
fe1c5e5cea9e34e329b658982acd5bd7fd8f23af
shorya97/AddSkill
/DS & Algo/Week 2/Stack/Implement Stack using Queues.py
1,420
4.15625
4
from queue import Queue class MyStack: def __init__(self): """ Initialize your data structure here. """ self.q1 = Queue() #inbuilt queues self.q2 = Queue() self.cur_size = 0 #contains number of elements def push(self, x: int) -> None...
true
be1b56dc341fc45d7c0d017bc979c4d1426f7afa
prabhu30/Python
/Strings/Set - 1/maketrans_translate.py
743
4.5625
5
""" maketrans() :- It is used to map the contents of string 1 with string 2 with respective indices to be translated later using translate(). translate() :- This is used to swap the string elements mapped with the help of maketrans(). """ # Python code to demonstrate working of # maketrans() and translate() from ...
true
bdbfdd41268b98866a0eb26d1d335267b1a4f0b9
prabhu30/Python
/Lists/Set - 1/indexing_negative.py
666
4.375
4
""" Negative indexing :- In Python, negative sequence indexes represent positions from the end of the array. Instead of having to compute the offset as in List[len(List)-3], it is enough to just write List[-3]. Negative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second-last it...
true
e8bc8d4d3b21a4e6525a0e23a3e462f4feabb9a0
Manish674/Cs50-problem-sets
/pset6/mario/mario.py
201
4.15625
4
height = int(input("Height: ")) while height < 0: height = int(input("Height: ")) col = 0 row = 0 while row <= height: while col <= row: print("#"*col) col += 1 row += 1
false
df60640085e6f84ebd72aee33d3dd29dfc4d950e
TrevorSpitzley/PersonalRepo
/PythonProjects/listCheck.py
920
4.25
4
#!/usr/bin/env python # This file is used for comparing two lists. # If there is an element in the input_list, # and it is not in the black_list, then it # will be added to the out_list and printed def list_check(input_list, black_list): out_list = [] for element in input_list: if element not in blac...
true
fba0793e6a6508be9717c0db93287d455ed13d5d
nathan-create/assignment-problems
/linked_list.py
1,601
4.15625
4
class Node: def __init__(self, data): self.data = data self.next = None self.index = 0 class LinkedList: def __init__(self, data): self.head = Node(data) def append(self, data): current_node = self.head node_index = 0 while current_node.next ...
false
62615472dad8b7cbd47655acab1ee1dcafcfc4f3
cbolson13/Pyautogui_CO
/Personality_Survey_C.py
1,876
4.21875
4
print("What's your name?") name = input().title() if name == "Connor": print("Same here!") else: print(name + " is a pretty cool name.") print("What's your favorite sport") sport = input().title() if sport == "Soccer": print("Cool, what's your favorite team!") soccertea...
true
e120d6a0b5708af15a2a50b654ef68837a12c03e
Abhiaish/GUVI
/ZEN class/day 1/fare.py
236
4.15625
4
distance=int(input("enter the distance")) peaktime=int(input("enter the peaktime")) if(distance>5): distance=distance-5 else: print("fare is 100") fare=int(distance*8+100) if(peaktime==1): fare=fare+0.25*fare print(fare)
true
bbdb68232f6a2d04d342d4cc274faa2d3d083aeb
renzhiliang/python_work
/chapter4/4-10.py
293
4.34375
4
#numbers=range(3,31,3) numbers=[number**3 for number in range(1,11)] print(numbers) print("The first three items in the list are:") print(numbers[0:3]) print("Three items from the middle of the list are:") print(numbers[5:8]) print("The last three items in the list are:") print(numbers[-3:])
true
cabc815a05896d9d72e0f904eac1aede308438e7
thu4nvd/project_euler
/prob014.py
1,184
4.15625
4
#!/usr/bin/env python3 ''' Longest Collatz sequence Problem 14 The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1 It can be ...
true
a3b53793279b63e1facca3a5b4bef20146aff93d
leemanni/receiving-GV_Python
/6.30/stackModule.py
1,583
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[27]: class Stack : # constructor def __init__(self, size = 5) : self.size = size self.stack = list() self.top = 0 # push def push(self, data): if data not in self.stack : if self.size > self.top: ...
false
12abd510bd551ccafd2101bb6392c35357bdbe47
mtmccarthy/langlearn
/bottomupcs/Types.py
1,530
4.71875
5
from typing import NewType, Dict """ In Chapter 1, we learned that 'Everything is a File!'. Here we've created a new type, 'FileType' which models a file as its path in the filesystem. """ FileType = NewType('FileType', str) """ In Chapter 1, we learned about FileDescriptors, which are essentially integer indexes int...
true
6bb5fbe258c60e039c2380dcbbf50dc6b8e5d803
mtmccarthy/langlearn
/dailyredditor/easy/imgurlinks_352.py
1,574
4.25
4
from common import * from typing import Union """ Finds the greatest exponent of n that is less than or equal to another number m Example: if n = 2 and m = 17 return 4 """ def get_base62_character(index: int) -> Union[str, None]: capital_letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' lower_case = 'abcdefghijklmnopqr...
true
17ce6e5c354abe914abb538356201ed5cfc55a25
lamyai-norn/algorithsm-week11
/week11/thursday1.py
279
4.15625
4
def sumFromTo(start,end): result=0 if start>end: return 0 else: for index in range(start,end+1): result=result+index return result startValue=int(input("Start value : ")) endValue=int(input("End value : ")) print(sumFromTo(startValue,endValue))
true
3ce463b0b5860ae48129db242597bb45d7620ecc
NikolasSchildberg/guesser
/guesser_simple.py
1,218
4.21875
4
""" Welcome to the number guesser in python! The logic is to use the bissection method to find a number chosen by the user, only providing guesses and asking to try a bigger or smaller one next time. """ # Initial message print("Welcome to the number guesser!\nThink of a number between 1 and 1000 (including them).I'll...
true
6150528fcd6ecb0f9a68655746318a2f680ee546
Antonio24ch/BEDU-281120
/01_tabla_multiplicar.py
485
4.15625
4
#Preguntar el numero que el usuario quiere multiplicar numero = int(input('Que número quieres multiplicar?\t')) print(f'A continuacion se muestra la tabla del {numero}') print('------------------------------------------------') #Esta función hace esto: # n * 1 = n # n * 2 = n # n * 3 = n # ... for n in range(10): ...
false
826f03f9f1dc41fe4aca2c70b505d7381ba091bf
EagleRock1313/Python
/circle.py
523
4.40625
4
# Load the Math Library (giving us access to math.pi and other values) import math # Ask for the radius of a circle that will be entered as a decimal number radius = eval(input(("Enter the radius of the circle: "))) # Computer circumference and area of this circle circumference = 2 * math.pi * radius area = math.pi ...
true
ebcf7ae783f11ff6e8908df29b9c0c46cd0b54af
petemulholland/learning
/Python/ThinkPython/Chapter18/MyCard.py
1,364
4.15625
4
class Card(object): """ Represents a playing card""" #suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades'] #rank_names = [None, 'Ace', '2', '3', '4', '5', '6', '7', # '8', '9', '10', 'Jack', 'Queen', 'King'] suit_names = ('C', 'D', 'H', 'S') rank_names = (None, 'A', '2', '...
false
fdeecfeec4bbea1b1c5bd1738bbadf905dcb3772
Kapilmundra/Complete-Python-for-Lerner
/4 set.py
691
4.21875
4
#Create set print("Create set") s={"teena","meena","reena"} print(s) # it can print in unorder way #pop the element from the set print("\npop the element from the set") s.pop() # it can pop the element in unorder way print(s) #Add element in the set print("\nAdd element in the set") s.add("priya") # i...
true
d86d7fdc1e4fb8c3e6c328b2d4141f5b2e078f66
das-jishu/data-structures-basics-leetcode
/Leetcode/hard/regular-expression-matching.py
2,506
4.28125
4
""" # REGULAR EXPRESSION MATCHING Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*' where: '.' Matches any single character.​​​​ '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). Exampl...
true