blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ad929f0d120653cf303cf7d59018eccdedae04c6
KULDEEPMALIKM41/Practices
/Python/Python Basics/114.multiple.py
2,399
4.3125
4
# 4. multiple inheritance => # (base for C)CLASS A CLASS B(base for C) # | | # | | # ______________________________________ # | # | # CLASS C(derived for A and B) # Drawback of other technology => # 1.if base class wi...
true
534146d46f8c71c9edec393105942add3bc01f5a
KULDEEPMALIKM41/Practices
/Python/Single Py Programms/statistics_module.py
1,459
4.15625
4
from statistics import * a = [1,10,3.5,4,6,7.3,4] b = [2,2,3,8,9] print("mean(a) - ",mean(a)) # The mean() method calculates the arithmetic mean of the numbers in a list. print("mean(b) - ",mean(b)) print("median(a) - ",median(a)) # The median() method returns the middle value of numeric data in a list. print("medi...
true
0702ece64a2e2eaffc7fa970ddf974ec2f244dbf
minhnhoang/hoangngocminh-fundamental-c4e23
/session3/password_validation.py
424
4.28125
4
pw = input("Enter password: ") while True: if len(pw) <= 8: print("Password length must be greater than 8") elif pw.isalpha(): print("Password must contain number") elif pw.isupper() or pw.islower(): print("Password must contain both lower and upper case") elif pw.isdigit(): ...
true
c298d41657f00d72a8718da8741c9d0cf24acc3a
oreolu17/python-proFiles
/list game.py
1,284
4.1875
4
flag = True list = [ 10,20,30,40,50] def menu(): print("Enter 1: to insert \n Enter 2: to remove \n Enter 3: to sort \n Enter 4: to extend \n Enter 5 to reverse \n Enter 6: to transverse") def insertlist(item): list.append(item) def remove(item): list.remove(item) def sort(item): list.sort() def extend...
true
cf0ffad1f8470707cf05177287c5a085b8db0098
shubham3207/pythonlab
/main.py
284
4.34375
4
#write a program that takes three numbers and print their sum. every number is given on a separate line num1=int(input("enter the first num")) num2=int(input("enter the second num")) num3=int(input("enter the third num")) sum=num1+num2+num3 print("the sum of given number is",sum)
true
d3a882a461e6f5b853ea7202592418618539c5e1
llmaze3/RollDice.py
/RollDice.py
679
4.375
4
import random import time #Bool variable roll_again = "yes" #roll dice until user doesn't want to play while roll_again == "yes" or roll_again == "y" or roll_again == "Yes" or roll_again == "Y" or roll_again == "YES": print("\nRolling the dice...") #pause the code so that it feels like dice is being rolled #sleep ...
true
246d6138de3857dd8bf9a4488ebcce3d9f1c7144
StevenLOL/kaggleScape
/data/script87.py
1,355
4.34375
4
# coding: utf-8 # Read in our data, pick a variable and plot a histogram of it. # In[4]: # Import our libraries import matplotlib.pyplot as plt import pandas as pd # read in our data nutrition = pd.read_csv("../input/starbucks_drinkMenu_expanded.csv") # look at only the numeric columns nutrition.describe() # Thi...
true
2c8305b951b42695790cc95fef57b5f3751db447
GowthamSiddarth/PythonPractice
/CapitalizeSentence.py
305
4.1875
4
''' Write a program that accepts line as input and prints the lines after making all words in the sentence capitalized. ''' def capitalizeSentence(sentence): return ' '.join([word.capitalize() for word in sentence.split()]) sentence = input().strip() res = capitalizeSentence(sentence) print(res)
true
b78fea29f88fee4293581bbbfae5da0fa60065b9
GowthamSiddarth/PythonPractice
/RobotDist.py
1,030
4.4375
4
''' A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following: UP 5 DOWN 3 LEFT 3 RIGHT 2 The numbers after the direction are steps. Please write a program to compute the distance from cur...
true
c1a94cfefd636be989ea3c0df1a2f40ecefd6390
GowthamSiddarth/PythonPractice
/PasswordValidity.py
1,368
4.3125
4
''' A website requires the users to input username and password to register. Write a program to check the validity of password input by users. Following are the criteria for checking the password: 1. At least 1 letter between [a-z] 2. At least 1 number between [0-9] 1. At least 1 letter between [A-Z] 3. At least 1 char...
true
2b78532e935cc48136266b96a4a8d5070d14852b
GowthamSiddarth/PythonPractice
/EvenValuesFromTuple.py
268
4.1875
4
''' Write a program to generate and print another tuple whose values are even numbers ''' def getEvenNumsFromTuple(nums): return tuple(x for x in nums if x % 2 == 0) nums = list(map(int, input().strip().split(','))) res = getEvenNumsFromTuple(nums) print(res)
true
615e85b944a61c73a1e1e0a2c99738750ebd112a
CHANDUVALI/Python_Assingment
/python27.py
274
4.21875
4
#Implement a progam to convert the input string to lower case ( without using standard library) Str1=input("Enter the string to be converted uppercase: ") for i in range (0,len(Str1)): x=ord(Str1[i]) if x>=65 and x<=90: x=x+32 y=chr(x) print(y,end="")
true
6c299c77b83d1f18798aacebb941d947de7236d4
monajalal/Python_Playground
/binary_addition.py
510
4.1875
4
''' Implement a function that successfully adds two numbers together and returns their solution in binary. The conversion can be done before, or after the addition of the two. The binary number returned should be a string! Test.assert_equals(add_binary(51,12),"111111") ''' #the art of thinking simpler is POWER def ad...
true
cce21967d8f50cdc3ac1312886f909db26cae7cf
bjgrant/python-crash-course
/voting.py
1,033
4.3125
4
# if statement example age = 17 if age >= 18: print("You are old enough to vote!") print("Have you registered to vote yet?") # else stament example else: print("Sorry, you are too young to vote!") print("Please register to vote as soon as you turn 18!") # if-elif-else example age = 12 if age < 4: ...
true
0efc11ea4177989652d50c18eaeca9cf25988c18
bjgrant/python-crash-course
/cars.py
594
4.53125
5
# list of car makers cars = ["bmw", "audi", "toyota", "subaru"] # sorts the list alphabetically cars.sort() print(cars) # sorts the list in reverse alphabetic order cars = ["bmw", "audi", "toyota", "subaru"] cars.sort(reverse=True) print(cars) cars = ["bmw", "audi", "toyota", "subaru"] # Print the list contents sorted,...
true
5bfeeb9948c267f0d0a4029800ef0cd8157a3689
Japoncio3k/Hacktoberfest2021-5
/Python/sumOfDigits.py
225
4.1875
4
num = int(input("Enter a number: ")); if(num<0): print('The number must be positive') else: total = 0; while num!=0: total += num%10; num = num//10; print("The sum of the digits is: ", total);
true
1d52ec1e83e2f428223741dde50588025375dd26
derekhua/Advent-of-Code
/Day10/Solution.py
1,859
4.125
4
''' --- Day 10: Elves Look, Elves Say --- Today, the Elves are playing a game called look-and-say. They take turns making sequences by reading aloud the previous sequence and using that reading as the next sequence. For example, 211 is read as "one two, two ones", which becomes 1221 (1 2, 2 1s). Look-and-say sequence...
true
2ad7197fd85f713b16fece5d7253bb4a4bd8b606
JuanSaldana/100-days-of-code-challenges
/day-19/turtle_race.py
1,638
4.125
4
from turtle import Turtle, Screen, colormode from random import randint colormode(255) def set_random_color(turtle: Turtle): r, g, b = randint(0, 255), randint(0, 255), randint(0, 255) turtle.color((r, g, b)) def setup_race(n): turtles = [] screen_size = screen.screensize() step = screen_size[1...
true
8412be3158ced9cda22b82984ba0b2296c3da8a2
jsculsp/python_data_structure
/11/buildhist.py
1,361
4.25
4
# Prints a histogram for a distribution of the letter grades computed # from a collection of numeric grades extracted from a text file. from maphist import Histogram def main(): # Create a Histogram instance for computing the frequencies. gradeHist = Histogram('ABCDF') # Open the text file containing the grades....
true
4d79e76fceb858235da96274f62274bd8bc9fa7a
jsculsp/python_data_structure
/2/gameoflife.py
1,548
4.25
4
# Program for playing the game of Life. from life import LifeGrid from random import randrange # Define the initial configuration of live cells. INIT_CONFIG = [(randrange(10), randrange(10)) for i in range(50)] # Set the size of the grid. GRID_WIDTH = 10 GRID_HEIGHT = 10 # Indicate the number of generations. NUM_GEN...
true
7b37bb7acc6c035aaeb649d750983ec9af284bdc
jsculsp/python_data_structure
/8/priorityq.py
1,346
4.1875
4
# Implementation of the unbounded Priority Queue ADT using a Python list # with new items append to the end. class PriorityQueue(object): # Create an empty unbounded priority queue. def __init__(self): self._qList = list() # Return True if the queue is empty. def isEmpty(self): return len(self) == 0 # Re...
true
ac0ca45de03da9e85d16cbd00e07595e92ceb8cc
Ethan2957/p02.1
/fizzbuzz.py
867
4.5
4
""" Problem: FizzBuzz is a counting game. Players take turns counting the next number in the sequence 1, 2, 3, 4 ... However, if the number is: * A multiple of 3 -> Say 'Fizz' instead * A multiple of 5 -> Say 'Buzz' instead * A multiple of 3 and 5 -> Say 'FizzBuzz' instead The function f...
true
7307669144fb61678697580311b3e82de4dc9784
sujoy98/scripts
/macChanger.py
2,495
4.34375
4
import subprocess import optparse # 'optparse' module allows us to get arguments from the user and parse them and use them in the code. # raw_input() -> python 2.7 & input() -> python3 # interface = raw_input("Enter a interface example -> eth0,wlan0 :-") ''' OptionParser is a class which holds all the user input ...
true
4da9e5bb9096d891064eb88bfa4ccfd5bcf95447
catechnix/greentree
/sorting_two_lists.py
502
4.15625
4
""" compared two sorted arrays and return one that combining the two arrays into one which is also sorted, can't use sort function """ array1=[0,3,2,1,6] array2=[1,2,4,5] print(array2) for i in array1: if i not in array2: array2.append(i) print(array2) array3=[] while array2: minimum = a...
true
32061facf23b68d0d1b6f7794366186dba758ead
catechnix/greentree
/print_object_attribute.py
442
4.375
4
""" Write a function called print_time that takes a Time object and prints it in the form hour:minute:second. """ class Time(): def __init__(self,hour,minute,second): self.hour=hour self.minute=minute self.second=second present_time=Time(12,5,34) def print_time(time): time_text="The pre...
true
8f6253e19d64eb0b4b7630e859f4e3a143fb0833
IBA07/Test_dome_challanges
/find_roots_second_ord_eq.py
751
4.1875
4
''' Implement the function find_roots to find the roots of the quadriatic equation: aX^2+bx+c. The function should return a tuple containing roots in any order. If the equation has only one solution, the function should return that solution as both elements of the tuple. The equation will always have at least one solut...
true
91bd2e803e12dae1fb6dad102e24e11db4dfdb03
ZainabFatima507/my
/check_if_+_-_0.py
210
4.1875
4
num = input ( "type a number:") if num >= "0": if num > "0": print ("the number is positive.") else: print("the number is zero.") else: print ("the number is negative.")
true
524b1d0fa45d90e7a326a37cc1f90cdabc1942e0
CTEC-121-Spring-2020/mod-5-programming-assignment-Rmballenger
/Prob-1/Prob-1.py
2,756
4.1875
4
# Module 4 # Programming Assignment 5 # Prob-1.py # Robert Ballenger # IPO # function definition def convertNumber(numberGiven): # Here a if/elif loop occurs where it checks if the numberGiven is equal to any of the numbers below, and if it does it prints the message. if numberGiven == 1: ...
true
03f6b186c0858c30b3ec64a7954bc98d6c2b169f
StephenTanksley/cs-algorithms
/moving_zeroes/moving_zeroes.py
1,662
4.1875
4
''' Input: a List of integers Returns: a List of integers ''' """ U - Input is a list of integers. The list of integers will have some 0s included in it. The 0s need to be pushed to the tail end of the list. The rest of the list needs to remain in order. P1 (in-place swap plan) - 1) We need a way of...
true
4186c4b7ce7404bdb82854787a04983a3b1dd7c7
priyankitshukla/pythontut
/Logical Operator.py
594
4.25
4
is_Hot=False is_Cold=False if is_Hot: print(''' Its very hot day Drink Plenty of water ''') elif is_Cold: print('Its a cold day') else: print('Its a lovely day') print('Enjoy your day!') # Excersise with logical operator if is_Cold==False and is_Hot==False: prin...
true
dcfeb5f5a83c47e5123cf8e0c07c39a8ed246898
afahad0149/How-To-Think-Like-A-Computer-Scientist
/Chap 8 (STRINGS)/exercises/num5(percentage_of_a_letter).py
1,515
4.3125
4
import string def remove_punctuations(text): new_str = "" for ch in text: if ch not in string.punctuation: new_str += ch return new_str def word_frequency (text, letter): words = text.split() total_words = len(words) words_with_letter = 0 for word in words: if letter in word: words...
true
c5262a687592caede04cadc4f18ef5a66c8b9e0d
Chandu0992/youtube_pthon_practice
/core/array_example_one.py
1,044
4.15625
4
'''from array import * arr = array('i',[]) n = int(input("Please Enter size of the array : ")) for i in range(n): x = int(input("Enter next Value : ")) arr.append(x) #manual method print(arr) s = int(input("Enter a Value to search : ")) k = 0 for i in arr: if i == s: print(k) break k ...
true
5354b5ce25def354480fbd85463224f527e38e83
Ajat98/LeetCode-2020-Python
/good_to_know/reverse_32b_int.py
702
4.3125
4
''' Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpos...
true
412485e1024007908fc7ae3f65bc31897545985b
vaishnavi-gupta-au16/GeeksForGeeks
/Q_Merge Sort.py
1,565
4.125
4
""" Merge Sort Merge Sort is a Divide and Conquer algorithm. It repeatedly divides the array into two halves and combines them in sorted manner. Given an array arr[], its starting position l and its ending position r. Merge Sort is achieved using the following algorithm. MergeSort(arr[], l, r) If r > l ...
true
9cadb464d665ebddf21ddc73b136c0cf4026ba11
chaiwat2021/first_python
/list_add.py
390
4.34375
4
# append to the end of list thislist = ["apple", "banana", "cherry"] thislist.append("orange") print(thislist) # insert with index thislist = ["apple", "banana", "cherry"] thislist.insert(1, "orange") print(thislist) # extend list with values from another list thislist = ["apple", "banana", "cherry"] tropical = ["man...
true
f47e0a404ee9c531f82b657c0cc4ecc987e9279c
2flcastro/python-exercises
/solutions/2flcastro/intermediate/smallest_common_multiple.py
2,773
4.375
4
# ---------------------------------- # Smallest Commom Multiple # ---------------------------------- # Find the smallest common multiple of the provided parameters that can be # evenly divided by both, as well as by all sequential numbers in the range # between these parameters. # # The range will be a list of two numb...
true
c253c625f1d74938fc087d2206d75b75c974cd23
2flcastro/python-exercises
/beginner/longest_word.py
1,175
4.1875
4
# ---------------------------------- # Find the Longest Word in a String # ---------------------------------- # Return the length of the longest word in the provided sentence. # # Your response should be a number. # ---------------------------------- import unittest def find_longest_word(strg): return len(strg) ...
true
cb64405d60c43194cb2fd4455a68a4ec7f4441d0
2flcastro/python-exercises
/solutions/2flcastro/beginner/longest_word.py
2,172
4.28125
4
# ---------------------------------- # Find the Longest Word in a String # ---------------------------------- # Return the length of the longest word in the provided sentence. # # Your response should be a number. # ---------------------------------- import unittest # using list comprehension and max() built-in funct...
true
166f72638df619e350bc3763d1082890106a7303
smysnk/my-grow
/src/lib/redux/compose.py
820
4.1875
4
""" * Composes single-argument functions from right to left. The rightmost * function can take multiple arguments as it provides the signature for * the resulting composite function. * * @param {...Function} funcs The functions to compose. * @returns {Function} A function obtained by composing the argument functi...
true
80c7a5e3c64f31e504c793b59951260636c65d17
mike-something/samples
/movies/movies_0.py
974
4.3125
4
# https://namingconvention.org/python/ # # define variables for the cost of tickets # # we try and use names for variables which are clear and memorable. Its # good to prefer longer names which are clearer - in a large program this # can really matter # adult_ticket_cost = 18 child_ticket_cost = 10 print('...
true
76db9c3360d671f7461297a63475063908e33df9
carlos-paezf/Snippets_MassCode
/python/factorial.py
472
4.5
4
#Calculates the factorial of a number. #Use recursion. If num is less than or equal to 1, return 1. #Otherwise, return the product of num and the factorial of num - 1. #Throws an exception if num is a negative or a floating point number. def factorial(num): if not ((num >= 0) & (num % 1 == 0)): raise Excep...
true
c8f0da7555edde737b7f5e8ad697305b1087079c
carlos-paezf/Snippets_MassCode
/python/keys_only.py
714
4.3125
4
#Function which accepts a dictionary of key value pairs and returns #a new flat list of only the keys. #Uses the .items() function with a for loop on the dictionary to #track both the key and value and returns a new list by appending #the keys to it. Best used on 1 level-deep key:value pair #dictionaries (a flat dictio...
true
56f8f9eb11022cce409c96cabf50ecb13273e7df
HaoyiZhao/Text-chat-bot
/word_count.py
1,116
4.34375
4
#!/usr/bin/python import sys import os.path # check if correct number of arguments if len(sys.argv)!=2: print "Invalid number of arguments, please only enter only one text file name as the command line argument" sys.exit() # check if file exists if os.path.isfile(sys.argv[1]): file=open(sys.argv[1], "r+") wordFreq...
true
c6c066383c6d2fc587e3c2bf5d26ee36c060e288
sarank21/SummerSchool-Assignment
/SaiShashankGP_EE20B040/Assignment1Q2.py
1,483
4.25
4
''' Author: Sai Shashank GP Date last modified: 07-07-2021 Purpose: To find a pair of elements (indices of the two numbers) from a given array whose sum equals a specific target number. Sample input: 10 20 10 40 50 60 70 Sample ouput: {1: [0, 3], 2: [2, 3], 3: [3, 0], 4: [3, 2]} ''' # importing useful libraries impor...
true
d5131ecef9b8ab0918033d2a66a4e21ff329dd39
NinjaOnRails/fillgaps
/fillGaps.py
916
4.15625
4
#! /usr/bin/env python3 # fillGaps - Finds all files with a given prefix in a folder, # locates any gaps in the numbering and renames them to close the gap. import shutil, os, re folder = input("Enter path to the folder containing your files: ") prefix = input("Enter prefix: ") def fillGaps(folder, prefix): reg...
true
a7aff197a21019a5e75502ad3e7de79e08f80465
jesusbibieca/rock-paper-scissors
/piedra_papel_tijeras.py
2,820
4.4375
4
##Rock, paper o scissors## #Written by Jesus Bibieca on 6/21/2017... import random # I import the necessary library import time #This will import the module time to be able to wait #chose = "" #Initializing variables def computer(): #This function will get a rand value between 1-99 and depending on the num...
true
13c728affd7e5939a50aa5001c77f8bf25ee089c
FadilKarajic/fahrenheitToCelsius
/temp_converter.py
653
4.4375
4
#Program converts the temperature from Ferenheit to Celsius def getInput(): #get input tempInCAsString = input('Enter the temperature in Ferenheit: ') tempInF = int( tempInCAsString ) return tempInF def convertTemp(tempInF): #temperature conversion formula tempInC = (tempInF - 32) *...
true
273f798d759f25e69cfe21edcad3418d66ffd0aa
Victor094/edsaprojrecsort
/edsaprojrecsort/recursion.py
1,020
4.46875
4
def sum_array(array): '''Return sum of all items in array''' sum1 = 0 for item in array: sum1 = sum1 + item # adding every item to sum1 return sum1 # returning total sum1 def fibonacci(number): """ Calculate nth term in fibonacci sequence Args: n (int): nth term in fib...
true
c1ea1eede64d04257cd5ba8bde4aea1601044136
Rekid46/Python-Games
/Calculator/app.py
1,076
4.1875
4
from art import logo def add(a,b): return(a+b) def subtract(a,b): return(a-b) def multiply(a,b): return(a*b) def divide(a,b): return(a/b) operations = { "+": add, "-": subtract, "*": multiply, "/": divide } def calculator(): print(logo) n1=float(input("Enter first number: ")) n2=floa...
true
838775b7700e92d22745528eb8a0d03135d44f55
brandong1/python_textpro
/files.py
1,485
4.28125
4
myfile = open("fruits.txt") content = myfile.read() myfile.close() # Flush and close out the IO object print(content) ########## file = open("fruits.txt") content = file.read() file.close() print(content[:90]) ########## def foo(character, filepath="fruits.txt"): file = open(filepath) content = file.read()...
true
8e5033488a99f2c785a5d52e13745d4ab0910f61
tanglan2009/Python-exercise
/classCar.py
2,858
4.4375
4
# Imagine we run a car dealership. We sell all types of vehicles, # from motorcycles to trucks.We set ourselves apart from the competition # by our prices. Specifically, how we determine the price of a vehicle on # our lot: $5,000 x number of wheels a vehicle has. We love buying back our vehicles # as well. We offer ...
true
c259a0fb4637d7d3c208a8e08657b7584501e424
Karlhsiao/py4kids
/homework/hw_30_pay_calc.py
1,262
4.21875
4
''' Calculate weekly payment by working hours and hourly rate ''' STANDARD_HOURS = 40 OVERTIME_FACTOR = 1.5 def process_user_input(working_hours, hourly_rate): hrs = float(working_hours) r = float(hourly_rate) return hrs, r def input_from_user(): #working hours in the week, ex. 40 working_h...
true
a094eace179eb7883904a900bb4ec3587c580d2c
KonstantinKlepikov/all-python-ml-learning
/python_learning/class_attention.py
1,427
4.15625
4
# example of traps of class construction """Chenging of class attributes can have side effect """ class X: a = 1 """Chenging of modified attributes can have side effect to """ class C: shared = [] def __init__(self): self.perobj = [] """Area of visibility in methods and classes """ def generate...
true
8dfac5602f8b55eb4b850bf8f3b7c15ea7c3363b
merryta/alx-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
550
4.34375
4
#!/usr/bin/python3 """ This is the "0-add_integer" module. add a and b and it can be int or floats """ def add_integer(a, b): ''' add two number Args: a : int or float b : int or float Rueturn an int ''' if not isinstance(a, int) and not isinstance(a, float): raise TypeError("...
true
a5a62e8a5f03096ad0ad03eb27d9da6e1864a6b5
JesusSePe/Python
/recursivity/Exercises3.py
1,503
4.28125
4
"""Exercise 1. Rus multiplication method.""" from math import trunc from random import randint def rus(num1, num2): if num1 == 1: print(num1, "\t\t", num2, "\t\t", num2) return num2 elif num1 % 2 == 0: print(num1, "\t\t", num2) return rus(trunc(num1 / 2), num2 * 2) else: ...
true
d02faf79c21f33ace38aabe121dcffc7a213e457
vivekmuralee/my_netops_repo
/learninglists.py
1,069
4.34375
4
my_list = [1,2,3] print (my_list) print (my_list[0]) print (my_list[1]) print (my_list[2]) ######################################################### print ('Appending to the lists') my_list.append("four") print(my_list) ###################################################### print ('Deleting List Elements') del my_...
true
92379a4874c8af8cc39ba72f79aeae7e0edb741c
RyanIsCoding2021/RyanIsCoding2021
/getting_started2.py
270
4.15625
4
if 3 + 3 == 6: print ("3 + 3 = 6") print("Hello!") name = input('what is your name?') print('Hello,', name) x = 10 y = x * 73 print(y) age = input("how old are you?") if age > 6: print("you can ride the rolercoaster!") else: print("you are too small!")
true
f9e1251d704a08dc1132f4d54fb5f46fb171766e
BjornChrisnach/Edx_IBM_Python_Basics_Data_Science
/objects_class_02.py
2,998
4.59375
5
#!/usr/bin/env python # Import the library import matplotlib.pyplot as plt # %matplotlib inline # Create a class Circle class Circle(object): # Constructor def __init__(self, radius=3, color='blue'): self.radius = radius self.color = color # Method def add_radius(self, r): ...
true
987a02de30705a5c911e4182c0e83a3e46baecb3
littleninja/udacity-playground
/machine_learning_preassessment/count_words.py
1,201
4.25
4
"""Count words.""" def count_words(s, n): """Return the n most frequently occuring words in s.""" # TODO: Count the number of occurences of each word in s word_dict = {} word_list = s.split(" ") max_count = 1 max_word_list = [] top_n = [] for word in word_list: if word...
true
857692c3bf179c775cb1416fc7d742dfbb254a39
NCCA/Renderman
/common/Vec4.py
1,551
4.125
4
import math ################################################################################ # Simple Vector class # x,y,z,w attributes for vector data ################################################################################ class Vec4: # ctor to assign values def __init__(self, x, y, z, w=1.0): ...
true
f6d6fce48a00f5af17044c4fafbcfef686ddd1f3
nikdom769/test_py111
/Tasks/a2_priority_queue.py
1,534
4.21875
4
""" Priority Queue Queue priorities are from 0 to 5 """ from typing import Any memory_prior_queue = {} def enqueue(elem: Any, priority: int = 0) -> None: """ Operation that add element to the end of the queue :param elem: element to be added :return: Nothing """ global memory_prior_queue ...
true
2be9e85741dc8553d4f6accc9f6bfd4f9ad545d1
jwex1000/Learning-Python
/learn_python_the_hard_way_ex/ex15_extra.py
865
4.4375
4
#!/usr/bin/env python # this imports the argv module from the sys libaray print "What is the name of the file you are looking for?" filename = raw_input("> ") #creates a variable txt and opens the variable passed into it from the argv module txt = open (filename) #Shows the user what the file name is print "Here's y...
true
66efbf4f5f6c20fe0a4a715e8f10bbf6d5690913
JMCCMJ/CSCI-220-Introduction-to-Programming
/HW 1/usury.py
1,750
4.34375
4
## ## Name: <Jan-Michael Carrington> ## <usury>.py ## ## Purpose: <This program calculates the priniple payments on a car or home ## purchase. It will tell exactly how much interest will be paid ## over the period of the loans. It also will tell the total payment.> ## ## ## Certification of Authenticity: ## ## I...
true
0d359a3c30b12076205a4b030b7723ecf65b7ba0
asiguqaCPT/Hangman_1
/hangman.py
1,137
4.1875
4
#TIP: use random.randint to get a random word from the list import random def read_file(file_name): """ TODO: Step 1 - open file and read lines as words """ words = open(file_name,'r') lines = words.readlines() return lines def select_random_word(words): """ TODO: Step 2 - select rand...
true
9b3f76d0f3659b1b5d9c4c1221213ea6fbbc2a5b
arloft/thinkpython-exercises
/python-thehardway-exercises/ex4.py
892
4.34375
4
my_name = "Aaron Arlof" my_age = 40 # sigh... my_height = 70 # inches my_weight = 152 # about my_eyes = 'blue' my_teeth = 'mostly white' my_hair = 'brown' print "Let's talk about %s." % my_name print "He's %d inches tall" % my_height print "He's %d pounds heavy" % my_weight print "Actually, that's not too heavy." prin...
true
c4d6ef81f598c2f0277bb734bfd90316be19043b
andrijana-kurtz/Udacity_Data_Structures_and_Algorithms
/project3/problem_5.py
2,914
4.21875
4
""" Building a Trie in Python Before we start let us reiterate the key components of a Trie or Prefix Tree. A trie is a tree-like data structure that stores a dynamic set of strings. Tries are commonly used to facilitate operations like predictive text or autocomplete features on mobile phones or web search. Before w...
true
8ec108d9e7689393dce6d610019da91cd693dfd7
ottoman91/ds_algorithm
/merge_sort.py
1,124
4.375
4
def merge_sort(list_to_sort): #base case: lists with fewer than 2 elements are sorted if len(list_to_sort) < 2: return list_to_sort # step 1: divide the list in half # we use integer division so we'll never get a "half index" mid_index = len(list_to_sort) / 2 left = list_to_sort[:mid_index] right = l...
true
03dc6d2c4223efe10b69acd3cc6b8bbda5732fc8
noltron000-coursework/data-structures
/source/recursion.py
1,182
4.40625
4
#!python def factorial(n): ''' factorial(n) returns the product of the integers 1 through n for n >= 0, otherwise raises ValueError for n < 0 or non-integer n ''' # check if n is negative or not an integer (invalid input) if not isinstance(n, int) or n < 0: raise ValueError(f'factorial is undefined for n = {n}...
true
1f6878f1a62be6110158401c6e04d0c8d46a5d8b
noltron000-coursework/data-structures
/source/palindromes.py
2,633
4.3125
4
#!python def is_palindrome(text): ''' A string of characters is a palindrome if it reads the same forwards and backwards, ignoring punctuation, whitespace, and letter casing. ''' # implement is_palindrome_iterative and is_palindrome_recursive below, then # change this to call your implementation to verify it p...
true
ac8e6616fe97a418e310efd5feced4ffde77a8cd
themeliskalomoiros/bilota
/stacks.py
1,696
4.46875
4
class Stack: """An abstract data type that stores items in the order in which they were added. Items are added to and removed from the 'top' of the stack. (LIFO)""" def __init__(self): self.items = [] def push(self, item): """Accepts an item as a parameter and appends it to the en...
true
4022fb87a259c9fd1300fd4981eb3bd23dce7c1f
0ushany/learning
/python/python-crash-course/code/5_if/practice/7_fruit_like.py
406
4.15625
4
# 喜欢的水果 favorite_fruits = ['apple', 'banana', 'pear'] if 'apple' in favorite_fruits: print("You really like bananas!") if 'pineapple' in favorite_fruits: print("You really like pineapple") if 'banana' in favorite_fruits: print("You really like banana") if 'lemon' in favorite_fruits: print("You really l...
true
500d2e4daea05e14d3cedad52e0fae2d1ca4fe92
harjothkhara/computer-science
/Intro-Python-I/src/08_comprehensions.py
1,847
4.75
5
""" List comprehensions are one cool and unique feature of Python. They essentially act as a terse and concise way of initializing and populating a list given some expression that specifies how the list should be populated. Take a look at https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions for m...
true
23d8562ec8a10caa237d4544bb07cfefbb6fcd7f
harjothkhara/computer-science
/Sprint-Challenge--Data-Structures-Python/names/binary_search_tree.py
2,610
4.1875
4
class BinarySearchTree: # a single node is a tree def __init__(self, value): # similar to LL/DLL self.value = value # root at each given node self.left = None # left side at each given node self.right = None # right side at each given node # Insert the given value into the tree ...
true
49e4c6e85a28647c59bd025e34ac9bae09b05fc8
rtorzilli/Methods-for-Neutral-Particle-Transport
/PreFlight Quizzes/PF3/ProductFunction.py
445
4.34375
4
''' Created on Oct 9, 2017 @author: Robert ''' #=============================================================================== # (5 points) Define a function that returns the product (i.e. ) of an unknown set of # numbers. #=============================================================================== def mathProd...
true
a8e5c4bc11d9a28b1ef139cbd0f3f6b7377e6780
itsmedachan/yuri-python-workspace
/YuriPythonProject2/YuriPy2-6.py
337
4.21875
4
str_temperature = input("What is the temperature today? (celsius) : ") temperature = int(str_temperature) if temperature >= 27: message = "It's hot today." elif temperature >= 20: message = "It's warm and pleasant today." elif temperature >= 14: message = "It's coolish today." else: message = "It's cold today....
true
5079c30dbdb327661f2959b057a192e45fa20319
itsmedachan/yuri-python-workspace
/YuriPythonProject2/YuriPy2-1.py
242
4.15625
4
str_score = input("Input your score: ") score = int(str_score) if score >= 90: grade = "A" elif score >= 80: grade = "B" elif score >= 70: grade = "C" elif score >= 60: grade = "D" else: grade = "F" print("Your grade is: ", grade)
true
ad5f7bd7652559a42904eee699f9f3b0238689c8
soniccc/regexp
/regexp2.py
386
4.53125
5
# Example: To verify a string contans a particular word import re paragraph = ''' The regular expression isolates the document's namespace value, which is then used to compose findable values for tag names ''' word = 'namespace' if re.search(word, paragraph): print(f"The paragraph contains the word : '{word}'")...
true
c50996345949e25f2bc5e6ab451e8a22f6a0c5fb
DanielFleming11/Name
/AverageScores.py
551
4.28125
4
#Initialize all variables to 0 numberOfScores = 0 score = 0 total = 0 scoreCount = 0 average = 0.0 #Accept the number of scores to average numberOfScores = int(input("Please enter the number of scores you want to input: ")) #Add a loop to make this code repeat until scoreCount = numberOfScores while(scoreCount != n...
true
221a661ba52f4393d984a377511f87f7ca1e285d
iwasnevergivenaname/recursion_rocks
/factorial.py
328
4.40625
4
# You will have to figure out what parameters to include # 🚨 All functions must use recursion 🚨 # This function returns the factorial of a given number. def factorial(n, result = 1): # Write code here result *= n n -= 1 if n == 1: return result return factorial(n, result) print(factorial...
true
b2e6d5d485409a42c565292fa84db602445778a4
eugenesamozdran/lits-homework
/homework8_in_progress.py
1,178
4.3125
4
from collections.abc import Iterable def bubble_sort(iter_obj, key=None, reverse=False): # first, we check if argument is iterable # if yes and if it is not 'list', we convert the argument to a list if isinstance(iter_obj, Iterable): # here we check if some function was passed a...
true
12ca3949ce6f3d218ed13f58ee0ab0a0e06f4ab4
geyunxiang/mmdps
/mmdps/util/clock.py
1,760
4.34375
4
""" Clock and time related utils. """ import datetime from datetime import date def add_years(d, years): """ Return a date that's `years` years after the date (or datetime) object `d`. Return the same calendar date (month and day) in the destination year, if it exists, otherwise use the following day ...
true
522bc730e6d05cc957a853f5d667e553229474ff
Bigbys-Hand/crash_course_git
/functions.py
2,909
4.4375
4
def greet_nerds(): """Display a simple greeting""" print("Live long and prosper") def better_greeting(username): """Display a simple greeting, pass name to function""" print(f"Live long and prosper, {username.title()}!") #This function is similar to the first one, but we created the PARAMETER 'usernam...
true
5d40801b679cd7469773a11535c56ec1efb8c63e
weixuanteo/cs_foundation
/string_splosion.py
474
4.28125
4
# Given a non-empty string like "Code" return a string like "CCoCodCode". # Sample input s = "Code" def string_splosion(str): result = "" # On each iteration, add the substring of the chars for i in range(len(str)): print("str[:i+1]: ", str[:i+1]) # [Python slicing] Returns from begining o...
true
c72327d594362697ad1b65db7530a19d564b74da
saintsavon/PortfolioProjects
/Interview_Code/Palindrome.py
1,434
4.21875
4
import re import sys # Used to get the word list file from command line # Example command: 'python Palindrome.py test_words.txt' input_file = sys.argv[1] def palindrome(word): """ Checks if word is a palindrome :param word: :return Boolean: """ return word == word[::-1] palindrome_dict = {}...
true
11a39da4784ff32c31419d5bb891893ec22f810e
abhatia05/Udemy---Colt-Steele-Modern-Python-Bootcamp-Codebook
/14. Dictionaries/125. iterating_dict.py
1,365
4.25
4
instructor = { "name":"Cosmic", "num_courses":'4', "favorite_language" :"Python", "is_hillarious": False, 44 : "is my favorite number" } # Accessing all values in a dictionary # We'll loop through keys, loop through values, loop through both keys and values # Values Print .values() ...
true
a9b3cedf7ae1dae5eb5ce3246552c15df6bf59eb
abhatia05/Udemy---Colt-Steele-Modern-Python-Bootcamp-Codebook
/12. Lists/104. list_methods.py
1,127
4.1875
4
first_list = [1,2,3,4] first_list.insert(2,'Hi..!') print(first_list) items = ["socks", 'mug', "tea pot", "cat food"] # items.clear() #Lets the items list to be a list but clears everything within it. items = ["socks", 'mug', "tea pot", "cat food"] first_list.pop() # Remove the last element first_list.pop(1...
true
f4724113c5118d7bd8a03d862cf6010ba588539f
abhatia05/Udemy---Colt-Steele-Modern-Python-Bootcamp-Codebook
/08. and 09. ConditionalLogic and RPS/game_of_thrones.py
1,970
4.15625
4
print("Heyy there! Welcome to GOT quotes machine.") print("What is your name human ?") user_name = input() print("\n Select from numbers 1 through 5 and we will give a quote (or two) based on your name. e.g. 1 or Tyrion or TL (case sensitive)\n \n") # or First Name or Initials print("What's your character's name?\...
true
aaaf8d5decbabeede4a42c2630fc1f31ec387a58
abhatia05/Udemy---Colt-Steele-Modern-Python-Bootcamp-Codebook
/08. and 09. ConditionalLogic and RPS/bouncer.py
1,367
4.375
4
#Psuedo Code: Ask for age # 18-21 Wristband and No Drinks # Method1 # age = input("How old are you: ") # age = int(age) # if age != "": # if age >= 18 and age < 21: # print("You can enter, but need a wristband ! Also no drinks for you ese!") # # 21+ Normal Entry and Drinks # elif a...
true
f96111974debd6f8a56e9eb3d964bcf2d40517d7
iroshan/python_practice
/recursive_sum.py
588
4.28125
4
def recursive_sum(n=0): ''' recursively add the input to n and print the total when the input is blank''' try: i = input('enter a number: ') # base case if not i: print(f'total = {n}') # check if a number elif not i.isnumeric(): print("not a number...
true
65fb533a490dfcaf5ed1462f217047f7a8ae5f74
iroshan/python_practice
/guess_the_number.py
783
4.125
4
from random import randint def guess_num(): ''' guess a random number between 0 and 100. while users guess is equal to the number provide clues''' num = randint(0,100) while True: try: # get the number and check guess = int(input('enter your guess: ')) if num > g...
true
ebfcfd2080c938b2f842bebf1e0e21a2a75b8cd6
jayfro/Lab_Python_04
/Minimum Cost.py
866
4.3125
4
# Question 4 c groceries = [ 'bananas', 'strawberries', 'apples', 'champagne' ] # sample grocery list items_to_price_dict = { 'apples': [ 1.1, 1.3, 3.1 ], 'bananas': [ 2.1, 1.4, 1.6, 4.2 ], 'oranges': [ 2.2, 4.3, 1.7, 2.1, 4.2 ], 'pineapples': [ 2.2, 1.95, 2.5 ]...
true
a3b6a12ec18d72801bf0ee0bb8a348313ddb62fa
AZSilver/Python
/PycharmProjects/test/Homework 05.py
2,286
4.4375
4
# ------------------------------------------------------------------------------- # Name: Homework 05 # Purpose: Complete Homework 5 # Author: AZSilverman # Created: 10/21/2014 # Desc: Asks the user for the name of a household item and its estimated value. # then stores both pieces of data in a text file called HomeInv...
true
6c64f1505db0b69276f2212bc96e8ec89ef81734
u4ece10128/Problem_Solving
/DataStructures_Algorithms/10_FactorialofAnyNumber.py
719
4.5
4
# Find the factorial of a given number n def factorial_iterative(n): """ Calculates the factorial of a given number Complexity: O(N) :param n: <int> :return: <int> """ result = 1 for num in range(2, n+1): result *= num return result def factorial_recursive(n): """ ...
true
de2e1abde37e6fd696a8f50d6143d491d8fb5d05
if412030/Programming
/Python/HackerRank/Introduction/Division.py
1,658
4.40625
4
""" In Python, there are two kinds of division: integer division and float division. During the time of Python 2, when you divided one integer by another integer, no matter what, the result would always be an integer. For example: >>> 4/3 1 In order to make this a float division, you would need to convert one of t...
true
0fdb20e59477fd96d05f5c3d2ed9abcbb0201e39
if412030/Programming
/Python/HackerRank/Introduction/ModDivmod.py
1,002
4.5
4
""" One of the built-in functions of Python is divmod, which takes two arguments aa and bb and returns a tuple containing the quotient of a/ba/b first and then the remainder aa. For example: >>> print divmod(177,10) (17, 7) Here, the integer division is 177/10 => 17 and the modulo operator is 177%10 => 7. Task Read...
true
762121b1d623ce8b5fc62b6234b333c67187131e
Ro7nak/python
/basics/Encryption_Decryption/module.py
621
4.625
5
# encrypt user_input = input("Enter string: ") cipher_text = '' # add all values to string for char in user_input: # for every character in input cipher_num = (ord(char)) + 3 % 26 # using ordinal to find the number # cipher = '' cipher = chr(cipher_num) # using chr to convert back to a letter cipher...
true
d85a139d910c67059507c6c73d49be723f3faa56
bugmark-trial/funder1
/Python/sum_of_digits_25001039.py
349
4.25
4
# Question: # Write a Python program that computes the value of a+aa+aaa+aaaa with a given # digit as the value of a. # # Suppose the following input is supplied to the program: # 9 # Then, the output should be: # 11106 # # Hints: # In case of input data being supplied to the question, it should be # # assumed to be a ...
true
e10eae47d7a19efb93d76caeb2f6a2752cdd6666
dichen001/CodeOn
/HWs/Week 5/S5_valid_anagram.py
1,626
4.125
4
""" Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s = "rat", t = "car", return false. """ def isAnagram(s, t): """ :type s: str :type t: str :rtype: bool """ ### Please start your code here### le...
true
3e73ef211d9d20808bad316e3d1f8493a386abd7
joeyyu10/leetcode
/Array/56. Merge Intervals.py
731
4.21875
4
""" 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]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] and [4,5] are ...
true
886bcb3990f524a5495b4254f71d6f6d03986a9f
reemanaqvi/HW06
/HW06_ex09_06.py
939
4.34375
4
#!/usr/bin/env python # HW06_ex09_05.py # (1) # Write a function called is_abecedarian that returns True if the letters in a # word appear in alphabetical order (double letters are ok). # - write is_abecedarian # (2) # How many abecedarian words are there? # - write function(s) to assist you # - number of abeced...
true