blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
8c8da9e1a61a6d6d78a2535e2b1bbda1a31b8b17
hhoangnguyen/mit_6.00.1x_python
/test.py
508
4.3125
4
def insertion_sort(items): # sort in increasing order for index_unsorted in range(1, len(items)): next = items[index_unsorted] # item that has to be inserted # in the right place # move all larger items to the right i = index_unsorted while i > 0 and items[i - 1] > next...
true
08b1c52901da46b2e7beb41246effc65ed9b4d3f
hhoangnguyen/mit_6.00.1x_python
/week_1/1_1.py
713
4.15625
4
""" Assume s is a string of lower case characters. Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghakl', your program should print: 5 """ string = 'azcbobobegghakl' def is_valid_vowel(char): if char == ...
true
655a5b9cf59b58bde19148bbae7ad6650fe23374
advikchava/python
/learning/ms.py
484
4.21875
4
print("1.Seconds to minutes") print("2.Minutes to seconds") ch=int(input("Choose one option:")) if ch==1: num=int(input("Enter time in seconds:")) minutes=int(num/60) seconds=int(num%60) print("After the Seconds are converted to Minutes, the result is:",minutes,"Minutes", seconds,"Seconds") elif ch==2...
true
156203c9c9a1c80101caf18ba558e1c89f682c42
JasmineOsti/pythonProject1
/Program.py
289
4.3125
4
#Write a program that takes three numbers and prints their sum. Every number is given on a separate line. A = int(input("Enter the first number: ")) B = int(input("Enter the second number: ")) C = int(input("Enter the third number: ")) sum = A+B+C print("the sum of three numbers is", sum)
true
df5270ff28213fc89bf0ee436b9855c73e026d9d
Sakshi011/Python_Basics
/set.py
1,190
4.21875
4
# set data type # unordered collection of data # INTRO ---------------------------------------------------------------------------------- s = {1,1.1,2.3,3,'string'} print(s) print("\n") # In set all elemets are unique that's why it is used to remove duplicate elements l = [1,2,4,2,3,6,3,7,6,6] s2 = list(set(l)) print(...
true
25401f5061ccabbded56366310f5e42e910eddd7
gourdcyberlab/pollen-testbed
/scapy-things/varint.py
1,438
4.375
4
#!/usr/bin/env python import itertools ''' Functions for converting between strings (formatted as varints) and integers. ''' class VarintError(ValueError): '''Invalid varint string.''' def __init__(self, message='', string=None): ValueError.__init__(self, message) self.string = string # Can'...
true
2c1699da529112c4820a06bdd0933ae4c6c11032
colinmcnicholl/automate_boring_tasks
/firstWordRegex.py
840
4.25
4
import re """How would you write a regex that matches a sentence where the first word is either Alice, Bob, or Carol; the second word is either eats, pets, or throws; the third word is apples, cats, or baseballs; and the sentence ends with a period? This regex should be case-insensitive.""" firstWordRegex = re...
true
901cfcc418c14cbdc3dc6b67440c0bcd22c42a35
bryano13/holbertonschool-interview
/0x09-utf8_validation/0-validate_utf8.py
1,186
4.15625
4
#!/usr/bin/python3 """ This software defines rules to check if an integer combination is a valid UTF-8 Encoding A valid UTF-8 character can be 1 - 4 bytes long. For a 1-byte character, the first bit is a 0, followed by its unicode. For an n-bytes character, the first n-bits are all ones, the n+1 bit is 0, followed by n...
true
ad34250006ebd1305657f4ba94cd7982895f6ddb
sofiarani02/Assigments
/Assignment-1.2.py
2,825
4.5
4
print("***Python code for List operation***\n") # declaring a list of integers myList = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] # List slicing operations # printing the complete list print('myList: ',myList) # printing first element print('first element: ',myList[0]) # printing fourth element print('f...
true
56cc4deeb8d82fe0a032ea4b0f84feff308315ab
baroquebloke/project_euler
/python/4.py
541
4.125
4
# A palindromic number reads the same both ways. The largest palindrome made # from the product of two 2-digit numbers is 9009 = 91 x 99. # Find the largest palindrome made from the product of two 3-digit numbers. # result: 906609 # time: 0.433s # # *edit: optimized* def palind_num(): is_pal = 0 for x in range...
true
054eaa44d1652eb87ed365839643ee4e76d4bbe7
codejoncode/Sorting
/project/iterative_sorting.py
2,418
4.5
4
# Complete the selection_sort() function below in class with your instructor def selection_sort(arr): # loop through n-1 elements for i in range(0, len(arr) - 1): cur_index = i smallest_index = cur_index # TO-DO: find next smallest element # (hint, can do in 3 loc) for j ...
true
1ced62858071d7ea1ee50ff2bf50760f9ff7b65c
ElenaMBaudrit/OOP_assignments
/Person.py
1,108
4.25
4
#Todd's March 21st 2018 #example of a class. class Person(object): #Always put "object" inside the parentheses of the class def __init__(self, name, age, location): #double underscores in Python: something that is written somewhere else. "Dunder"= double underscores. #constructor: name of the fu...
true
d07f8d3ae500f5aefc1e03accc48d230ce4b4edd
adibhatnagar/my-github
/NIE Python/Third Code/Further Lists.py
1,629
4.3125
4
list_1=['Apple','Dell','HP','LG','Samsung','Acer','MSI','Asus','Razer'] #declares list containing names of laptop makers as strings list_2=[1,2,3,3,3,4,5,5,6,7,8,8,8,8,9] #declares list containing integers #Remember list elements have index starting from 0 so for list_1 the element 'Apple' has index 0 #If you store an...
true
e5e227509210a211bbbd4c9c4a7e3fcc9dd23a96
gagande90/Data-Structures-Python
/Comprehensions/comprehension_list.py
562
4.25
4
# list with loop loop_numbers = [] # create an empty list for number in range(1, 101): # use for loop loop_numbers.append(number) # append 100 numbers to list print(loop_numbers) # list comprehension comp_numbers = [ number for number in range(1, 101) ] # create a new li...
true
bbd9d9f89619a93c37c79c269f244d899b047394
rebecabramos/Course_Exercises
/Week 6/search_and_replace_per_gone_in_list.py
1,123
4.375
4
# The program create a list containing the integers from (1 to 10) in increasing order, and outputs the list. # Then prompt the user to enter a number between 1 and 10, replace this number by the str object (gone) and output the list. # If the user enters a string that does not represent an integer between 1 and 10, ...
true
23aed0b18c33addf4ed34a8a25f206b826239b9c
rebecabramos/Course_Exercises
/Week 6/split_str_space-separated_and_convert_upper.py
308
4.46875
4
# The program performs space-separated string conversion in a list # and then cycles through each index of the list # and displays the result in capital and capital letters string = input('Enter some words >') list_string = string.split() print(list_string) for x in list_string: print(x, x.upper())
true
0f8cc167c0447ed209bb00b04ebdb2cb3053b2fb
hm06063/OSP_repo
/py_lab/aver_num.py
282
4.28125
4
#!/usr/bin/python3 if __name__ == '__main__': n = int(input("How many numbers do you wanna input?")) sum = 0 for i in range(0,n): num = int(input("number to input: ")) sum += num mean = sum/n print("the mean of numbers is {}".format(mean))
true
86b2340e9602b2aa3eab5c4fd4fd3dc1b9b9cf9a
zatserkl/learn
/python/numpy_matrix_solve.py
1,756
4.28125
4
################################################# # See the final solution in the numpy_matrix.py # ################################################# import numpy as np """ Solve equation A*x = b where b is represented by ndarray or matrix NB: use matmul for the multiplication of matrices (or arrays). """ def solv...
true
cf44c9820ab6c0e5c8ae0c270c5f097cd6c79550
zatserkl/learn
/python/class_set.py
1,286
4.15625
4
class Set: """Implementation of set using list """ def __init__(self, list_init=None): """constructor""" self.list = [] if list_init is not None: for element in list_init: self.list.append(element) """From http://stackoverflow.com/questions/1436703/differ...
true
62cbd1bb70a63056c31bf7eb173481b151060d0b
zatserkl/learn
/python/plot.py
849
4.1875
4
"""See Python and Matplotlib Essentials for Scientists and Engineers.pdf """ import matplotlib.pyplot as plt x = range(5) y = [xi**2 for xi in x] plt.figure() # fig = plt.figure() # create a figure pointed by fig # fig.number # get number of the figure pointed by fig # plt.gcf().number # get numb...
true
821e0a1793c5fb08e85102dfe2f73d3744f24589
zatserkl/learn
/python/generator_comprehension.py
481
4.3125
4
# modified example from https://wiki.python.org/moin/Generators nmax = 5 # Generator expression: like list comprehension doubles = (2*n for n in range(nmax)) # parenthesis () instead of brackets [] # print("list of doubles:", list(doubles)) while True: try: number = next(doubles) # raises StopIterat...
true
2e449b4aeae7d9409d28e6ff4ae686b58ab315b5
zatserkl/learn
/python/numpy_matrix.py
1,614
4.375
4
################################################################### # This is the final solution: use array for the matrix operations # ################################################################### """ See https://docs.scipy.org/doc/numpy-dev/user/numpy-for-matlab-users.html NumPy matrix operations: use arrays ...
true
b02955a662cd3093d93d4783334982e507492132
liyangwill/python_repository
/plot.py
1,395
4.15625
4
# Print the last item from year and pop print(year[-1]) print(pop[-1]) # Import matplotlib.pyplot as plt import matplotlib.pyplot as plt # Make a line plot: year on the x-axis, pop on the y-axis plt.plot(year,pop) plt.show() # Print the last item of gdp_cap and life_exp print(gdp_cap[-1]) print(life_exp[-1]) # Make...
true
f236b8b9866ac9eae15b53802cc2c01854c248f9
MainakRepositor/Advanced-Programming-Practice
/Week 3/Q.1.py
543
4.4375
4
'''1.Develop an Python code to display the following output using class and object (only one class and two objects)''' class Birdie: species = "bird" def __init__(self, name, age): self.name = name self.age = age blu = Birdie("Blu", 10) woo = Birdie("Woo", 15) print("Blu is a {}".format(b...
true
12b16dbd277eb214c3ccc2dc47d64dccfceb0d36
hari-bhandari/pythonAlgoExpert
/QuickAndBubbleSort.py
684
4.15625
4
def quickSort(array): length=len(array) if length<=1: return array else: pivot=array.pop() itemsGreater=[] itemsLower=[] for item in array: if(item>pivot): itemsGreater.append(item) else: itemsLower.append(item) return quickSort(items...
true
357fbd822fa1d9e68afd1b880fc4c2f76988b384
jjen6894/PythonIntroduction
/Challenge/IfChallenge.py
593
4.21875
4
# Write a small program to ask for a name and an age. # When both values have been entered, check if the person # is the right age to gon on an 18-30 holiday must be over 18 # under 31 # if they are welcome them to the holiday otherwise print a polite message # refusing them entry name = input("What's your name? ") ag...
true
49a053c483508ebe7a6bed95bafbe294b56239c1
gabmwendwa/PythonLearning
/3. Conditions/2-while.py
396
4.34375
4
# With the while loop we can execute a set of statements as long as a condition is true. i = 1 while i <= 10: print(i) i += 1 print("---------") # Break while loop i = 1 while i <= 10: print(i) if i == 5: break i += 1 print("---------") # With the continue statement we can stop the current iteration, and continu...
true
b5ab9138384b9079b73d6a64e922a307d500fe42
gabmwendwa/PythonLearning
/4. Functions/1-functions.py
2,308
4.71875
5
# In Python a function is defined using the def keyword: def myfunction(): print("Hello from function") # Call function myfunction() print("-------") # Information can be passed to functions as parameter. def namefunc(fname): print(fname + " Mutisya") namefunc("Mutua") namefunc("Kalui") namefunc("Mwendwa") print("-...
true
71b8b67c39bb8c55568ba0c8dcdbb0e3565c1972
gabmwendwa/PythonLearning
/2. Collections/4-dictionary.py
2,577
4.34375
4
# Dictionary is a collection which is unordered, changeable and indexed. No duplicate members. # A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values. mdic = { "brand" : "Ford", "model" : "Mustang", "year" : 19...
true
252d6fb9fb6b77cfd70c38325fedc0b50e1d530d
alantanlc/what-is-torch-nn-really
/functions-as-objects-in-python.py
1,897
4.71875
5
# Functions can be passed as arguments # We define an 'apply' function which will take as input a list, _L_ and a function, _f_ and apply the function to each element of the list. def apply(L, f): """ Applies function given by f to each element in L Parameters ---------- L : list containing the op...
true
78c1296a009f6ff19884a46f48e67f6795e312f4
mariarozanska/python_exercises
/zad9.py
768
4.34375
4
'''Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. Extras: Keep the game going until the user types “exit” Keep track of how many guesses the user has taken, and when the game ends, print this ou...
true
4b610d707b407ef845cc19fde9da3eefc6115065
BlakeBeyond/python-onsite
/week_02/08_dictionaries/09_03_count_cases.py
1,065
4.5
4
''' Write a script that takes a sentence from the user and returns: - the number of lower case letters - the number of uppercase letters - the number of punctuations characters (count) - the total number of characters (len) Use a dictionary to store the count of each of the above. Note: ignore all spaces. Example in...
true
d7af1592985a4677bc8929c35905f045b25ca842
BlakeBeyond/python-onsite
/week_02/06_tuples/02_word_frequencies.py
628
4.40625
4
''' Write a function called most_frequent that takes a string and prints the letters in decreasing order of frequency. For example, the follow string should produce the following result. string_ = 'hello' Output: l, h, e, o For letters that are the same frequency, the order does not matter. ''' my_dict = {} sorted...
true
e8f1c5cd3e440886e0fa8f594d1092fb58fb509a
cp105/dynamic_programming_101
/dp101/knapsack01.py
1,896
4.4375
4
""" The knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. It derives its name from t...
true
e441e0e4fa599fefe6f3f49f32477c68dd46e29a
jtannas/intermediate_python
/caching.py
1,368
4.65625
5
""" 24. Function caching Function caching allows us to cache the return values of a function depending on the arguments. It can save time when an I/O bound function is periodically called with the same arguments. Before Python 3.2 we had to write a custom implementation. In Python 3.2+ there is an lru_cache decorator w...
true
ebd261d238b7e9fe9a2167c9333de3046439771b
jtannas/intermediate_python
/ternary.py
574
4.25
4
""" 6. Ternary Operators Ternary operators are more commonly known as conditional expressions in Python. These operators evaluate something based on a condition being true or not. They became a part of Python in version 2.4 """ # Modern Python Way. def positive_test(num): return 'positive' if num > 0 else 'not po...
true
9b381446f85c86c9b92fb0749fe97301418828ff
Anjustdoit/Python-Basics-for-Data-Science
/string_try1.py
546
4.25
4
name = "hello" print(type(name)) message = 'john said to me "I\'ll see you later"' print(message) paragraph = ''' Hi , I'm writing a book. I will certainly do''' print(paragraph) hello = "Hello World!" print(hello) name = input('What is your name ? --> ') print(name) # What is your age ...
true
d50626ac217a242938030eb2621bc6263893c191
martinak1/diceman
/diceman/roll.py
2,993
4.25
4
import random def roll( num: int = 1, sides: int = 6) -> list: ''' Produces a list of results from rolling a dice a number of times Paramaters ---------- num: int The number of times the dice will be rolled (Default is 1) sides: int The number of sides the dice has (Default is ...
true
36028b8aae863b3c6de5d5e1e76f32c6037c7d7f
Cakarena/CS-2
/numprint.py
235
4.15625
4
##Write a Python program that prints all the numbers from 0 to 6 except 3 and 6. ## Note : Use 'continue' statement. Name the code. Expected Output : 0 1 2 4 5 for i in range(0,7): if i==3 or i==6: continue print(i,end='')
true
097b292ea5a0d040181ec80c9beb3965f1cacb93
JohnKlaus-254/python
/Python basics/String Operations.py
1,105
4.28125
4
#CONCACTINATION using a plus #CONCACTINATION using a format first_name= "John" last_name = "Klaus" full_name = first_name +' '+ last_name print(full_name) #a better way to do this is; full_name = "{} {}".format(first_name, last_name) print(full_name) print("this man is called {} from the family of {} ".for...
true
7dd6519daded48e31f9c24276fee8f1c51a19623
GuptaNaman1998/DeepThought
/Python-Tasks/Rock-Paper-Scissors/Code.py
999
4.21875
4
""" 0-Rock 1-Paper 2-Scissor """ import random import os def cls(): os.system('cls' if os.name=='nt' else 'clear') Options={0:"Rock",1:"Paper",2:"Scissor"} # Created Dictionary of available choices poss={(0, 1):1,(0, 2):0,(1, 2):2} # Dictionary of possibilities and the winner value # print("Hi User!") player...
true
ce4fe060c3a35b03a49650e8aa385dc68d42715d
alexhohorst/MyExercises
/ex3.py
844
4.28125
4
print "I will now count my chickens:" print "Hens", 25 + 30 / 6 #adds 25 and 30 and divides this by 6 print "Roosters", 100 - 25 * 3 % 4 #substracts 25 from 100, multiplies with 3 and divides by 4, returning the remainder print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 #adds 3 and 2 and 1,...
true
f494f59caa548f497bd1d3825fd5448ac3cff339
MReeds/Classes-Practices
/pizzaPractice/classes.py
1,021
4.4375
4
#Add a method for interacting with a pizza's toppings, # called add_topping. #Add a method for outputting a description of the #pizza (sample output below). #Make two different instances of a pizza. #If you have properly defined the class, #you should be able to do something like the #following code with your Pizza ...
true
bf49ad63a8611cdbcfc34e384f940d47e9eed772
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 11- String Contents.py
1,202
4.28125
4
# The String Contents Problem- Lab 11: CIS 1033 # Seth Miller and Kaitlin Coker # Explains purpose of program to user print("Hello! This program takes a string that you enter in and tells you what the string contains.") # Ask user for string userString = input("Please enter a string ---> ") # Tests if it co...
true
74a25f4969bc732424c26c88dc80441e2f4f499d
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 17- Training Heart Rate.py
1,034
4.21875
4
# The Training Heart Rate Problem # Lab 17: CIS 1033 # Author: Seth Miller # function that calculates training heart rate # based on age and resting heart rate def trainingHeartRate( age, restingHeartRate ) : maxHeartRate = 220 - age result = maxHeartRate - restingHeartRate result2 = result * 0.60...
true
bd4bf3185496a137ef716b6188082d27b9f084e8
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 9- Electric Bill.py
1,048
4.25
4
# The Electric Bill Problem- Lab 9 CIS 1033 # Author: Seth Miller # Input: receives the meter reading for the previous # and current month from the user prevMonthMeterReading = int(input("Meter reading for previous month: ")) currentMonthMeterReading = int(input("Meter reading for current month: ")) # Input: ...
true
c3050341b766f637b39ba112c5967a9b43d74dfe
MortalKommit/Coffee-Machine
/coffee_machine.py
2,630
4.1875
4
class CoffeeMachine: def __init__(self, capacity, menu): self.capacity = {} contents = ("water", "milk", "coffee beans", "disposable cups", "money") for content, cap in zip(contents, capacity): self.capacity[content] = cap self.menu = menu def get_user_input(self): ...
true
1702acae637148eee91612d432b6e8fa4d594205
toddljones/advent_of_code
/2019/1/a.py
1,013
4.4375
4
""" Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. For example: - For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2. - For a mass of 14, dividing by 3 and rou...
true
694ac91eec52f84fdac4581f1cd3be42554925d4
CertifiedErickBaps/Python36
/Listas/Practica 7/positives.py
1,028
4.125
4
# Authors: # A013979896 Erick Bautista Perez # #Write a program called positives.py. Define in this program a function called #positives(x) that takes a list of numbers x as its argument, and returns a new #list that only contains the positive numbers of x. # # October 28, 2016. def positives(x): a = ...
true
df7911328fd4b62321d98a88f8399978c053c5d0
CertifiedErickBaps/Python36
/Manipulacion de textos/Practica 6/username.py
2,277
4.3125
4
# Authors: # A01379896 Erick Bautista Pérez #Write a program called username.py. Define in this program a function called username(first, middle, last) #that takes the first name, middle name, and last name of a person and generates her user name given the above #rules. You may assume that every first name...
true
5af607504652e3240c32ecfb8a764987e5e58786
Exclusive1410/practise3
/pr3-4.py
231
4.34375
4
#Write Python program to find and print factorial of a number import math def fact(n): return (math.factorial(n)) num = int(input('Enter the number:')) factorial = fact(num) print('Factorial of', num, 'is', factorial)
true
f14a298f9b623616b2e81fe80aa2d1860e707bf4
StephenJonker/python-sample-code
/sort-list/sort-list-of-integer-list-pairs.py
1,780
4.25
4
# uses python3 # # Written by: Stephen Jonker # Written on: Tuesday 19 Sept 2017 # Copyright (c) 2017 Stephen Jonker - www.stephenjonker.com # # Purpose: # - basic python program to show sorting a list of number pairs # # - Given a list of integer number pairs that will come from STDIN # - first read in n, the number o...
true
e6b38846ceed488f1334a77279b1220c31a4d21d
jeansabety/learning_python
/frame.py
608
4.25
4
#!/usr/bin/env python3 # Write a program that prints out the position, frame, and letter of the DNA # Try coding this with a single loop # Try coding this with nested loops dna = 'ATGGCCTTT' for i in range(len(dna)) : print(i, i%3 , dna[i]) #i%3 -> divide i (which is a number!) by i, and print the remainder for ...
true
632a36b7c686db27cfee436935eecfc9ba74be30
jeansabety/learning_python
/xcoverage.py
1,902
4.15625
4
#!/usr/bin/env python3 # Write a program that simulates random read coverage over a chromosome # Report min, max, and average coverage # Make variables for genome size, read number, read length # Input values from the command line # Note that you will not sample the ends of a chromosome very well # So don't count the ...
true
7efe190f957eec5b5c7a62adb1e45b520066f33f
bensenberner/ctci
/peaksAndValleys.py
638
4.40625
4
''' in an array of ints, a peak is an element which is greater than or equal to the adjacent integers. the opposite for a valley. Given an array of ints, sort it into an alternating sequence of peaks and valleys. ''' def peakSort(arr): for i in range(1, len(arr), 2): # make sure indices don't go out of bou...
true
1a5541ac2b3af545ec206ad68986eaf8d6232512
dheerajps/pythonPractice
/algorithms/unsortedArrayHighestProduct.py
1,344
4.21875
4
# same as highestProduct.py # but find the maximum product possible by three numbers in an array without sorting it #so O(N) must be time requirements def getMaxProductOfThreeNumbers(array): import sys #Max product can be 3 maximum numbers or 2 minimum numbers and 1 max firstMax = -sys.maxsize-1 secondMa...
true
32e8588930e8821ae35ef762dc37c3fa5368fd97
lyndsiWilliams/cs-module-project-algorithms
/sliding_window_max/sliding_window_max.py
1,063
4.5
4
''' Input: a List of integers as well as an integer `k` representing the size of the sliding window Returns: a List of integers ''' def sliding_window_max(nums, k): # Your code here # Check if numbers array exists if nums: # Set an empty list for the max numbers to live max_numbers = [] ...
true
a2b4f9b45b1888a518e7db8a687c3bf452aca122
manu4xever/leet-code-solved
/reverse_single_linked_list.py
506
4.1875
4
Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def reverseList(self, head): ...
true
0d4b6e26e09ea7d90e4d45941f07a4d9046ba1b4
Hety06/caesar_cipher
/caesar_cipher.py
878
4.1875
4
def shift(letter, shift_amount): unicode_value = ord(letter) + shift_amount if unicode_value > 126: new_letter = chr(unicode_value - 95) else: new_letter = chr(unicode_value) return new_letter def encrypt(message, shift_amount): result = "" for letter in message:...
true
1eb92fd964d785db16d04628b9734810a5460374
anterra/area-calculator
/area_calculator.py
1,016
4.15625
4
import math class Rectangle: def __init__(self, length1, length2): self.length1 = length1 self.length2 = length2 def area(self): area = self.length1 * self.length2 return area class Circle: def __init__(self, radius): self.radius = radius def area(self): ...
true
f8cb2d4ff4976169893c680ba37018de7e936e34
dileep208/dileepltecommerce
/test/one.py
341
4.25
4
# This is for printing print('This is a test') # This is for finding the length of a string s = 'Amazing' print(len(s)) # This for finding the length of hippopotomus s='hippopotomous' print(len(s)) # This is for finding the length of string print('Practice makes man perfect') # finding the length of your name s = 'dil...
true
a7a5cbedf25dc380bfcf6c152cfa4848d32f0c55
vinaykumar7686/Algorithms
/Data Structures/Binary-Tree/Binary Search Tree/[BST] Validate Binary Search Tree.py
2,161
4.375
4
# Validate Binary Search Tree ''' Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node...
true
867ffc604bc02ee32ef1798070530ef9861ef0a1
vinaykumar7686/Algorithms
/Algorithms/Dynamic_Programming/Nth_Fibonacci_No/fibonacci _basic _sol.py
1,022
4.40625
4
def fibo_i(n): ''' Accepts integer type value as argument and returns respective number in fibonacci series. Uses traditional iterative technique Arguments: n is an integer type number whose respective fibonacci nyumber is to be found. Returns: nth number in fiboacci series ''' # Sim...
true
f04e1c9e1d991242d1dcce33de00c651125572a7
ziolkowskid06/Python_Crash_Course
/ch10 - Files and Exceptions/10-03. Guest.py
222
4.4375
4
""" Write a program that prompts the user for their name. """ name = input("What's your name? ") filename = 'guest.txt' # Save the variable into the .txt file with open(filename, 'w') as f: f.write(name)
true
daddc2badb17111c59d9406fdeb09dd7871b620e
ziolkowskid06/Python_Crash_Course
/ch05 - IF Statements/5-02. More Conditional Tests.py
673
4.125
4
""" Write more conditional tests. """ # Equality and iequality with strings. motorcycle = 'Ducati' print("Is motorcycle != 'Ducati'? I predict False.") print(motorcycle == 'ducati') print("\nIs motorycle == 'Ducati'? I predict True.") print(motorcycle == 'Ducati') # Test using lower() method. pc = 'DELL' p...
true
58ca8613f51031792f48d896a3f5c3d6a4cfc565
ziolkowskid06/Python_Crash_Course
/ch05 - IF Statements/5-08. Hello Admin.py
473
4.4375
4
""" Make a list of five or more usernames, including the name'admin'. Imagine you are writing code that will print a greeting to each user after they log in to a website and the question for admin. """ names = ['anna', 'elizabeth', 'julia', 'kim', 'admin', 'rachel'] for name in names: if name == 'admin': ...
true
d90c7e345eb4fe782187b003523f9caa1909447c
ziolkowskid06/Python_Crash_Course
/ch07 - User Input and WHILE Loops/7-10. Dream Vacation.py
494
4.15625
4
""" Write a program that polls users about their dream vacation. """ poll = {} while True: name = input("What's your name? ") vacation = input("If you could visit one place in the world, " "where would you go? ") poll[name] = vacation quit = input("Stop asking? (yes/no) "...
true
b9014e87d1d5167c8cdcd0f0837609b7d61e240e
ziolkowskid06/Python_Crash_Course
/ch03 - Introducing Lists/3-09. Dinner Guests.py
319
4.21875
4
""" Working with one of the programs from Exercises 3-4 through 3-7 (page 42), use len() to print a message indicating the number of people you are inviting to dinner. """ # Print a number of elements guest_list = ['mary jane', 'elizabeth hurtley', 'salma hayek'] print(f" There are {len(guest_list)} people invi...
true
30176a4c40a0682963e4d0d9de8d27004b191ff1
ziolkowskid06/Python_Crash_Course
/ch07 - User Input and WHILE Loops/7-02. Restaurant Seating.py
277
4.21875
4
""" Write a program that asks the user how many people are in their dinner group. """ seating = input('How many people are in your dinner group?\n') seating = int(seating) if seating > 8: print("You need to wait for a table.") else: print("Table is ready!")
true
c41f4dcd82e4b041185764f8646f5de6dc5b1ab6
Alex-Angelico/math-series
/math_series/series.py
1,337
4.3125
4
def fibonacci(num): """ Arguments: num - user-selected sequence value from the Fibonacci sequence to be calculated by the funciton Returns: Calculated value from the sequence """ if num <= 0: print('Value too small.') elif num == 1: return 0 elif num == 2: return 1 else: return fi...
true
cddc10f2fb3571e8d55ac0bc8393f5fe1aabd2cb
Priyojeet/man_at_work
/python_100/string_manipulation1.py
322
4.34375
4
# Write a Python program to remove the nth index character from a nonempty string. def remove_char(str, n): slice1 = str[:n] slice2 = str[n + 1:] #print(slice1) #print(slice2) return slice1 + slice2 l = str(input("enter a string:-")) no = int(input("enter a number:-")) print(remove_char(l, no)...
true
97a822a515d3434b42b402aebbcb5513b01334f4
Priyojeet/man_at_work
/python_100/decision_making_nested_if_else.py
562
4.125
4
# check prime number with nested loop number = eval(input("enter the number you want:-")) if(isinstance(number,str)): print(" please enter an integer value") elif(type(number) == float): print("you enter a float number") else: if (number <= 0): print("enter an integer grater then 0") elif (numb...
true
0862a345a5b5422d0e062f977015a95ef4ad3f3b
dipsuji/coding_pyhton
/coding/flatten_tree.py
1,266
4.1875
4
class Node: """ create node with lest and right attribute """ def __init__(self, key): self.left = None self.right = None self.val = key def print_pre_order(root): """ this is pre order traversal """ if root: # First print the data of root print...
true
44e6ef8dd8212448ed8684262c52fcc71da35d4e
dipsuji/coding_pyhton
/udemy_leetcode/Hash Map Facebook Interview Questions solutions/majority_element.py
846
4.1875
4
""" - https://leetcode.com/problems/majority-element/ Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1: Input: nums = [3,2,3] Output: 3 Exa...
true
0045f7f9c3c0e13656f0b5f5c815f7cb17ac13bc
dipsuji/coding_pyhton
/udemy_leetcode/Microsoft Interview Questions solutions/missing_number.py
1,121
4.15625
4
from typing import List """ Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the mi...
true
77e3b9062540fd72f2a1deb8f3ccf652d982ad0d
lehmanwics/programming-interview-questions
/src/general/Python/4_fibonachi_numbers.py
1,402
4.28125
4
""" 4. Write fibonacci iteratively and recursively (bonus: use dynamic programming) """ # Fibonachi recursively (function calls itself) def fib(nth_number): if nth_number == 0: return 0 elif nth_number == 1: return 1 else: return fib(nth_number-1) + fib(nth_number - 2) ...
true
935726112481fa8173f8e4bc7a817225d123d126
sarma5233/pythonpract
/python/operators.py
2,108
4.40625
4
a = 10 b = 8 print("ARITHMETIC operators") print('1.Addition') print(a+b) print() print('2.subtraction') print(a-b) print('3.Multiplication') print(a*b) print('4.Division') print(a/b) print('5.Modulus') print(a%b) print('6.Exponentiation') print(a**b) print('7.floor Division') print(a//b) print("Comparision Operators"...
true
8fb2558f6f9bed68720ee257727e9be5840cbe0d
sarma5233/pythonpract
/flow_controls/while.py
210
4.15625
4
n = int(input("enter a number:")) sum = 0 total_numbers = 1 while total_numbers <= n: sum += total_numbers total_numbers += 1 print("sum =", sum) average = sum/n print("Average = ", average)
true
c8ff41d4b83e1b1285f1acde17504d2236b453c6
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/04-regular_expression_in_python/e32_flying_home.py
1,297
4.15625
4
""" Flying home The variable flight containing one email subject was loaded in your session. You can use print() to view it in the IPython Shell. Import the re module. Complete the regular expression to match and capture all the flight information required. Only the first parenthesis were placed for you. Find all the m...
true
fa7afe7b83e2d11110183c186ed9019e7043d306
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/05-Working_with_Dates_and_Times/e22_how_many_hours_elapsed_around_daylight_saving.py
1,348
4.5625
5
""" How many hours elapsed around daylight saving? Let's look at March 12, 2017, in the Eastern United States, when Daylight Saving kicked in at 2 AM. If you create a datetime for midnight that night, and add 6 hours to it, how much time will have elapsed? You already have a datetime called start, set for March 12, 20...
true
afb5a251bfa0ba326669aa7ae14f0004c54d914e
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/12-Introduction_to_Deep_Learning_in_Python/e1_coding_the_forward_propagation_algorithm.py
1,574
4.375
4
""" Coding the forward propagation algorithm The input data has been pre-loaded as input_data, and the weights are available in a dictionary called weights. The array of weights for the first node in the hidden layer are in weights['node_0'], and the array of weights for the second node in the hidden layer are in weigh...
true
a5437c79e37d03fd36f379c41ee2f84ea191bb79
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/02-python-data-science-toolbox-part-2/e33_writing_an_iterator_to_load_data_in_chunks3.py
1,534
4.15625
4
""" Writing an iterator to load data in chunks (3) The packages pandas and matplotlib.pyplot have been imported as pd and plt respectively for your use. Instructions 100 XP Write a list comprehension to generate a list of values from pops_list for the new column 'Total Urban Population'. The output expression ...
true
c1a72827d922ed8468dd66d50a7c0d2d4c897ce8
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/02-python-data-science-toolbox-part-2/e18_list_comprehensions_vs_generators.py
1,679
4.5
4
""" List comprehensions vs generators generators does not store data in memnory like list if there a very large list then use generators. There is no point in using large list instead use generators In this exercise, you will recall the difference between list comprehensions and generators. To help with that task, t...
true
7278153d5148595cd0bc4cfb92ccef72cd4706c7
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/10-Supervised_Learning_with_scikit-learn/e28_centering_and_scaling_your_data.py
1,912
4.28125
4
""" Centering and scaling your data You will now explore scaling for yourself on a new dataset - White Wine Quality! Hugo used the Red Wine Quality dataset in the video. We have used the 'quality' feature of the wine to create a binary target variable: If 'quality' is less than 5, the target variable is 1, and otherwi...
true
246c365f2c3f7f10c249933ead07532244770291
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/03-cleaning_data_in_python/e36_pairs_of_restaurants.py
1,325
4.125
4
""" in this exercise, you will perform the first step in record linkage and generate possible pairs of rows between restaurants and restaurants_new. Both DataFrames, pandas and recordlinkage are in your environment. Instructions Instantiate an indexing object by using the Index() function from recordlinkage. ...
true
5b718cdb7f238284afaa3e3a5080213062c4bf15
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/04-regular_expression_in_python/e3_palindromes.py
782
4.28125
4
""" The text of a movie review for one example has been already saved in the variable movie. You can use print(movie) to view the variable in the IPython Shell. Instructions 100 XP Extract the substring from the 12th to the 30th character from the variable movie which corresponds to the movie title. Store it ...
true
d4cf7f2383afe7107d2218d684df69e3f9e4c9e8
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/05-Working_with_Dates_and_Times/e16_the_long_and_the_short_of_why_time_is_hard.py
1,779
4.46875
4
""" The long and the short of why time is hard As before, data has been loaded as onebike_durations. Calculate shortest_trip from onebike_durations. Calculate longest_trip from onebike_durations. Print the results, turning shortest_trip and longest_trip into strings so they can print. """ from datetime im...
true
9aa4a68742400f5dff59647d53bfb1e0e7d91a14
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e32_making_predictions.py
1,169
4.21875
4
""" Making predictions At this point, we have a model that predicts income using age, education, and sex. Let's see what it predicts for different levels of education, holding age constant. Using np.linspace(), add a variable named 'educ' to df with a range of values from 0 to 20. Add a variable named 'age' ...
true
7e486404b32bb6b34085ee5fc263fbb2437cd3b6
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/09-Statistical_Thinking_in_Python_Part2/e7_linear_regression_on_appropriate_anscombe_data.py
1,403
4.125
4
""" Linear regression on appropriate Anscombe data Compute the parameters for the slope and intercept using np.polyfit(). The Anscombe data are stored in the arrays x and y. Print the slope a and intercept b. Generate theoretical and data from the linear regression. Your array, which you can create with np.array(), sh...
true
dab0d9344df34e3f0730c2b87683c050d701e011
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/04-regular_expression_in_python/e2_artificial_reviews.py
1,271
4.15625
4
""" The text of two movie reviews has been already saved in the variables movie1 and movie2. You can use the print() function to view the variables in the IPython Shell. Remember: The 1st character of a string has index 0. Instructions Select the first 32 characters of the variable movie1 and assign it to the variabl...
true
b6eb4dde3b6ef947df4922a52e971102397f01e9
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e7_compute_birth_weight.py
818
4.3125
4
""" Compute birth weight Make a Boolean Series called full_term that is true for babies with 'prglngth' greater than or equal to 37 weeks. Use full_term and birth_weight to select birth weight in pounds for full-term babies. Store the result in full_term_weight. Compute the mean weight of full-term bab...
true
fef3d8a8eb810bfeebd65a7951b14f2f55c514c8
DiniH1/python_concatenation_task
/python_concactination_task.py
507
4.21875
4
# Task 1 name = "" name = input("What is your name? ") name_capitalize = name.capitalize() print(name_capitalize + " Welcome to this task!") # Task 2 full_name = "" full_name = input('What is your full name? ') first_name = (full_name.split()[0]) first_name_capitalize = first_name.capitalize() last_name = (full_name.s...
true
2ae3f62714952207aaf401db24a148f92a9871d1
AtxTom/Election_Analysis
/PyPoll.py
1,017
4.125
4
# The data we need to retrieve. # 1. The total number of votes cast # 2. A complete list of candidates who received votes # 3. The percentage of votes each candidate won # 4. The total number of votes each candidate won # 5. The winner of the election based on popular vote. # Add our dependencies. import csv import o...
true
fceebe8dfa503b1bfe1925f59e1a06c7f14a3851
lengfc09/Financial_Models
/NLP/Codes/code-sklearn-k-means-clustering.py
792
4.3125
4
# This script illustrates how to use k-means clustering in # SciKit-Learn. from sklearn.cluster import KMeans import numpy as np # We create a numpy array with some data. Each row corresponds to an # observation. X = \ np.array( [[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], ...
true
302334f9a7cd8ac3ae4ff61777bc7926899baca4
sanraj99/practice_python
/prime_number.py
509
4.15625
4
# A Prime number can only divided by 1 and itself def is_prime(num): for i in range(2, num): if (num % i) == 0: return False return True def getPrimes(max_number): list_of_primes = [] for num1 in range(2, max_number): if is_prime(num1): list_of_primes.app...
true
4f97b96ca9683d7dea5defd2201e10d4408b169b
sourav-gomes/Python
/Part - I/Chapter 3 - Strings/03_string_functions.py
854
4.28125
4
story = "once upon a time there was a boy named Joseph who was good but very lazy fellow and never completed any job" # String Functions # print(len(story)) # gives length of the string # print(story.endswith("job")) # returns True or false. In this case True. # print(story.count("a")) # returns how many ...
true
b79a137c9f02c076e43d751bbaec2b0ede6f6603
sourav-gomes/Python
/Part - I/Chapter 5 - Dictionary & Sets/03_Sets_in_python_and methods.py
1,726
4.375
4
''' a = (1, 2, 3) # () means --> tuple print(type(a)) # prints type --> <class 'tuple'> a = [1, 2, 3] # [] means --> list print(type(a)) # prints type --> <class 'list'> a = {1, 2, 3} # {x, y,....} means --> set print(type(a)) # prints type --> <class 'set'> a = {1:3} # {x:...
true
22f684c1ea3a1f78b58f9b8db35238d5041091ce
suneeshms96/python-password-validator
/python-password-validator.py
795
4.28125
4
digit_count = 0 alpha_count = 0 char_count = 0 lower_count = 0 #we can change password strength requirement here..! required_digit_count = 5 required_alpha_count = 2 required_char_count = 4 required_lower_count = 2 uname = input('Enter your username: ') word = input('Enter a password : ') for w in str(word): if ...
true
321abe804a7ce7b47ee132886559168e3b52d640
wojlas/Guess-the-number
/guess_the_number.py
909
4.1875
4
import random def guess_the_number(): try: """function checks if the given number is equal to the drawn number and displays an appropriate message""" user_number = int(input("Guess the number: ")) index = 0 while user_number != random_number: if user_number < ra...
true
29ab376394ff53ed3542e6f22877b23d5d115e72
dchtexas1/pythonFiles
/division.py
233
4.4375
4
"""Gives quotient and remainder of two numbers.""" a = input("Enter the first number: ") b = input("Enter the second number: ") print("The quotient of {} divided by {} is {} with a remainder of {}.".format( a, b, a / b, a % b))
true