blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f09e36813c4fc46424781e2d98255410d81ca8dc
sureshyhap/Python-Crash-Course
/Chapter 4/13/buffet.py
249
4.21875
4
foods = ('burgers', 'fries', 'lasagna', 'alfredo', 'macaroni') for food in foods: print(food) new_food1 = 'chicken' new_food2 = 'vegan burger' foods = (new_food1, new_food2, foods[2], foods[3], foods[-1]) for food in foods: print(food)
true
9203ba6034915302abb40d4cca075868a75deaa2
MrDarnzel/Total-Price
/Celsius.py
385
4.375
4
Temp_Celsius = input(" What is the Temperature in Celsius? ") #Asks the user for Temperature in Celsius float(Temp_Celsius) #Converts to Float print(Temp_Celsius) #Prints Celcius Temperature Temp_Fahrenheit = (((float(Temp_Celsius) * 9) / 5) + 32) #Takes C and converts into F print(" The temperature in F...
true
54d2037bb436d0bc5b6d4eff3c52dbac36683fc3
HamMike/extra_python_exercises
/single_one.py
421
4.1875
4
# Given an array of integers, every element appears twice except for one. # Implement a program that will print that single one. # Example: [1,1,2,2,3,3,4,5,5,6,6,7,7] - 4 would be the odd man out # Note: # Your algorithm should have a linear runtime complexity. # *** your code here *** #Steve's solution def find_...
true
1188c4eefe1d9093d1d428b08c0531d801541f90
Raspberriduino/PythonBeginnerProjects
/FAQ Questions Program - Dictionary Data Structure Practice/FAQ Data Entry Program.py
2,449
4.21875
4
# # # David Pierre-Louis # August 11, 2019 # SEC 290 32784.201930 SUMMER 2019 - Block II # Programming Assignment 5 # # Create a Python program that will serve as a # menu-driven interface that manages a dictionary # of Frequently Asked Questions (FAQ's) # # Questions serve as the keys and answers serve as # the value...
true
423b4396d2a14034c9e5120127c7a88e396d10ea
rohinikuzhiyampunathumar/Python
/arrays.py
1,104
4.15625
4
from array import * # import array as arr # use this if you are using import array as arr # vals = arr.array('i',[4,-3,7,3]) # print(vals) # vals.reverse() # print(vals) vals = array('i',[7,8,4,-3,6,8]) print(vals) for i in range(6): print(vals[i]) for i in range(len(vals)): print(vals[i]) for ...
true
9071e4cf7cb405a6105ba56342505a37232eae88
KamranHussain05/CS3A-OOP-Python
/kamranHussainLab2.py
2,033
4.125
4
########################################################### # Name: Kamran Hussain # Date: 7/13/2021 # Course: CS 3A Object-Oriented Programming Methodologies in Python # Lab 2: Programming with Numbers and Strings; Controlling Selection # Description: A console based program that calculates the value of a coupon # bas...
true
9dba312c2409873e6c12195400b76fc4e0e2613f
sidlokam/Python-Addition
/Addition.py
251
4.15625
4
def addition(number1, number2) : return number1 + number2 number1 = int(input("Enter First Number : ")) number2 = int(input("Enter Second Number : ")) number3 = addition(number1, number2) print("the sum of the two numbers is : "+ str(number3))
true
08f04d54ded1d3193a5b51b4a86e0604ed486385
hacker95-bot/SE-HW1
/code/__init__.py
267
4.25
4
x = 10 def factorial(n): """ Recursive Function to calculate the factorial of a number :param n: integer :return: factorial """ if n <= 1: return 1 return n * factorial(n - 1) if __name__ == "__main__": print(factorial(x))
true
e3ef5a553583b8f9612d1672d0e74e5b6edd7345
MengleJhon/python_1
/parrot.py
527
4.25
4
message = input("Tell me something, and I will repeat it back to you: ") print(message) name = input("Please enter your name: ") print("Hello, " + name + "!") prompt = "If you tell us who you are, we can personalize the messages you see." prompt += "\nWhat is your first name? " name = input(prompt) print("\nHello, "...
true
e039a0b6781bbdae332d45fd561ad66b28fdf284
sharkfinn23/Birthday-quiz
/birthday.py
2,500
4.6875
5
""" birthday.py Author: Finn Credit: none Assignment: Your program will ask the user the following questions, in this order: 1. Their name. 2. The name of the month they were born in (e.g. "September"). 3. The year they were born in (e.g. "1962"). 4. The day they were born on (e.g. "11"). If the user's birthday fell...
true
314ea8b713dba09f9499c694b9200671736ec0a8
meikesara/Heuristieken
/algorithms/simulatedannealing.py
2,784
4.25
4
""" Script to run a simulated annealing algorithm with a logarithmic cooling rate (temperature = D/ln(iteration + 2) - D/ln(10^6)). From the 10^6-2th iteration the temperature will be D/ln(10^6 - 1) - D/ln(10^6). Meike Kortleve, Nicole Jansen """ import copy import math import random import matplotlib.pyplot as plt f...
true
d61ab7bdd40531e7cc20ce49e796e631dda31588
interpegasus/book
/python/data_structures/linked_list.py
2,511
4.15625
4
class Node: def __init__(self, data, next): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None self.length = 0 def is_empty(self): return self.length == 0 def insert(self, data): new_node = Node(dat...
true
942afab63fcbdd0514ac581a6d4fa3ed9790e2ea
sabrupu/comp151
/Lab9/Problem2.py
631
4.15625
4
# Write a function that will accept a list of numbers and calculate the median. # Input: [20, 10, 5, 15] # Output: The median is 12.5. # Input: [20, 10, 5, 15, 30] # Output: The median is 15 def median(list): sort_list = sorted(list) length = len(list) middle = length // 2 if length == 1: ret...
true
65f0cf1442e5485adebc89db4e9b5b6fb636309d
sabrupu/comp151
/Lab6/Problem1.py
729
4.34375
4
# Write a function that will accept two arguments, a string and a character. Your function # should search the string for and count the number of occurrences of the given character. # # Enter the string to search: Sally sells sea shells down by the sea shore. # Enter the character to count: s # # There were 8 s's in th...
true
ee571416c44ff8cc7a299db5a141341ef26f5417
sabrupu/comp151
/Lab6/Problem2.py
451
4.28125
4
# Write a function that will convert a list of characters into a string. Return this string to # main and display it. # # Input: [‘H’, ‘e’, ‘l’, ‘l’, ‘o’] # # Output: “Hello” def join_chars(char_list): str = '' for c in char_list: str += c return str def main(): input = ['H', 'e', 'l', 'l', ...
true
f525d1dfb123d4faac7482d9c8fe9453a35bd153
sabrupu/comp151
/PAL/Assignment2/Problem1.py
255
4.21875
4
# Write a program that will read a number n from the user then print all values from 1-n. # Example: # Enter a number: 6 # 1 2 3 4 5 6 def main(): n = int(input('Enter a number: ')) for i in range(1, n + 1): print(i, end=' ') main()
true
c6f618ed9dc14d50a766a6e6d6138a6e92bdb6dc
sabrupu/comp151
/PAL/Assignment2/Problem2.py
478
4.3125
4
# Write a program that will read a number n from the user then print and sum all even # numbers from 1-n. # Enter a number: 12 # 2 + 4 + 6 + 8 + 10 + 12 = 42 def main(): # Enter user input n = int(input('Enter a number: ')) # Loop through even natural numbers up to n sum = 0 str = '' for i in...
true
9b4ee102cee05b58e23b92afbb55d41475b21b2c
dubeyji10/Learning-Python
/Day6/.idea/iterator1.py
1,067
4.71875
5
#iterator # ---- it is an object that represents a stream of a data # it returns the stream or the actual data in the stream (one element at a time) #an object that supports iteration is called itertion # two iterable objects we've seen already so far --- strings and lists string = "1234567890" # for char in string:...
true
37379bb285ea9c80f8512cc9f64a2e7db4ff7ebc
dubeyji10/Learning-Python
/Day5/.idea/lists2.py
1,095
4.28125
4
list1 = [] list2 = list() #constructor ? print(" List 1 : {}".format(list1)) print(" List 2 : {}".format(list2)) if list1 == list2 : print(" lists are equal") #passsing a string to the list #creates a list with each character print(list(" the lists are equal ")) # see the output print(" \n------ reversing a lis...
true
105553aaa9066d677220be514c9c396c389450e5
dubeyji10/Learning-Python
/Day9(Dictionaries and Sets)/.idea/DS14.py
708
4.1875
4
#more on sets even_set = set(range(0,40,2)) print(even_set) #* unordered print(len(even_set)) print("--"*30) squares_tupple = (4,6,9,16,25) squares = set(squares_tupple) print(squares) print(len(squares)) print("--"*30) #union of sets #mathematical union ------- one item on time print(even_set.union(squares)) #inte...
true
6face84af864ea99dd3865d56d51719bba6a41bb
dubeyji10/Learning-Python
/Day9(Dictionaries and Sets)/.idea/DS1.py
1,046
4.46875
4
#Dictionaries #are unordered #contain key valued pairs #values are not accessed by an index but by means of a key fruit = {"orange": "a sweet, orange, citrus fruit", "apple": "good for making cider", "lemon": "a sour,yellow citrus fruit", "grape": "a small, sweet fruit growing in bunhces", ...
true
965c6d04d1bd7d9d483c3a4bf1caa848ec992230
dubeyji10/Learning-Python
/PythonDay2/.idea/Day2a.py
1,060
4.28125
4
#undo next 3 lines # greeting="HELLO" # name=input("Enter you name ") # print(greeting+' '+name) #backslash gives a special meaning #splitString #and tabString show # to put something in a comment select that part and use ctrl+/ button to make it a # comment and undo it splitString = " This string has been \nsplit ...
true
4fb1d0b6cc215c9f69388938f51e66d0e795c954
dubeyji10/Learning-Python
/Day5/.idea/lists3.py
390
4.3125
4
even = [2,4,6,8] another_even2 = list(even) # a constructor and # passing list even to it which returns a new list print( "\n !!!! see source !!!!") print(another_even2 is even) # this returns false another_even2.sort(reverse=True) #make the required --- excep for declaration of even # above code comment and see print(...
true
acf9882273eff9d2bdc46832f594cb58fc281a64
hr21don/Single-Linked-List
/main.py
883
4.21875
4
# A single node of a singly linked list class Node: # constructor def __init__(self, data): self.data = data self.next = None # A Linked List class with a single head node class LinkedList: def __init__(self): self.head = None # insertion method for the linked list def insert(self, data): ...
true
75f5e69447c91b87a4bed209d3a1af851b30973e
rtanvr/pathon
/text/palindrome.py
280
4.15625
4
#See if string is a palindrome class StringMan(): def palindrome(self, string): if string == string[::-1]: return "Palindrome" else: return "Not Palindrome" if __name__ == '__main__': x = StringMan() string = input("Enter a string: ") print (x.palindrome(string))
true
704e6e4af0e148a6f7a21ee0312ed513a68d6383
AdrianaChavez/rockpaperscissors
/rps.py
1,176
4.125
4
list = ["rock","paper","scissors"] import random computer_choice = (random.choice(list)) user_input = input("Let's play Rock Paper Scissors. Which do you choose? (Type 'Rock', 'Paper', or 'Scissors'") print("Rock, paper, scissors, shoot!") if user_input=="Rock" and computer_choice=="rock": print("I chose rock to...
true
5e4ca3203ffa1b4742e5206b71c68ab4142eb74b
michalkasiarz/learn-python-programming-masterclass
/program-flow-control-in-python/ForLoopsExtractingValuesFromInput.py
432
4.28125
4
# For loops extracting values from user input # prints entered number without any separators number = input('Please enter a series of numbers, using any separators you like: ') separators = '' numberWithNoSeparators = '' for char in number: if not char.isnumeric(): separators = separators + char else:...
true
95edfc4291b87aaf46304869b4d4b724365e01d3
michalkasiarz/learn-python-programming-masterclass
/lists-ranges-and-tuples-in-python/ListsIntro.py
856
4.34375
4
# Introduction to lists # ip_address = input("Please enter an IP address: ") # print(ip_address.count(".")) parrot_list = ["non pinin", "no more", "a stiff", "bereft of live"] parrot_list.append("A Norwegian Blue") for state in parrot_list: print("This parrot is " + state) even = [2, 4, 6, 8] odd = [1, 3, 5, 7...
true
a1cf944dad61d0af6cb3c2b753059a99e5c03951
michalkasiarz/learn-python-programming-masterclass
/program-flow-control-in-python/GuessingGame.py
1,059
4.34375
4
# Challenge # Modify the program to use a while loop, to allow the player to keep guessing. # The program should let the player know whether to guess higher or lower, and should # print a message when the guess is correct. # A correct guess will terminate the program # As an optional extra, allow the player to quit by ...
true
85ab131d6b933173455b59008d7c58a12a856b65
michalkasiarz/learn-python-programming-masterclass
/program-flow-control-in-python/SteppingThroughForLoop.py
347
4.375
4
# Stepping through a For Loop number = '63,123;321:642 941 332;120' separators = '' # extracting separator with a For Loop for character in number: # for each character in a number if not character.isnumeric(): # if is not numeric separators = separators + character # add the character to the sep...
true
728025a2f0e7574edd8f4d44f2bddc79a2ba87d2
iqbalanwar/python_tutorial
/3_data_structure_collections/1_list_and_tuples.py
1,948
4.5
4
''' Lists are mutable - Lists are an ordered collection Tuples are not mutable - Tuples are also an ordered collection - They were exactly the same, but can't be modified ''' def main(): game_one_list() game_two_list() game_tuple() x = ['-','X','X','-'] print(f"Before, the list x is {x}") # th...
true
6ffefd7a634fde7fba5178bda6a3c9a07513cda2
irimina/python-exercises
/apendAndsort.py
309
4.15625
4
''' Task: Write a for-loop that iterates over start_list and .append()s each number squared (x ** 2) to square_list. Then sort square_list! ''' start_list = [5, 3, 1, 2, 4] square_list = [] # Your code here! for number in start_list: square_list.append(number**2) square_list.sort() print square_list
true
d851c1ca807d66353d7a188404a111ae9347ca84
JuliaJansen/-HabboHotel
/Python code/csv_reader.py
2,442
4.21875
4
# Reads the list of houses and water from a csv file named output.csv # and stores this in the same object-type of list. # # csv_reader(filename) # Amstelhaege - Heuristieken # Julia Jansen, Maarten Brijker, Maarten Hogeweij import csv from house import * def csv_reader(filename): """ Writes th...
true
12f824c483ebfc1aba65a336c316fbeb3356dff7
1941012973/CWC
/quiz-1/question2.py
2,485
4.375
4
import random # reserved values for user USER_INPUT = "" USER_POINTS = 0 # reserved values for computer COMPUTER_INPUT = "" COMPUTER_POINTS = 0 # other reserved values STOP_GAME = False MAX_ROUNDS = 3 COMPLETED_ROUNDS = 0 ACCEPTED_INPUTS = ['R', 'P', 'S'] # loop till the number of rounds is 3 or user decides to qui...
true
01995a8eec92fb99395ba57a7def0cf85458e627
abhinav-bapat/PythonPrac
/for_loop_example6.py
307
4.1875
4
""" Find out and print the vowels in a given word word = 'Milliways' vowels = ['a', 'e', 'i', 'o', 'u'] """ word = 'Milliways' vowels = ['a', 'e', 'i', 'o', 'u'] result=[] for x in word: if x in vowels: if x not in result: result.append(x) print(result)
true
35184453606c23ec5579cd25a29e8be7dbc6cd3d
graemerenfrew/DesignPatternsInPython
/SingletonPattern/singleton_classic.py
592
4.15625
4
class Singleton(object): ans = None @staticmethod def instance(): ''' we do not instantiate instances of Singleton class we just use this static method to allow access''' if '_instance' not in Singleton.__dict__: Singleton._instance = Singleton() # this is how we ens...
true
35aaf99d1f456b2dbb245924da2a9ebbb0683683
ankitsaini84/python
/files.py
614
4.21875
4
""" 1. Create a program that opens file.txt. Read each line of the file and prepend it with a line number. """ with open('file.txt', 'r') as r_file: for line in r_file: print(line.rstrip()) # rstrip removes all trailing whitespaces & newlines """ 2. Read the contents of animals.txt and produce a file named...
true
bdb8aa93aa1252198159eee3dc0214021ede2cab
Mohitgola0076/Day5_Internity
/File_and_Data_Hanldling.py
1,662
4.1875
4
''' Python too supports file handling and allows users to handle files i.e., to read and write files, along with many other file handling options, to operate on files. Data handling is the process of ensuring that research data is stored, archived or disposed off in a safe and secure manner during and after the conclu...
true
75fbd42ced9297082c7796e677ddc01fbf3091ec
Hasibul-Alam/learning-python
/Python Basic/recursion.py
240
4.28125
4
#!/usr/bin/python3.9 def calc_factorial(x): if x == 1: return 1 else: return (x*calc_factorial(x-1)) grab = input('Enter a number to find its factorial:') b=int(grab) print ('Factorial of',b,'is:',calc_factorial(b))
true
3af98f0e1cdbf8c49ef05ca95243d11ce478b742
Hasibul-Alam/learning-python
/clever-programming/set.py
787
4.15625
4
list_of_numbers = [1, 2, 2, 3, 4, 5, 5, 5, 6, 6] no_duplicate_set = set(list_of_numbers) no_duplicate_list = list(no_duplicate_set) list_of_numbers = no_duplicate_list print(list_of_numbers) library_1 = {'Harry Potter', 'Hunger Games', 'Lord of the rings'} library_2 = {'Harry Potter', 'Romeo and Juliet'} # union_oper...
true
b68fdff33a610c7e4bb398d14a6c21cc13a9b558
dustinboswell/daily-coding-problem
/prob28.py
2,558
4.21875
4
''' Write an algorithm to justify text. Given a sequence of words and an integer line length k, return a list of strings which represents each line, fully justified. More specifically, you should have as many words as possible in each line. There should be at least one space between each word. Pad extra spaces when ne...
true
1006271f95ec1da9d57dd3afaaf1591cd27afaad
cryu1994/python_folder
/oop/products/index.py
666
4.1875
4
class bike(object): def __init__(self, price, max_speed, miles = 0): print "New bike" self.price = price self.max_speed = max_speed self.miles = miles def display(self): print "Price is:",self.price print "The max_speed is:",self.max_speed print "The total miles riden is:",self.miles return self def ...
true
62032db1055ce4b10a14cb5574db5fdf6f6b7e11
mvoecks/CU-MatrixMethods
/firstorder.py
2,656
4.34375
4
#This file generates random text based on an input text using a first order markov chain model #import necessary libraries import random import sys #define the probability transition matrix hashtable and the lastword variable lastWord = '' ptm = {} #This section populates the probability transition matrix by scannin...
true
9a42eba82f4fe4eb85c0430c76d05448e5a63b25
crobil/project
/range_extraction.py
1,524
4.5625
5
""" instruction A format for expressing an ordered list of integers is to use a comma separated list of either individual integers or a range of integers denoted by the starting integer separated from the end integer in the range by a dash, '-'. The range includes all integers in the interval including both endpoints...
true
6c7f9df74e6defe4b9348e167da97b71d19047c4
crobil/project
/Simple_Encryption_#1_Alternating_Split.py
1,477
4.46875
4
""" For building the encrypted string: Take every 2nd char from the string, then the other chars, that are not every 2nd char, and concat them as new String. Do this n times! Examples: "This is a test!", 1 -> "hsi etTi sats!" "This is a test!", 2 -> "hsi etTi sats!" -> "s eT ashi tist!" Write two methods: def encr...
true
fcf5810c6153783f3133e1ec24260d6c9f3c8a1f
alyssonalvaran/activelearning-python-exercises
/scripts/exercise-08.py
788
4.40625
4
#!/usr/bin/env python # coding: utf-8 # ## Exercise 8 # #### dates-and-times # Ask the user to input a month, day, and year, and display it in the following format - `Jan 2, 2019 (Wed)`. # In[1]: import datetime # assuming that the user will enter valid inputs: month = int(input("Enter month (1 to 12): ")) day =...
true
4210cf5ce1635d4dd0e938e6767cc030ce617349
alyssonalvaran/activelearning-python-exercises
/scripts/exercise-06.py
2,035
4.6875
5
#!/usr/bin/env python # coding: utf-8 # ## Exercise 6: Functions # #### days-in-month # Modify days-in-month of Exercise 3.1. Write a function called `num_days_in_month(month)` which will return the number of days given a month (1 to 12). The function should return -1 if the value passed is not between 1 to 12. Modi...
true
af1247d822a3caf43b668dd211e927bf09b8ea26
pdst-lccs/alt2
/average.py
2,529
4.3125
4
# Program to demonstrate mean, median and mode # A function to return the arithmetic mean of all the values in L def get_mean(L): # set the initial value of total to zero total = 0 # running total of values in L # Now loop over the list for v in L: total = total + v # running total ...
true
63aac3628de8792208f5c40e17e61a677280e0a8
klewison428/Python-Projects
/Automate the Boring Stuff with Python/table_printer.py
615
4.1875
4
def printTable(): colWidths = [0] * len(tableData) for column in tableData: for row in column: if len(colWidths) < len(row): print("column widths = " + str(colWidths)) print("row = " + str(row)) longest_word = len(row) longest_word = row print(longest_word) tableData = [['apples', 'oranges', ...
true
a6721a95cf84e30f928b616458ae05196e66baee
PoojaDilipChavan/DataScience1
/Tuples.py
2,290
4.75
5
""" Tuples https://www.geeksforgeeks.org/python-tuples/?ref=lbp https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences https://docs.python.org/3/library/stdtypes.html#typesseq https://wiki.python.org/moin/TimeComplexity -- complexity for tuples is same as lists (indexed) ...
true
2105df201becec94f76a59e1bd583d70e9e8a4db
Fey0xFF/python_odin_project
/caesar_cipher/caesar_cipher.py
809
4.125
4
#import string for ascii import string #store user string and shift factor plaintext = input("Please enter a sentence to encrypt: ") shift = int(input("Please enter a shift factor: ")) #cipher function def cipher(text, shiftfactor): #init key lists letters = list(string.ascii_lowercase[:26]) capletters = list(s...
true
0929a445c33490a8ac0a171f95db790ed405ca92
dogusural/arbitrager
/gui/menu.py
756
4.125
4
choice ='0' while choice =='0': print("Please choose currency.") print("Choose 1 for TRY") print("Choose 2 for EUR") choice = input ("Please make a choice: ") if choice == "1" or choice == "2": print("Please choose arbitrage direction.") print("Choose 1 for Turkish -> Europe") ...
true
f4d3ea16f57c651382d204db451dbb11d557522c
JulianConneely/multiParadigm
/Assignment2/10.py
890
4.59375
5
# Verify the parentheses Given a string, return true if it is a nesting of zero or more # pairs of parenthesis, like “(())” or “((()))”. # The only characters in the input will be parentheses, nothing else # For them to be balanced each open brace must close and it has to be in the correct order # ref. https://ww...
true
67658293f7276aff66812ae1006ec2ebfee8677a
Zalasanjay/hacktoberfest2020-1
/Python/shell_sort.py
1,226
4.1875
4
""" Author: Kadhirash Sivakumar Python program implementing Shell Sort Shell Sort: Similar to Insertion Sort except allows for exchange with farther indexes. Make the array 'h' -sorted for a large 'h' value, and keep reducing 'h' by 1. Array is 'h' sorted if all subarrays of every h'th element is sorted! Time Com...
true
761ca059fcff934608c98c8ebd071a8d7268da46
Zalasanjay/hacktoberfest2020-1
/Projects/Python/ball.py
2,295
4.21875
4
import pygame import random # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) SCREEN_WIDTH = 700 SCREEN_HEIGHT = 500 BALL_SIZE = 25 class Ball: """ Class to keep track of a ball's location and vector. """ def __init__(self): self.x = 0 self.y = 0 self.change_x = 0 self.chang...
true
8886bc06ddaed9ff37a5d6190d7791a646b29e8f
cristopherf7604/bluesqurriel
/ex13.py
487
4.1875
4
from sys import argv # read the WYSS section for how to run this script, first, second, third = argv # in bash you can make the first second and third variable it put a word in each variable slot and it determines that by whatever words are after python3.6 # it's saying what script first second and third variable are c...
true
f6c0165e506e822728faa17a84fccefd1ed30c2a
Lemachuca10/Module-3-assingment-
/area of a circle (2).py
222
4.375
4
#Luis Machuca #1/30/2020 #This program will compute the area of a circle. #formula is p*r^2 for Area of circle p = 3.14 r = int(input ("radius ")) #the caculation for the area print ("The area is ") print (p*r**2)
true
6e551a7376ec75ffc063039826ad30affe7ac3ba
aclairekeum/comprobo15
/useful_tools/useful_trig.py
736
4.21875
4
import math def angle_normalize(z): """ convenience function to map an angle to the range [-pi,pi] """ return math.atan2(math.sin(z), math.cos(z)) def angle_diff(a, b): """ Calculates the difference between angle a and angle b (both should be in radians) the difference is always based on the close...
true
e5c3ebc8f9589e0957ecdf6747299e3bba8f2e5b
captainGeech42/CS160
/assignment4.py
2,206
4.21875
4
firstRun = True while True: # choose the mod mode = input("Please select 'scientific' or 'programmer' mode: " if firstRun else "Please select next mode, or 'exit' to quit the calculator: ") if (mode == "scientific"): # scientific mode validOperations = ["+", "-", "*", "/", "**"] chosenOperation = "" expone...
true
0a4f08eaeac3ccd1e47e10f57d4d05c0f31e68d8
nancyorgan/memory
/main.py
2,585
4.15625
4
#!/usr/bin/python ###################################################### ########### card-flip memory game #################### class PRNG(object): def __init__(self, seed): self.state = seed def next(self): x = self.state x = x + 1 x = x << 8 | x >> 8 x = x * 997 * 997 x = x % 1024 s...
true
e9c651b2cf84e60edc1e481d3fa9734618fe65d2
Jolo510/practice_fusion_challenge
/src/doctors.py
1,371
4.125
4
class Doctor: """ Summary of class here. Doctor contains - num_id - name - specialty - area - score Attributes: similarity_score: Generates a similarity score between two doctors """ def __init__(self, num_id, name, specialty, area, score): self.num_id = num_id self.name = name self.spe...
true
79953dc7f863590116ef1772ecafc0a65f49e1aa
andbutso/6.0001
/ps 1/ps1a.py
929
4.21875
4
# Problem Set 1a # Name: George Mu # Collaborators: None # Time Spent: 00:20 # Get user inputs annual_salary = int(input('Enter your annual salary:')) portion_saved = float(input('Enter the percent of your salary to save, as a decimal:')) total_cost = int(input('Enter the cost of your dream home:')) # Initialize sta...
true
6dd651b8564305dbabc40f6635b46b75c67996b3
jltf/advanced_python
/homework3/1_lock.py
856
4.15625
4
""" Output numbers from 0..100 in order. First thread outputs even numbers. Second thread outputs odd numbers. Using Lock synchronization object. """ from threading import Lock from threading import Thread def print_even_numbers(lock_even, lock_odd): for i in range(0, 101, 2): lock_odd.acquire() ...
true
03124d060da28ead6b28daa50b2b6468f7339f45
AstroHackWeek/pr_review_tutorial
/Tiwari/template/simple_functions.py
924
4.375
4
#function to calculate a Fibonacci sequence upto a given number def fibonacci(max): #define the first two numbers of the sequence values = [0, 1] #create the fibonacci sequence by adding all previous numbers to create the next number in the sequence while values[-2] + values[-1] < max: values.append...
true
9e8a5a4a78d6fd5c2fb91241509445dfba43a36a
jackson097/ISS_Tracker
/input_validation.py
1,272
4.3125
4
""" Check if the coordinate provided is a valid coordinate for the API call Parameters: type - latitude or longitude coordinate - coordinate value passed as a string Returns: boolean - True if the coordinate is valid, Else False """ def _is_valid_coordinate(type, coordinate): # Determine what the max/min coordinate...
true
ae00cbcf05d17aaf51a407129c29fdcf31118781
ethanwood2003/Code
/dads programming problems/Task2/task2-with-function.py
1,281
4.4375
4
# THe below statement uses "def" which defines a function of our own making called "isEven()" # we can then use this isEven() later in the main body of the program. def isEven(number): is_even_number = False # this initialises a boolean variable to False as we assume it's odd to start with. if int(number) % 2 == 0:...
true
e7573926bba8abaa9538cfcac1edd00e363f39ab
narsingojuhemanth/pythonlab
/right_triangle.py
282
4.3125
4
# (a^2 + b^2) == c^2 a = int(input("Length of side 1:")) b = int(input("Length of side 2:")) c = int(input("Length of side 3:")) #Determines if it's a right triangle if (a**2 + b**2) == c**2: print("It's a right triangle") else: print("It's not a right triangle")
true
f3203c895769a323491ff7c82be070ce48f5738e
narsingojuhemanth/pythonlab
/stringreverse.py
319
4.25
4
# 20. Write a Python class to reverse a string word by word. class Solution: def solve(self, s): temp = s.split(' ') temp = list(reversed(temp)) print(temp) return ' '.join(temp) ob = Solution() sentence = "Hello world, I love python programming" print(ob.solve(sentence))
true
b9a16d2a39eeeaf2e8fd70c3c759cc1200f821c0
joerlop/Sorting
/src/recursive_sorting/recursive_sorting.py
1,628
4.21875
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge( arrA, arrB ): elements = len( arrA ) + len( arrB ) merged_arr = [0] * elements # TO-DO for i in range(len(merged_arr)): if len(arrA) == 0: merged_arr[i] = arrB[0] arrB.pop(0) elif le...
true
1233a1a8a04a7296c3eebbf8568e99cccf2e3529
bsuman/BlockChain
/assignment/assignment_7.py
2,145
4.15625
4
class Food: #1) Create a Food class with a “name” and a “kind” attribute # as well as a “describe() ” method # (which prints “name” and “kind” in a sentence). def __init__(self, name, kind): self.name = name self.kind = kind #def describe(self): #print('The food has the n...
true
64b1b7f55b9e7884658d05b34849493fd1844e62
shikha1997/Interview-Preparation-codes
/Binary_tree/dncn.py
1,578
4.25
4
class Node: def __init__(self, data): self.data = data self.right = None self.left = None # Utility function to print the inorder # traversal of the tree def PrintInorderBinaryTree(root): if (root == None): return PrintInorderBinaryTree(root.left) print(str(root.data), ...
true
22c43c186b319a6cd29da32a948e6809e67a8cad
samdeanefox/tdd_class
/notestdd/_made_by_me/oop_overview.py
1,273
4.21875
4
"""OOP Overview Discuss the advantages and drawbacks of Object Oriented Programming in general and in Python """ ####################################################################### # Generalization/Specialization class Animal: def breathe(self): print('Animal is breathing') def play(self): ...
true
abccf8ed5677b5c0dcbda592e435e5fced78d579
briabar/Katas
/lambdamapfilterreduce.py
1,135
4.15625
4
def square_it(number): return number ** 2 # LAMBDA FUNCTIONS first = lambda x: 2 * x second = lambda x, y: x + y third = lambda x,y: x if x > y else y print(first(3)) print(second(3,2)) print(third(1,2)) # MAP -- APPLY SAME FUNCTION TO EACH ELEMENT OF A SEQUENCE # RETURN MODIFIED LIST numbers = [4,3,2,1] def s...
true
04ee73dcd3048479f881681552c9184c31f26f57
PENGYUXIONG/DataStructutre-Practice-python
/dataStructure/queue/doubly_linked_list_deque.py
2,448
4.15625
4
class Node: def __init__(self, data): self.data = data self.prev = self.next = None class deque: def __init__(self, capacity): self.capacity = capacity self.front = self.rear = None def size(self): size = 0 cur_node = self.front while cur_node is not None: size = size + 1 cur_node = cur_node.next...
true
5a7a074fe68fef75b7d2f07787b1e9d48c836346
PENGYUXIONG/DataStructutre-Practice-python
/dataStructure/queue/linked_list_queue.py
1,478
4.125
4
class Node: def __init__(self, data): self.data = data self.next = None class linked_list_queue: def __init__(self, capacity): self.front = self.rear = None self.capacity = capacity def size(self): size = 0 cur_node = self.front while cur_node is not None: size = size + 1 cur_node = cur_node.nex...
true
4389b67d12b2aa4c9279e43310a17698aa749f22
nthnjustice/FletcherPythonWorkshop
/Round1/Conditionals.py
2,295
4.3125
4
a = 3 b = 1 if a == 3: print "a is equal to 3" #this statement will print ########################################################################### a = 3 b = 1 if a < 3: print "a is less than 3" #this statement will NOT print elif a <= 3: print "a is less than or equal to 3" #this statement will print ####...
true
0d919371825065554dcb9f443c3971a110c30313
GaryMOnline/CiscoDevNetPF
/Dictionaries.py
595
4.34375
4
#Used to add Dictionary Info dict = {"apples":5,"pears":12,"bananas":92} print dict #get length of Dictionary print ("Dict is {} long".value(len(dict))) #Add Value to dictiionary print "\nAdd Value to Dictionary" dict["strawberrys"]=32 print dict #Remove value from dictionary print "\nRemove Value from Dictionary" ...
true
13d1b61b1c29f2955ae55458c3795046e9cd31ce
YashSaxena75/GME
/dice.py
422
4.25
4
import random print("So let us play another game,So are You ready!!!!") input("Press Enter if you are ready") die1=random.randint(1,6) #random.randrange() generates number between 0-5 so if I add 1 then the numbers will become (1-6) #if you want to start from 0 then use random.randrange() die2=random.randint(1,6) t...
true
93854c23681f3a0baceb9ce0383b6120af2820a4
sunilkumarc/LearnPython
/day6/example9.py
475
4.21875
4
# Write a function which takes first_name and last_name as arguments # and return True if full name is 'Sunil Kumar' # otherwise return False def correct_name(first_name, last_name): if first_name == 'Sunil' and last_name == 'Kumar': return True return False def correct_name_2(first_name, last_name): ...
true
a952d60f39b1ad6cd9b3ef923664a0cacb9d87ab
sunilkumarc/LearnPython
/day21/class.py
1,897
4.4375
4
''' 1. create employees 2. update employees with new salary 3. assign a computer to an employee ''' ''' Object Oriented Programming: ============================ - Python is a OOP language C, C++, Java, JavaScript, Python OOP: Python, Java, C++ Functional/Procedural: C, Scala ''' ''' Instead of using functions we w...
true
b00eec47f89547b0ec7c80113aa08f9320c8a908
wanghan79/2020_Master_Python
/2019102938梁梦瑶/FunctionExample.py
1,912
4.21875
4
##!/usr/bin/python3 """ Author: liangmengyao Purpose: Function Example Created: 4/18/2020 """ import random import string def dataSampling(datatype, datarange, num, strlen=6): # 固定参数;可变参数arg*;默认参数;关键字参数**kwargs ''' :Description: function... :param datatype: input the type of data :param datarang...
true
00f4a82b39204779596c1b0a060a311c1a1d182b
ksaubhri12/ds_algo
/practice_450/binary_tree/13_check_tree_balanced_or_not.py
1,785
4.125
4
# Do three things in recursive manner # check if left portion is valid and return the height # check if right portion is valid and return the height # now check the diff between height is less than or equal to one and also check if the left and right portion is valid # or not. If the height diff is okay and left and ri...
true
8b47bd7cb699a728630e861bde2372622b4c71b3
charlenecalderon/Girls_Who_Code
/carnival.py
1,999
4.375
4
print("Welcome to The Carnival!") print("BIG RIDES ARE 7 TICKETS (bumper cars, carousel)") print("SMALL RIDES ARE 3 TICKETS (slide, train ride)") print("You have 15 tickets to spend.") choosingRide = True tickets = 15 while choosingRide == True: print("Which ride would you like go on?") ...
true
7221bd81ec2b1e1395bab53f7f1a25731cc5a515
bea03/learnpythonhardway3
/ex20.py
982
4.125
4
#ex20 functions files #this line allows us to use argv (variables in script line) from sys import argv #this line assigns argv script, input_file = argv #this line defines a function called print_all() that takes in an arg f def print_all(f): #this line prints what is passed into print_all by reading the file ...
true
1abcf2eaa0e8d7c7781697cb320a3fcc53eedd50
andbra16/CSF
/F13/homework6/hw6.py
1,964
4.3125
4
# Name: Brandon Anderson # Evergreen Login: andbra16 # Computer Science Foundations # Programming as a Way of Life # Homework 6 # You may do your work by editing this file, or by typing code at the # command line and copying it into the appropriate part of this file when # you are done. When you are done, running thi...
true
7318bec8ea515888fe26cb33f21bd1a0c26b5f05
asadrazaa1/Python-Practice
/tuple_operations_everything_recursive.py
516
4.1875
4
tup1 = ("11", "12", "13", "14", "15") tup2 = (1, 2, 3, 4, 5) tup3 = 'a', 'b', 'c', 'd', 'e' #empty tuple is written with empty parantheses tuple = () #for a single valued tuple, you have to add a comma after the element tup4 = (20, ) #acessing values within the tuple print(tup1[0]) print(tup1[1:4]) print(tup1[:3]) #...
true
39a0126c4dcad38eebb2ed87d48229e513290698
Wojtek001/Dictionary-for-a-little-programmer-
/dictionary_done.py
2,152
4.21875
4
import sys import csv import os def main(): with open("dictionary.csv", mode='r') as infile: reader = csv.reader(infile) my_dict = {rows[0]: (rows[1], rows[2]) for rows in reader} os.system('clear') print('Dictionary for a little programmer:') print('1 - search explanation by appell...
true
a8f28d8ff664a6b70e96bb10f84edd44be0d2704
burke3601/Digital-Crafts-Classes
/medium_exercises/coins.py
335
4.25
4
coins = 0 print(f"You have {coins} coins.") more = input("would you like another coin? yes or no \n") while more == "yes": coins += 1 print(f"You have {coins} coins.") more = input("would you like another coin? yes or no \n") if more == "no": coins == coins print("bye.") # not sure why this is ...
true
85e910db7967241f540ed3d3fd88e508341aa1fa
burke3601/Digital-Crafts-Classes
/small-exercises/hello2.py
210
4.15625
4
name = str(input("WHAT IS YOUR NAME?\n")) number = len(name) print(f"Hello your name is {name.upper}") print(f"Your name has {number} letters in it! Awesome!") # not sure why this isn't returning upper case
true
ab50abbc1aaf2ef28251cde266ff7bbf8b2f8af5
juggal/99problems
/p04.py
646
4.28125
4
# Find the number of elements of a list from linked_list.sll import sll def count_elements(ll): """ calculate length of linked list Parameters ---------- ll: sll linked list on which to be operated on Returns ------- int length of linked list """ curr = ll.he...
true
fe2a6a6318f8c509a9e7ffaed6332cab63036b61
Asunqingwen/LeetCode
/easy/Height Checker.py
1,204
4.375
4
# -*- coding: utf-8 -*- # @Time : 2019/8/23 0023 9:37 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Height Checker.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ Students are asked to stand in non-decreasing order of heights fo...
true
1944be3fbcd30de7259ba49b9f82c2c7d769083f
Asunqingwen/LeetCode
/medium/Print FooBar Alternately.py
2,523
4.46875
4
# -*- coding: utf-8 -*- # @Time : 2019/9/2 0002 16:39 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Print FooBar Alternately.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ Suppose you are given the following code: class FooBar...
true
d340ab735fcd78494df1ba2df13ce3bf7102e16f
Asunqingwen/LeetCode
/easy/Word Pattern.py
1,014
4.375
4
# -*- coding: utf-8 -*- # @Time : 2019/8/29 0029 15:32 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Word Pattern.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ Given a pattern and a string str, find if str follows the same patt...
true
3f69de1e48f7729f90ca74fe5f75b98e00584c10
Asunqingwen/LeetCode
/easy/Largest Perimeter Triangle.py
980
4.1875
4
# -*- coding: utf-8 -*- # @Time : 2019/10/9 0009 9:48 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Largest Perimeter Triangle.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ Given an array A of positive lengths, return the large...
true
ccf914675bb33ca164414b3b9913ca45fa5073d0
Asunqingwen/LeetCode
/easy/Jewels and Stones.py
1,034
4.125
4
# -*- coding: utf-8 -*- # @Time : 2019/8/13 0013 14:58 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Jewels and Stones.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ You're given strings J representing the types of stones that ...
true
ef581fc5fdec8061ca47abeff0c4d9add1e76622
Asunqingwen/LeetCode
/easy/Ugly Number.py
1,604
4.375
4
# -*- coding: utf-8 -*- # @Time : 2019/9/19 0019 10:20 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Ugly Number.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ Write a program to check whether a given number is an ugly number. ...
true
dc23b3b72329168a7168779480589df6a625c786
Asunqingwen/LeetCode
/easy/Armstrong Number.py
897
4.34375
4
# -*- coding: utf-8 -*- # @Time : 2019/10/22 0022 17:29 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Armstrong Number.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ The k-digit number N is an Armstrong number if and only if the...
true
ad7c1cefea6607deeef015dbd2ea630df92794d7
Asunqingwen/LeetCode
/medium/Bulb Switcher II.py
1,101
4.15625
4
# -*- coding: utf-8 -*- # @Time : 2019/9/18 0018 9:07 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Bulb Switcher II.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ There is a room with n lights which are turned on initially and ...
true
115b8c6a3d4839acce2b3b720f9854f83499a864
Asunqingwen/LeetCode
/easy/Reverse String II.py
1,029
4.3125
4
# -*- coding: utf-8 -*- # @Time : 2019/9/17 0017 10:52 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: Reverse String II.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ Given a string and an integer k, you need to reverse the first...
true
66d868b1c698beceb3ca2bcecbb60d823984748b
Asunqingwen/LeetCode
/medium/3Sum Closest.py
1,144
4.125
4
# -*- coding: utf-8 -*- # @Time : 2019/9/19 0019 14:27 # @Author : 没有蜡笔的小新 # @E-mail : sqw123az@sina.com # @FileName: 3Sum Closest.py # @Software: PyCharm # @Blog :https://blog.csdn.net/Asunqingwen # @GitHub :https://github.com/Asunqingwen """ Given an array nums of n integers and an integer target, find three...
true