blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
920d2ff4b74ff86352851e8435f0a9761c649392
Cbkhare/Challenges
/multiply_list.py
1,233
4.15625
4
#In case data is passed as a parameter from sys import argv #from string import ascii_uppercase file_name = argv[1] fp = open(file_name,'r+') contents = [ line.strip('\n').split('|') for line in fp] #print (contents) for item in contents: part1 = list(item[0].split(' ')) part1.remove('') part2 = list(...
true
0ea75af0aeb9c2bea86f5c8e95f9ca942344e8a9
Cbkhare/Challenges
/HackerRank_Numpy_Transpose_Flatten.py
1,424
4.125
4
from sys import stdin as Si, maxsize as m import numpy as np class Solution: pass if __name__=='__main__': n,m = map(int,Si.readline().split()) N = np.array([],int) for i in range(n): N = np.append(N,list(map(int,Si.readline().split())),axis=0) N.shape = (n,m) #Note:- #To appe...
true
0c747667e925a98008c91f87dedbd34c2ab10e83
Cbkhare/Challenges
/str_permutations.py
1,087
4.3125
4
#In case data is passed as a parameter from sys import argv from itertools import permutations #from string import ascii_uppercase file_name = argv[1] fp = open(file_name,'r+') contents = [line.strip('\n') for line in fp] #print (contents) for item in contents: #print (item) p_tups= sorted(permutations(i...
true
b6e142f9993d67e2eb0976dd1ddb304315cf28a6
RaelViana/Python_3
/ex018.py
460
4.1875
4
import math #importação da biblioteca math """ Aplicação do Módulo Math """ num = int(input('digite um número par a raiz Quadrada: ')) #recebe num do usuário rq = math.sqrt(num) #aplica a função square root(raiz quadrada) em num print('A raiz quadrada de {} é {}'.format(num, math.ceil(rq))) # a f...
false
ed7fccb8c5b758a7e8461d346a2637f4e380197a
RaelViana/Python_3
/ex032.py
613
4.25
4
""" Estruturas condicionais simples e compostas. """ # estrutura simples nome = str(input('Qual seu nome? ')) if nome == 'Maria': # execulta a ação caso valor seja igual print('Que lindo nome..') print('Bom dia "{}" !'.format(nome)) # estrutura composta nota1 = float(input('Digite a primeira nota: '...
false
ac2ffaa848aee4feacc96c124fa6ca0e6f4480e6
PutkisDude/Developing-Python-Applications
/week3/3_2_nameDay.py
490
4.25
4
#Author Lauri Putkonen #User enters a weekday number and the program tells the name of the day. import calendar day = int(input("Number of the day: ")) -1 print(calendar.day_name[day]) # Could also make a list and print from it but there is inbuilt module in python to do same thing # weekdays = ["Monday", "Tuedsday...
true
7a32efcdfaf7edef3e3ffaffabbeed9bed255bd3
mkgmels73/Bertelsmann-Scholarship-Data-Track
/Python challenge/39_random_password.py
1,389
4.40625
4
#While generating a password by selecting random characters usually creates one that is relatively secure, it also generally gives a password that is difficult to memorize. As an alternative, some systems construct a password by taking two English words and concatenating them. While this password may not be as secure, ...
true
12b45b29d942aec593b21161d8f6c4c6409722f2
kimfucious/pythonic_algocasts
/solutions/matrix.py
1,501
4.53125
5
# --- Directions # Write a function that accepts an integer, n, and returns a n x n spiral matrix. # --- Examples # matrix(2) # [[1, 2], # [4, 3]] # matrix(3) # [[1, 2, 3], # [8, 9, 4], # [7, 6, 5]] # matrix(4) # [[1, 2, 3, 4], # [12, 13, 14, 5], # [11, 16, 15, 6], # [10, 9,...
true
dca708d0b43e4adea6e69b7ec9611e919310a472
kimfucious/pythonic_algocasts
/exercises/reversestring.py
273
4.375
4
# --- Directions # Given a string, return a new string with the reversed order of characters # --- Examples # reverse('apple') # returns 'leppa' # reverse('hello') # returns 'olleh' # reverse('Greetings!') # returns '!sgniteerG' def reverse(string): pass
true
b93be8d587df03aa1ef86361067b3ae45c42e861
kimfucious/pythonic_algocasts
/solutions/levelwidth.py
510
4.15625
4
# --- Directions # Given the root node of a tree, return a list where each element is the width # of the tree at each level. # --- Example # Given: # 0 # / | \ # 1 2 3 # | | # 4 5 # Answer: [1, 3, 2] def level_width(root): widths = [0] l = [root, "end"] while len(l) > 1: nod...
true
fdc8646c69a3c4eb44cd016b4d1708ca77acef07
kimfucious/pythonic_algocasts
/solutions/palindrome.py
410
4.40625
4
# --- Directions # Given a string, return True if the string is a palindrome or False if it is # not. Palindromes are strings that form the same word if it is reversed. *Do* # include spaces and punctuation in determining if the string is a palindrome. # --- Examples: # palindrome("abba") # returns True # palindro...
true
7484096aff7b568bf17f4bc683de3a538807ce52
kimfucious/pythonic_algocasts
/solutions/capitalize.py
1,010
4.4375
4
# --- Directions # Write a function that accepts a string. The function should capitalize the # first letter of each word in the string then return the capitalized string. # --- Examples # capitalize('a short sentence') --> 'A Short Sentence' # capitalize('a lazy fox') --> 'A Lazy Fox' # capitalize('look, it is ...
true
6744b752c094cf71d347868859037e6256cdb4e8
didomadresma/ebay_web_crawler
/ServiceTools/Switcher.py
978
4.28125
4
#!/usr/bin/env python3 __author__ = 'papermakkusu' class Switch(object): """ Simple imitation of Switch case tool in Python. Used for visual simplification """ value = None def __new__(class_, value): """ Assigns given value to class variable on class creation :return: ...
true
21aa97d8eab6bb0f41c63d799ddb126be72a467f
Pooja5573/DS-Pragms
/table_fib_fact.py
867
4.25
4
#ASSIGNMENT : 1 #to find factorial of given num n = int(input("enter the num")) fact = 1 while n>=2 : fact = fact*n n-=1 print("factorial : ",fact) ##ASSIGNMENT : 2 #to find the fibonacci series n = int(input("enter the num")) a = 0 b = 1 c = a+b while c <= n: print("THE FIBONACCI serie...
false
e7d5d7e1c7a2d766c49de8e0009482ad488a3a63
Priktopic/python-dsa
/str_manipualtion/replace_string_"FOO"_"OOF".py
1,052
4.3125
4
""" If a string has "FOO", it will get replaced with "OOF". However, this might create new instances of "FOO". Write a program that goes through a string as many times as required to replace each instances of "FOO" with "OOF". Eg - In "FOOOOOOPLE", 1st time it will become "OOFOOOOPLE". Again we have "FOO", so the 2nd ...
true
57899dbcf24323514b453e3b1a9de5bc01379c8c
Priktopic/python-dsa
/linkedlist/largest_sum_of_ele.py
1,149
4.4375
4
''' You have been given an array containg numbers. Find and return the largest sum in a contiguous subarray within the input array. Example 1: arr= [1, 2, 3, -4, 6] The largest sum is 8, which is the sum of all elements of the array. Example 2: arr = [1, 2, -5, -4, 1, 6] The largest sum is 7, which is the sum of th...
true
17e30a414fdf6bf310fa229ddede6b7dd23551bc
Priktopic/python-dsa
/str_manipualtion/rmv_digits_replace_others_with_#.py
350
4.25
4
""" consider a string that will have digits in that, we need to remove all the not digits and replace the digits with # """ def replace_digits(s): s1 = "" for i in s: if i.isdigit(): s1 += i return(re.sub('[0-9]','#',s1)) # modified string which is after replacing the # with digits re...
true
153687f5a58296d127d14789c96ce8843eb236a0
dylanly/Python-Practice
/best_friends.py
386
4.25
4
list_friends = ['Ken', 'Mikey', 'Mitchell', 'Micow'] print("Below you can see all my best friends!\n") for friend in list_friends: print(friend) if 'Drew' not in list_friends: print("\n:O \nDrew is not in my friends list!!\n") list_friends.append('Drew') for friend in list_friends: print...
true
41a3c87f4494962b830a3fae87ce7864d7b2a502
CHINNACHARYDev/PythonBasics
/venv/ConditionalStatements.py
1,071
4.5
4
# Conditional statements (Selection Statements/Decesion Making Statements) # It will decide the execution of a block of code based on the condition of the expression # 'if' Statement # 'if else' Statement # 'if elif else' Statement # Nested 'if' Statement A = 'CHINNA' B = 'CHARY' C = 'CHINNACHARY' D = 'CHINNA CHARY'...
false
7014390c7d7031113d04ac773ee1dec33950aeea
KKobuszewski/pwzn
/tasks/zaj2/zadanie1.py
1,623
4.15625
4
# -*- coding: utf-8 -*- def xrange(start=0, stop=None, step=None): """ Funkcja która działa jak funkcja range (wbudowana i z poprzednich zajęć) która działa dla liczb całkowitych. """ #print(args,stop,step) x = start if step is None: step = 1 if stop is None: stop = st...
true
9aab8e7e48f9e49f5769bd101b6697adb7809ea5
clark-ethan9595/CS108
/lab02/stick_figure.py
936
4.1875
4
''' Drawing Stick Figure September 11, 2014 Lab 02 @author Serita Nelesen (smn4) @authors Ethan and Mollie (elc3 and mfh6) ''' #Gain access to the collection of code named "turtle" import turtle #Give the name "window" to the screen where the turtle will appear window = turtle.Screen() #Create a turtle and name it ...
false
91023ff23cf97b09c25c2fe53f787aa764c8ca69
clark-ethan9595/CS108
/lab05/song.py
1,076
4.375
4
''' A program to specify verses, container, and desired food/beverage. Fall 2014 Lab 05 @author Ethan Clark (elc3) ''' #Prompt user for their own version of the song lyrics verses = int(input('Please give number of verses for song:')) container = input('Please give a container for your food/beverage:') substance = inp...
true
8bcb5e719f1148779689d7d80422c468257a9f0f
clark-ethan9595/CS108
/lab02/einstein.py
729
4.21875
4
''' Variables and Expessions September 11, 2014 Lab 02 @author Ethan and Mollie (elc3 and mfh6) ''' #Ask user for a three digit number. number = int(input('Give a three digit number where the first and last digits are more than 2 apart : ')) #Get the reverse of the user entered number. rev_number = (number//1)%10 * 1...
true
2ab3022ae0ea51d58964fffd5887dbd5f1812974
huajianmao/pyleet
/solutions/a0056mergeintervals.py
1,085
4.21875
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/merge-intervals/ # # DESC: # ===== # Given a collection of intervals, merge all overlapping intervals. # # Example 1: # Input: [[1,3],[2,6],[8,10],[15,18]] # Output: [[1,6],[8,10],[15,18]] # Explan...
true
cd72d43f6a973cf8d0bb3b522e9226dc7f8eef76
ACES-DYPCOE/Data-Structure
/Searching and Sorting/Python/merge_sort.py
1,939
4.125
4
''' Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the two sorted halves.The merge() function is used for merging two halves. The merge(arr, l, m, r) is key process that assumes that arr[l..m] and arr[m+1..r] are sorted and merges ...
true
aad803d232b8bb4e205cd3b0cac8233f228b44d3
ACES-DYPCOE/Data-Structure
/Searching and Sorting/Python/shell_sort.py
1,254
4.15625
4
#Shell sort algorithm using python #Shell sort algorithm is an improved form of insertion sort algorithm as it compares elements separated by a gap of several position. #In Shell sort algorithm, the elements in an array are sorted in multiple passes and in each pass, data are taken with smaller and smaller gap sizes....
true
4fc35071689bad45b1cc4c9c02aee401b1364ccc
shiuchunming/python3_learning
/datatype.py
1,496
4.1875
4
def list(): print("---List---") a_list = ['a'] a_list = a_list + [2.0, 3] a_list.append([1, 2]) a_list.extend(['four', '#']) a_list.insert(0, '1') print("List A: " + str(a_list)) print("Length of list: " + str(len(a_list))) print("Slice List:" + str(a_list[1:3])) print("Slice ...
false
f5cf5e85ffd22f6a59d4d1c1f183b2b668f82e29
faizanzafar40/Intro-to-Programming-in-Python
/2. Practice Programs/6. if_statement.py
298
4.1875
4
""" here I am using 'if' statement to make decisions based on user age """ age = int(input("Enter your age:")) if(age >= 18): print("You can watch R-Rated movies!") elif(age > 13 and age <= 17): print("You can watch PG-13 movies!") else: print("You should only watch Cartoon Network")
true
c56354bd9e49655c5f7f4a4c8f009ee7c13b7272
razi-rais/toy-crypto
/rsa.py
1,457
4.1875
4
# Toy RSA algo from rsaKeyGen import gen_keypair # Pick two primes, i.e. 13, 7. Try substituting different small primes prime1 = 13 prime2 = 7 # Their product is your modulus number modulus = prime1 * prime2 print "Take prime numbers %d, %d make composite number to use as modulus: %d" % (prime1, prime2, modulus) prin...
true
26960cd52e3c63adcedc75d86f102741dea7aace
nitishjatwar21/Competitive-Coding-Repository
/Bit Manupulation/Is Power Of 2/is_pow_of_2.py
238
4.4375
4
def is_pow_of_2(num): return (num and (not(num & (num-1)))) number = 5 if(is_pow_of_2(number)): print("number is power of 2 ") else: print("number is not a power of 2") ''' Input : 5 Output :number is not a power of 2 '''
false
2d727e0acb9fcca8ecee72742970dbc8831af33d
RodolfoBaez/financial-calculators
/main.py
1,662
4.21875
4
print("Welcome to Financial-Calculators ") print("What would you like to calulate ") print("") print("1. Bank Savings Account Interest ") print("2. Stock Market Growth Per Year") print("") user_choice = input("Input your response ") if user_choice == "1": print("Using the Annual Inflation Rate Of 2.5%, We Will Te...
false
7715a9ad5a59aa0962b4257520b0143b0b9e98ea
sirdesmond09/mypython-
/pro.py
2,901
4.125
4
print("WELCOME TO MATHCALS") operations=['Add', 'Sub', 'Mult', 'Divi'] print(operations) g=1 q=int(input("Choose the number of times you want to solve ")) while g<=q: gee=input("choose your arthimetric operation") if (gee==operations[0]): w=int(input("are you adding 2 or 3 numbers")) if (w==2): ...
false
5a25d397ed98da278f080f2d97fd9149c33e403e
FranHuzon/ASIR
/Marcas/Python/Ejercicios/Listas/Ejercicio 2.py
2,246
4.3125
4
#-------------------- CREACIÓN LISTA --------------------# palabras = input('Escribe la palabra que quieras añadir a la lista (Para terminar pulsa ENTER sin escribir nada): ') lista_palabras = [] while palabras != '': lista_palabras.append(palabras) palabras = input('Escribe la palabra que quieras añadir a la lista ...
false
bc60a2c690b7f7e51f086f92258a7e9bc14ff466
raoliver/Self-Taught-Python
/Part II/Chapter 14.py
997
4.21875
4
##More OOP class Rectangle(): recs = []#class variable def __init__(self, w, l): self.width = w#Instance variable self.len = l self.recs.append((self.width, self.len))#Appends the object to the list recs def print_size(self): print("""{} by {}""".format(self.width, self.le...
true
7633a1fedf0957e1577ffcae5d1b35fc894a3b34
knmarvel/backend-katas-functions-loops
/main.py
2,253
4.25
4
#!/usr/bin/env python import sys import math """Implements math functions without using operators except for '+' and '-' """ __author__ = "github.com/knmavel" def add(x, y): added = x + y return added def multiply(x, y): multiplied = 0 if x >= 0 and y >= 0: for counter in range(y): ...
true
e2755d36a518efc21f5c479c4c3f32a54408eade
behind-the-data/ccp
/chap2/name.py
534
4.3125
4
name = "ada lovelace" print(name.title()) # the title() method returns titlecased STRING. # All below are optional # Only Capital letters print(name.upper()) # Only Lower letters print(name.lower()) ## Concatenation ## first_name = "ada" last_name = "lovelace" full_name = first_name + " " + last_name print(full_n...
true
2d29f47c7b91c33feac52f38bf0168ac6918d821
jcol27/project-euler
/41.py
1,674
4.3125
4
import math import itertools ''' We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? Can use itertools similar to previous problem. We can use t...
true
5c4fc548e88cada634ce1e2c84bf0fa494d6b6a8
mparkash22/learning
/pythonfordatascience/raise.py
538
4.1875
4
#raise the value1 to value2 def raise_both(value1, value2): #function header """Raise value1 to the power of value 2 and vice versa""" #docstring new_value1= value1 ** value2 #function body new_value2= value2 ** value1 new_tuple = (new_value1, new_value2) return new_tuple #we c...
true
f9dbc54c6b2cf46b0f879bce94908ff944045eb2
leemyoungwoo/pybasic
/python/활용자료/예제/04/ex4-4.py
218
4.1875
4
for i in range(10) : print(i, end =' ') print() for i in range(1, 11) : print(i, end =' ') print() for i in range(1, 10, 2) : print(i, end =' ') print() for i in range(20, 0, -2) : print(i, end =' ')
false
856ea8f0efef73fba334f00caa090b9a2697c0a8
xiaomengxiangjia/Python
/foods.py
580
4.34375
4
my_foods = ['pizza', 'falafel', 'carrot cake', 'beer', 'chicken'] friend_foods = my_foods[:] my_foods.append('cannoli') friend_foods.append('icecream') print("My favorite foods are:") print(my_foods) print("\nMy friends's favorite foods are:") print(friend_foods) print("The first three items in the list are:" ) pri...
false
aec15d1708777d5cccc103aa309fab48491fb53c
jesuarezt/datacamp_learning
/python_career_machine_learning_scientist/04_tree_based_models_in_python/classification_and_regression_tree/02_entropy.py
1,607
4.125
4
#Using entropy as a criterion # #In this exercise, you'll train a classification tree on the Wisconsin Breast Cancer dataset using entropy as an information criterion. #You'll do so using all the 30 features in the dataset, which is split into 80% train and 20% test. ## ##X_train as well as the array of labels y_tr...
true
a5b6035fb3d38ef3459cfd842e230bbfb2148583
jesuarezt/datacamp_learning
/python_career_machine_learning_scientist/06_clustering_analysis_in_python/03_kmeans_clustering/01_example_kmeans.py
1,881
4.1875
4
#K-means clustering: first exercise # #This exercise will familiarize you with the usage of k-means clustering on a dataset. Let us use the Comic Con dataset and check how k-means clustering works on it. # #Recall the two steps of k-means clustering: # # Define cluster centers through kmeans() function. It has...
true
5ca2cf2b0365dd45d8f5ff5dc17b8e21d6ab751f
remichartier/002_CodingPractice
/001_Python/20210829_1659_UdacityBSTPractice/BinarySearchTreePractice_v00.py
1,210
4.25
4
"""BST Practice Now try implementing a BST on your own. You'll use the same Node class as before: class Node(object): def __init__(self, value): self.value = value self.left = None self.right = None This time, you'll implement search() and insert(). You should rewrite search() and not use yo...
true
c7f1a592ba1dc81f24bc3097fbde5f0784eecd35
remichartier/002_CodingPractice
/001_Python/20210818_2350_UdacityQuickSortAlgo/QuickSorAlgoPivotLast_v01.py
1,305
4.1875
4
"""Implement quick sort in Python. Input a list. Output a sorted list.""" # Note : method always starting with last element as pivot def quicksort(array): # quick sort with pivot # Then quick sort left_side of pivot and quick_sort right side of pivot # Then combine left_array + Pivot + Right Array # b...
true
d975dee37afc80c487f6ff0b1723697f340b2448
ZeroDestru/aula-1-semestre
/aulas/oitavo3.py
1,764
4.125
4
import turtle myPen = turtle.Turtle() myPen.tracer(5) myPen.speed(5) myPen.color("blue") # This function draws a box by drawing each side of the square and using the fill function def box(intDim): myPen.begin_fill() # 0 deg. myPen.forward(intDim) myPen.left(90) # 90 deg. myPen....
true
92f0837d2b94b72d013e7cb41d72ef7f5c78fdf8
HYnam/MyPyTutor
/W2_Input.py
1,110
4.375
4
""" Input and Output Variables are used to store data for later use in a program. For example, the statement word = 'cats' assigns the string 'cats' to the variable word. We can then use the value stored in the variable in an expression. For example, sentence = 'I like ' + word + '!' will assign the string 'I like cat...
true
c21a9037c094373b18800d86a8a5c64ea1beb0f7
HYnam/MyPyTutor
/W6_range.py
711
4.53125
5
""" Using Range The built-in function range returns an iterable sequence of numbers. Write a function sum_range(start, end) which uses range to return the sum of the numbers from start up to, but not including, end. (Including start but excluding end is the default behaviour of range.) Write a fun...
true
0fbe09ab6841a44123707d905ee14be14e03fc53
HYnam/MyPyTutor
/W12_recursive_base2dec.py
354
4.125
4
""" Recursively Converting a List of Digits to a Number Write a recursive function base2dec(digits, base) that takes the list of digits in the given base and returns the corresponding base 10 number. """ def base2dec(digits, base): if len(digits) == 1: return digits[0] else: return digits[-1] + ...
true
8dc081fad4227c0456266c0eab5ae3fcf5ed4d36
HYnam/MyPyTutor
/W7_except_raise.py
1,736
4.5625
5
""" Raising an Exception In the previous problem, you used a try/except statement to catch an exception. This problem deals with the opposite situation: raising an exception in the first place. One common situation in which you will want to raise an exception is where you need to indicate that some precond...
true
dc68b3a0f41f752b188744d0e1b0cdb547682b11
HYnam/MyPyTutor
/W3_if_vowels.py
1,070
4.5
4
""" If Statements Using Else In the previous question, we used an if statement to run code when a condition was True. Often, we want to do something if the condition is False as well. We can achieve this using else: if condition: code_if_true [code_if_true...] else: code_if_false ...
true
d8bdbbf1e4426b928b14400e35938562cffaa83d
zwiktor/Checkio_zadania
/Split_list.py
676
4.25
4
# https://py.checkio.org/en/mission/split-list/ def split_list(items: list) -> list: half_list = len(items)//2 if len(items) % 2 == 1: half_list += 1 return [items[:half_list], items[half_list:]] if __name__ == '__main__': print("Example:") print(split_list([1, 2, 3, 4, 5, 6])) # Th...
false
edb7cb3c4ee6562817d60924828836e66eed9011
PraveshKunwar/python-calculator
/Volumes/rcc.py
410
4.125
4
import math def rccCalc(): print(""" Please give me radius and height! Example: 9 10 9 would be radius and 10 would be height! """) takeSplitInput = input().split() if len(takeSplitInput) > 2 or len(takeSplitInput) < 2: print("Please give me two numbers only to work with!") value...
true
32321cdb22a57d52a55354adc67bdf020828a8e1
nitinaggarwal1986/learnpythonthehardway
/ex20a.py
1,317
4.375
4
# import the argv to call arguments at the script call from sys module. from sys import argv # Asking user to pass the file name as an argument. script, input_file = argv # To define a function to print the whole file passed into function as # a parameter f. def print_all(f): print f.read() # To define a rewind fu...
true
8872d33049899b976831cea4e01e8fc73f88ebef
bvsbrk/Learn-Python
/Basics/using_super_keyword.py
684
4.46875
4
class Animal: name = "animal" """ Here animal class have variable name with value animal Child class that is dog have variable name with value dog So usually child class overrides super class so from child class If we see the value of name is dog To get the value of super class we use 'sup...
true
9b9a3cc0ceb807373aa9c542ba8f3de0a28436e6
eazapata/python
/Ejercicios python/PE5/PE5E10.py
288
4.1875
4
#Escribe un programa que pida la altura de un #triángulo y lo dibuje de la siguiente #manera: alt=int(input("Introduce la altura del triangulo\n")) simb=("*") for i in range (alt): print (" "*(alt-1)+simb) simb=simb+"**" alt=alt-1
false
7ae4858f192bbbc1540e1fb3d8a3831e6a04f6e9
CodeItISR/Python
/Youtube/data_types.py
979
4.59375
5
# KEY : VALUE - to get a value need to access it like a list with the key # key can be string or int or float, but it need to be uniqe # Creating an dictionary dictionary = {1: 2 ,"B": "hello" , "C" : 5.2} # Adding a Key "D" with value awesome dictionary["D"] = "awesome" print(dictionary["D"]) # Print the dictionary ...
true
475fe0c425bd46ed406d2ce6492b2b0c0768d7c6
scidam/algos
/algorithms/intervieweing.io/max_prod.py
580
4.125
4
# find maximum product of two integers in array # arr = [-1, 4, 9, -10, -8] def max_prod(arr): """ Find maximum product of 2 ints """ fmax = smax = fmin = smin = arr[0] for k in range(len(arr)): if arr[k] > fmax: fmax = arr[k] if arr[k] < fmin: fmin = arr[k] ...
false
4c8aaf045dae040ed39b071d4e054765b7dfd3f5
scidam/algos
/algorithms/intervieweing.io/shuffle_fy.py
324
4.21875
4
# Shuffle input array using Fisher-Yates algorithm import random arr = list(range(10)) def shuffle(arr): n = len(arr) for j in range(len(arr)-1): i = random.randint(0, j) arr[i], arr[j] = arr[j], arr[i] return arr print("Before shuffling: ", arr) print("After shuffling: ", shuffle(a...
false
a1c2a407f9e3c3bac070a84390674c519ca8ed63
scidam/algos
/algorithms/sorting/bubble.py
1,446
4.21875
4
__author__ = "Dmitry E. Kislov" __created__ = "29.06.2018" __email__ = "kislov@easydan.com" def bubble_sort(array, order='asc'): """Bubble sorting algorithm. This is a bit smart implementation of the bubble sorting algoritm. It stops if obtained sequence is already ordered. **Parameters** :...
true
3d4f2c0e283d492aef64578a2e3fb3ebf24bf42f
SakshamMalik99/Python-Mastery
/List/List5.py
973
4.15625
4
print("Program :5 :") # *number : number of time List. list1 = [1, 3, 5] print(list1*2) list1 = ['Data Structure', 'C', 'C++', 'Java', 'Unix', 'DBMS', 'Python', 'SQL', 'IBM', 'Microsoft', 'Apple'] print("Orignal list is ", list1) for data in list1: print(data) list1 = [1, 3, 5, 7, 17, 9, 19, 7...
false
30cf241927d7fb24f62b6ec3afd4952e05d01032
KrisztianS/pallida-basic-exam-trial
/namefromemail/name_from_email.py
512
4.40625
4
# Create a function that takes email address as input in the following format: # firstName.lastName@exam.com # and returns a string that represents the user name in the following format: # last_name first_name # example: "elek.viz@exam.com" for this input the output should be: "Viz Elek" # accents does not matter emai...
true
ea2638797b8f339b3a16f09b52a918690b1df4e6
karacanil/Practice-python
/#13.py
243
4.15625
4
#13 inp=int(input('How many fibonnaci numbers you want me to generate:\n')) def fibonnaci(num): counter=0 x=1 y=0 while counter<num: print(x) temp=x x+=y y=temp counter+=1 fibonnaci(inp)
false
b3561a5180fc2c219f1b7fa97a663de9ea0be793
Whitatt/Python-Projects
/Database1.py
1,057
4.25
4
import sqlite3 conn = sqlite3.connect('database1.db') with conn: cur = conn.cursor() #Below I have created a table of file list cur.execute("CREATE TABLE IF NOT EXISTS tbl_filelist(ID INTEGER PRIMARY KEY AUTOINCREMENT, \ col_items TEXT)") # in the file list, i have created a column of items. ...
true
7d32b260a8251dfe0bd111e615f8c84975d7102c
zarkle/code_challenges
/codility/interviewing_io/prechallenge2.py
2,097
4.1875
4
""" Mary has N candies. The i-th candy is of a type represented by an interger T[i]. Mary's parents told her to share the candies with her brother. She must give him exactly half the candies. Fortunately, the number of candies N is even. After giving away half the candies, Mary will eat the remaining ones. She loves...
true
ba81db6eb0340d66bc8151f3616069d4d6a994a0
zarkle/code_challenges
/dsa/recursion/homework_solution.py
2,026
4.3125
4
def fact(n): """ Returns factorial of n (n!). Note use of recursion """ # BASE CASE! if n == 0: return 1 # Recursion! else: return n * fact(n-1) def rec_sum(n): """ Problem 1 Write a recursive function which takes an integer and computes the cumulative ...
true
95ceaa512a7cf774c5ca911f131109f93dc55c50
zarkle/code_challenges
/hackerrank/25_python_if_else.py
269
4.125
4
# https://www.hackerrank.com/challenges/py-if-else/problem #!/bin/python3 N = int(input()) if N % 2 == 1: print('Weird') if N % 2 == 0: if 1 < N < 6: print('Not Weird') elif 5 < N < 21: print('Weird') else: print('Not Weird')
false
84ba5a4f2a1b9761148d8ec7c803bb7732f3e75a
zarkle/code_challenges
/fcc_pyalgo/07_minesweeper.py
1,491
4.5
4
""" Write a function that wil take 3 arguments: - bombs = list of bomb locations - rows - columns mine_sweeper([[0,0], [1,2]], 3, 4) translates to: - bomb at row index 0, column index 0 - bomb at row index 1, column index 2 - 3 rows (0, 1, 2) - 4 columns (0, 1, 2, 3) [2 bomb location coordinates in a 3x4 matrix] we s...
true
c2a5429480d3c26fefd305b728e27c8fe7824ebf
zarkle/code_challenges
/hackerrank/16_tree_postorder_trav.py
783
4.21875
4
# https://www.hackerrank.com/challenges/tree-postorder-traversal/problem """ Node is defined as self.left (the left child of the node) self.right (the right child of the node) self.info (the value of the node) """ def postOrder(root): #Write your code here traverse = '' def _walk(node=None): ...
true
7624dfe6435e1575121da552c169df512f974c24
rxu17/physics_simulations
/monte_carlo/toy_monte_carlo/GluonAngle.py
1,025
4.1875
4
# Rixing Xu # # This program displays the accept and reject method - generate a value x with a pdf(x) as the gaussian distribution. # Then generate a y value where if it is greater than the pdf(x), we reject that x, otherwise we accept it # Physically, the gluon is emitted from the quark at an angle # Assumptions:...
true
c6be4757dcfe28f09cee4360444ede6068058a8b
omarMahmood05/python_giraffe_yt
/Python Basics/13 Dictionaries.py
786
4.40625
4
# Dict. in python is just like dicts in real life. You give a word and then assign a meaning to it. Like key -> An instrument used to open someting speciftc. # In python we do almost the same give a key and then a value to it. For eg Jan -> January monthConversions = { "Jan": "January", "Feb": "February",...
true
e03f5102f11516c3c3fd7afb465799879f79c6a0
ritomar/ifpi-386-2017-1
/Lista03_Q04.py
815
4.125
4
# 4. A seqüência de Fibonacci é a seguinte: # 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ... # Sua regra de formação é simples: os dois primeiros elementos são 1; # a partir de então, cada elemento é a soma dos dois anteriores. # Faça um algoritmo que leia um número inteiro calcule o seu número # de F...
false
2781aceb1adfff0d5da87946d824572779f73c8e
mdeng1110/Computing_Talent_Initiative
/9_P3_Min_Stack.py
1,041
4.125
4
class MinStack(object): def __init__(self): """ initialize your data structure here. """ self.stack = [] self.min = 999 def push(self, x): """ :type x: int :rtype: None """ if x <= self.min: self.stack.append(self.min) ...
false
a1a726746b3b41b70fedef537c27a5da6c313d28
mdeng1110/Computing_Talent_Initiative
/7_P3_Evaluate_Expression.py
893
4.125
4
def evaluate_expression(expression): # create empty stack - > stack = [] stack = [] # loop over the expression for element in expression: if element.isnumeric(): stack.append(int(element)) else: #print('STACK: ', stack) if element == "*": a = stack.pop() b = stack.pop()...
false
2935d9e5617f497d5eb145bc473650ab021d996a
huangqiank/Algorithm
/leetcode/sorting/sort_color.py
1,112
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 ...
true
317f0783b9e840b41f9d422896475d5d76949889
huangqiank/Algorithm
/leetcode/tree/binary_tree_level_order_traversal2.py
1,205
4.15625
4
##Given a binary tree, return the bottom-up level order traversal of its nodes' values. # (ie, from left to right, level by level from leaf to root). ##For example: ##Given binary tree [3,9,20,null,null,15,7], ## 3 ## / \ ## 9 20 ## / \ ## 15 7 ##return its bottom-up level order traversal as: ##[ ## [1...
true
f07911a813545ba8213b8500356406cd1a3fb8af
Hyeongseock/EulerProject
/Problem004.py
1,832
4.15625
4
''' Largest palindrome product Problem 4 ''' ''' English version A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. ''' #Make empty list to add number number_lis...
true
88021e789e0602fff3527af5edd82e2db4e5376c
omolea/BYUI_CS101
/week_02/team_activity.py
2,155
4.15625
4
""" Jacob Padgett W02 Team Activity: Bro Brian Wilson """ First_name = input("What is you first name: ") Last_name = input("What is you last name: ") Email_Address = input("What is you email: ") Phone_Number = input("What is you number: ") Job_Title = input("What is you job: ") ID_Number = input("What is you id: ") H...
true
029fb3d02ca753d046ce00a6156f7ff75e8c0210
alexisalt/curso_pensamiento_computacional
/listas.py
1,503
4.4375
4
my_list = [1, 2, 3] print(my_list[0]) print(my_list[1:]) #Veremos ahora los metodos de las listas y sus side-effects my_list.append(4) print(my_list) #NO EXISTIO una reasignacion, simplemente la modificamos a la lista #agreganndole el numero 4 al final. #modificar ahora una de las posiciones my_list[0] = 'a' #A d...
false
c3f197930c850ca43bc7c7339d1ab7482ea218bc
shoel-uddin/Digital-Crafts-Classes
/programming102/exercises/list_exercises.py
1,555
4.375
4
#Exercise 1 # Create a program that has a list of at least 3 of your favorite # foods in order and assign that list to a variable named "favorite_foods". # print out the value of your favorite food by accessing by it's index. # print out the last item on the list as well. favorite_foods = ["Pizza", "Pasta", "Byriani"...
true
d652382b0e657735b15fc377cf8c087d32759c6a
shoel-uddin/Digital-Crafts-Classes
/programming102/exercises/key-value-pairs_exercise.py
718
4.3125
4
#1 movie = { "name":"Star Wars", "episode":4, "year":"1977" } print (movie) #2 person = { "first_name": "Sho", "last_name": "Uddin", "age": 30, "hair_color": "Black" } for key in person: print (person[key]) print (f"Hello {person['first_name']} {person['last_name']}. Since you ...
false
28c51e037e37d5567b59afb6abb3cbdf40f9e64b
Eccie-K/pycharm-projects
/looping.py
445
4.28125
4
#looping - repeating a task a number of times # types of loops: For loop and while loop # modcom.co.ke/datascience counter = 1 # beginning of the loop while counter <= 10: # you can count from any value print("hello", counter) counter = counter +1 # incrementing z = 9 while z >= -9: print("you", z) ...
true
deb60878e985ea2f31f2c57fd7f035db19cfbd5f
Eccie-K/pycharm-projects
/leap year.py
330
4.25
4
# checking whether a year is leap or not year = int(input("enter the year in numbers:")) if year % 4 != 0: print("this is not a leap year") elif year % 4 == 0 and year % 100 == 0 and year % 400 == 0: print("it is a leap year") elif year % 4 == 0 and year % 100 != 0: print("leap year") else: print("l...
false
d1bbfae6e3467c8557852939faf5cdd1daa1f2ca
Robock/problem_solving
/interview_code_14.py
1,127
4.125
4
#Given a non-finite stream of characters, output an "A" if the characters "xxx" are found in exactly that sequence. #If the characters "xyx" are found instead, output a "B". #Do not re-process characters so as to output both an “A” and a “B” when processing the same input. For example: #1. The following input xx...
true
ef02434465a6d6da8ebcec85cbc10711f6660760
wyxvincent/turtle_lesson
/poligon.py
413
4.1875
4
import turtle t = turtle.Pen() def polygon(side, length): if side < 2: print("2条边不足以构成多边形") else: angle = 180 - (side - 2) * 180 / side for i in range(side): t.forward(length) t.left(angle) turtle.done() side = int(input("请输入多边形的边数:")) length = int(input("请输...
false
5c69c5fbd745c124255cae5cf5856026b0b6e989
ashwin-pajankar/Python-Bootcamp
/Section15/04Dict.py
612
4.15625
4
dict1 = {"brand": "Intel", "model": "8008", "year": 1972} print(dict1) print(dict1["brand"]) print(dict1.get("model")) dict1["brand"] = "AMD" dict1["model"] = "Ryzen" dict1["year"] = 2017 print(dict1) for x in dict1: print(x) for x in dict1: print(dict1[x]) for x in dict1.values(): ...
false
c7b7a3f789e1481bdd819b815820bebefddb6582
ashwin-pajankar/Python-Bootcamp
/Section09/08fact.py
225
4.3125
4
num = int(input("Please enter an integer: ")) fact = 1 if num == 0: print("Factorial of 0 is 1.") else: for i in range (1, num+1): fact = fact * i print("The factorial of {0} is {1}.".format(num, fact))
true
787dc5e851fba1bf8819f643da671ec4b0b06462
rubramriv73/daw1.2
/prog/python/tareas/ejerciciosSecuenciales/ej16_coches.py
1,518
4.25
4
''' @author: Rubén Ramírez Rivera 16. Dos vehículos viajan a diferentes velocidades (v1 y v2) y están distanciados por una distancia d. El que está detrás viaja a una velocidad mayor. Se pide hacer un algoritmo para ingresar la distancia entre los dos vehículos (km) y sus respectivas velocidades (km/h) y con esto...
false
71aaf25131020ba822111659bb2594904b4f8e63
rubramriv73/daw1.2
/prog/python/tareas/ejerciciosSecuenciales/ej15_intercambio.py
888
4.28125
4
''' @author: Rubén Ramírez Rivera 15. Dadas dos variables numéricas A y B, que el usuario debe teclear, se pide realizar un algoritmo que intercambie los valores de ambas variables y muestre cuanto valen al final las dos variables. ''' print('\n *** PROGRAMA QUE INTERCAMBIA EL VALOR DE 2 VARIABLES *** \n') #Ped...
false
718ebb2daf0753bcaeeef1bfc6c226f320000859
zenvin/ImpraticalPythonProjects
/chapter_1/pig_latin_ch1.py
926
4.125
4
## This program will take a word and turn it into pig latin. import sys import random ##get input VOWELS = 'aeiouy' while True: word = input("Type a word and get its pig Latin translation: ") if word[0] in VOWELS: pig_Latin = word + 'way' else: pig_Latin = word[1:] + word[0] + 'ay' p...
true
d436073bd316bd56c8c9958785e0bb18476944a7
Soundaryachinnu/python_script
/classobj.py
1,360
4.125
4
#!/usr/bin/python class Parent: # define parent class parentAttr = 100 def __init__(self): print "Calling parent constructor" def parentMethod(self): print 'Calling parent method' def setAttr(self, attr): Parent.parentAttr = attr def getAttr(self): print "Parent attribu...
true
f60b812a06af2b1a20d6f8c609c5c06492fe3f8c
Arsal-Sheikh/Dungeon-Escape---CS-30-Final
/gamemap.py
2,604
4.25
4
class Dungeon: def __init__(self, name, riddle, answer): """Creates a dungeon Args: name (string): The name of the dungeon riddle (string): The riddle to solve the dungeon answer (string): The answer to the riddle """ self.name = name self...
true
6030e8ed6694c33baf1b4a8851323c5adcfa9c79
ju9501/iot-kite
/Python/func_2.py
381
4.5
4
# list 선언 list_a = [1, 2, 3, 4, 5] list_b = list(range(1,6)) print(list_a) print(list_b) # 리스트 역순으로 뒤집는다. list_reversed = reversed(list_a) list_reversed = list(list_reversed) # list 출력 print('list_a :',list_a) print('list(list_reversed) :',list_reversed) # for 문장을 이용해서 역순 참조 for i in reversed(list_a): print(i)...
false
d9736075107c9ca1f288291a0109789e658d00c1
1ekrem/python
/CrashCourse/chapter10/tiy103.py
1,962
4.375
4
''' 10-3. Guest: Write a program that prompts the user for their name. When they respond, write their name to a file called guest.txt. 10-4. Guest Book: Write a while loop that prompts users for their name. When they enter their name, print a greeting to the screen and add a line recording their visit in a file called...
true
9a6a512989a683662cb0947cc5b7ad2d3ba903e7
1ekrem/python
/CrashCourse/chapter8/tiy86.py
2,533
4.75
5
""" 8-6. City Names: Write a function called city_country() that takes in the name of a city and its country. The function should return a string formatted like this: "Santiago, Chile" Call your function with at least three city-country pairs, and print the value that’s returned. """ def city_country(cityName, country...
true
38f7a26fd5f45b93c1d1ed6669bd362a55e2f641
1ekrem/python
/CrashCourse/chapter8/tiy89.py
1,670
4.46875
4
"""8-9. Magicians: Make a list of magician’s names. Pass the list to a function called show_magicians(), which prints the name of each magician in the list.""" def show_magicians(magicians): for name in magicians: print(name) names = ['Ekrem', 'Daria', 'Pupsik'] show_magicians(names) """8-10. ...
true
8b816e4924d13dad093ea03f4967cae78eb494d5
Lyonidas/python_practice
/Challenge-4.py
1,759
4.1875
4
# Preston Hudson 11/21/19 Challenge 4 Written in Python #1. Write a function that takes a number as input and returns that number squared. def f(x): """ returns x squared :param x: int. :return: int sum of x squared """ return x ** 2 z = f(4) print(z) #2. Create a function that accepts a str...
true
ceb3a00d884b1ee19687364f03d1755e7932c43d
Lyonidas/python_practice
/Challenge-6.py
1,652
4.1875
4
# Preston Hudson 11/25/19 Challenge 6 Written in Python #1. Print every character in the string "Camus". author = "Camus" print(author[0]) print(author[1]) print(author[2]) print(author[3]) print(author[4]) #2. Write a program that collects two strings from the user, inserts them into a string and prints a new strin...
true
9cd05b9e27b20535a31ceca3db2987fd97a85ae0
Blasco-android/Curso-Python
/desafio60.py
562
4.125
4
# Calcular o Fatorial ''' #Utilizando modulo from math import factorial print(''' #[ 1 ] Calcular Fatorial #[ 0 ] Fechar Programa ''') abrir = int(input('Escolha uma Opcão: ')) while abrir != 0: num = int(input('Digite um valor: ')) print('O fatorial de {} é {}.'.format(factorial(num))) ''' num = int(input...
false
76178534554fa030e42e9f7a2d23db151b282b09
jcalahan/ilikepy
/004-functions.py
311
4.15625
4
# This module explores the definition and invocation of a Python function. PI = 3.1459 def volume(h, r): value = PI * h * (r * r) return value height = 42 radius = 2.0 vol = volume(height, radius) print "Volume of a cylinder with height of %s and radius of %s is %s" \ % (height, radius, vol)
true
2b409cfeb923e07db625a46cf4a357cc627d5a20
niranjan2822/Interview1
/count Even and Odd numbers in a List.py
1,827
4.53125
5
# count Even and Odd numbers in a List ''' Given a list of numbers, write a Python program to count Even and Odd numbers in a List. Example: Input: list1 = [2, 7, 5, 64, 14] Output: Even = 3, odd = 2 Input: list2 = [12, 14, 95, 3] Output: Even = 2, odd = 2 ''' # Example 1: count Even and Odd numbers from given li...
true