blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
c46f2637edea6f94adff6a8e93f78bd858d94fc1
jjspetz/digitalcrafts
/py-exercises2/make-a-box.py
327
4.15625
4
# makes a box of user inputed hieght and width # gets user input height = int(input("Enter a height: ")) width = int(input("Enter a width: ")) # calculate helper variables space = width - 2 for j in range(height): if j == 0 or j == height - 1: print("*" * width) else: print("*" + (" "*space) ...
true
5c9ff36d6710c334e72abc5b9b58abc8a94758bd
jjspetz/digitalcrafts
/dict-exe/error_test.py
343
4.125
4
#!/usr/bin/env python3 def catch_error(): while 1: try: x = int(input("Enter an integer: ")) except ValueError: print("Enter an integer!") except x == 3: raise myError("This is not an integer!") else: x += 13 if __name__ == "__main...
true
4bdd9011b451281cdd9b3c8d4c3abbe730f9358f
kusaurabh/CodeSamples
/python_samples/check_duplicates.py
672
4.25
4
#!/usr/bin/python3 import sys def check_duplicates(items): list_items = items[:] list_items.sort() prev_item = None for item in list_items: if prev_item == item: return True else: prev_item = item return False def create_unique_list(items)...
true
a5a46c8dbaaf4c4ceee25803e0cca585d74eb883
pseudomuto/sudoku-solver
/Python/model/notifyer.py
1,164
4.125
4
class Notifyer(object): """A simple class for handling event notifications""" def __init__(self): self.listeners = {} def fireEvent(self, eventName, data = None): """Notifies all registered listeners that the specified event has occurred eventName: The name of the event being fired data: An optional param...
true
3e925a8f0736eec9688f3597502d77f249c05e08
annapaula20/python-practice
/functions_basic2.py
2,510
4.4375
4
# Countdown - Create a function that accepts a number as an input. # Return a new list that counts down by one, from the number (as the 0th element) down to 0 (as the last element). # Example: countdown(5) should return [5,4,3,2,1,0] def countdown(num): nums_list = [] for val in range(num, -1, -1): nums...
true
607e0ba035eaa2dc9216f0884c1562036797ba79
Jagadeesh-Cha/datamining
/comparision.py
487
4.28125
4
# importing the required module import matplotlib.pyplot as plt # x axis values x = [1,2,3,4,5,6,7,8,9,10] # corresponding y axis values y = [35,32,20,14,3,30,6,20,2,30] # plotting the points plt.plot(x, y) # naming the x axis plt.xlabel('busiest places in descending-order') # naming th...
true
b4816526ef6cc323464ac3e9f787a6032e32072f
lilimonroy/CrashCourseOnPython-Loops
/q1LoopFinal.py
507
4.125
4
#Complete the function digits(n) that returns how many digits the number has. For example: 25 has 2 digits and 144 has 3 digits. # Tip: you can figure out the digits of a number by dividing it by 10 once per digit until there are no digits left. def digits(n): count = 0 if n == 0: return 1 while (n > 0): cou...
true
0ca00b26b0774c6e0d1891fca4567889cc657a01
Mmingo28/Week-3
/Python Area and Radius.py
263
4.28125
4
#MontellMingo #1/30/2020 #The program asks if the user can compute the area of an circle and the radius. radius = int(input("what is the radius")) #print("what is the number of the radius"+ ) print("what is the answer") print(3.14*radius*radius)
true
8fbfcc3bcd13f2db5c6178cd7ed40f9eade923fc
xywgo/Learn
/LearnPython/Chapter 10/addition.py
372
4.1875
4
while True: try: number1 = input("Please enter a number:(enter 'q' to quit) ") if number1 == 'q': break number1 = int(number1) number2 = input("Please enter another number:(enter 'q' to quit) ") if number2 == 'q': break number2 = int(number2) except ValueError: print("You must enter a number") ...
true
d025ef9b5f54fb004dc8ed67b652469566c92754
davidadamojr/diary_of_programming_puzzles
/arrays_and_strings/has_zero_triplets.py
1,089
4.1875
4
""" Given an array of integers that do not contain duplicate values, determine if there exists any triplets that sum up to zero. For example, L = [-3, 2, -5, 8, -9, -2, 0, 1] e = {-3, 2, 1} return true since e exists This solution uses a hash table to cut the time complexity down by n. Time complexity: O(n^2) Spac...
true
31966a029427f2de3759a8af889481c05e30339a
davidadamojr/diary_of_programming_puzzles
/arrays_and_strings/three_sum_closest.py
1,284
4.34375
4
""" Given an array "nums" of n integers and an integer "target", find three integers in nums such that the sum is closest to "target". Return the sum of the three integers. You may assume that each input would have exactly one solution. Example: Given array nums = [-1, 2, 1, -4], and target = 1. The sum that is closes...
true
a7ad18871194654ee4d1cf04e1264b670df3d204
davidadamojr/diary_of_programming_puzzles
/arrays_and_strings/toeplitz_matrix.py
1,212
4.46875
4
""" A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given an MxN matrix, return True if and only if the matrix is Toeplitz. Example 1: Input: matrix = [[1, 2, 3, 4], [5, 1, 2, 3], [9, 5, 1, 2]] Output: True Explanation: 1234 5123 9512 In the above grid, the diagonals ar...
true
895e80acf9eed3e1b580a9ac4dec51eb295e7319
davidadamojr/diary_of_programming_puzzles
/sorting_and_searching/find_in_rotated_array.py
1,653
4.21875
4
""" Given a sorted array of n integers that has been rotated an unknown number of times, write code to find an element in the array. You may assume that the array was originally sorted in increasing order. """ def find_in_rotated(key, rotated_lst, start, end): """ fundamentally binary search... Either t...
true
46a081380aa96ceaf062d72e0101881f8d57a08c
davidadamojr/diary_of_programming_puzzles
/bit_manipulation/hamming_distance.py
1,025
4.3125
4
""" The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers num1 and num2, calculate the Hamming distance. https://leetcode.com/problems/hamming-distance/ """ # @param num1 integer # @param num2 integer def hamming_distance(num1, num2): ...
true
1ebdbdafcc3dadabe48676ca0dbda76cdb3181d8
davidadamojr/diary_of_programming_puzzles
/misc/convert_to_hexadecimal.py
1,658
4.75
5
""" Given an integer, write an algorithm to convert it to hexadecimal. For negative integers, two's complement method is used. Note: 1. All letters in hexadecimal (a-f) must be in lowercase. 2. The hexadecimal string must not contain extra leading 0s. If the number is zero, it is represented by a single zero character...
true
a6673418628269bdac32de4aaa469fc9ea6b8239
davidadamojr/diary_of_programming_puzzles
/arrays_and_strings/integer_to_string.py
952
4.6875
5
""" Write a routine to convert a signed integer into a string. """ def integer_to_string(integer): """ Writes the string backward and reverses it """ if integer < 0: is_negative = True integer = -integer # for negative integers, make them positive else: is_negative = False...
true
e114ca362bb69f5298c5137696ee4aaffec569ad
davidadamojr/diary_of_programming_puzzles
/mathematics_and_probability/intersect.py
931
4.125
4
""" Given two lines on a Cartesian plane, determine whether the two lines would intersect. """ class Line: def __init__(self, slope, yIntercept): self.slope = slope self.yIntercept = yIntercept def intersect(line1, line2): """ If two different lines are not parallel, then they intersect...
true
76e8af6b3ef66bce39724bd917d84150361c139e
davidadamojr/diary_of_programming_puzzles
/arrays_and_strings/excel_sheet_column_title.py
662
4.15625
4
""" Given a positive integer, return its corresponding column title as it appears in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB """ def convert_to_title(num): integer_map = {} characters = "ZABCDEFGHIJKLMNOPQRSTUVWXY" for i in range(0, 26): integer_map[i] = c...
true
332acd1b09be1ad4bdea876a5f3f82633319c7bc
cryojack/python-programs
/charword.py
402
4.34375
4
# program to count words, characters def countWord(): c_str,c_char = "","" c_str = raw_input("Enter a string : ") c_char = c_str.split() print "Word count : ", len(c_char) def countChar(): c_str,c_char = "","" charcount_int = 0 c_str = raw_input("Enter a string : ") for c_char in c_str: if c_char is not " "...
true
2c12b700e72b2cd155a8dca90a3e2389106eed3f
koenigscode/python-introduction
/content/partials/comprehensions/list_comp_tern.py
311
4.25
4
# if the character is not a blank, add it to the list # if it already is an uppercase character, leave it that way, # otherwise make it one l = [c if c.isupper() else c.upper() for c in "This is some Text" if not c == " "] print(l) # join the list and put "" (nothing) between each item print("".join(l))
true
22e20f3364f8498766caf17e4dc8b967ef217f5b
BMariscal/MITx-6.00.1x
/MidtermExam/Problem_6.py
815
4.28125
4
# Problem 6 # 15.0/15.0 points (graded) # Implement a function that meets the specifications below. # def deep_reverse(L): # """ assumes L is a list of lists whose elements are ints # Mutates L such that it reverses its elements and also # reverses the order of the int elements in every element of L. #...
true
73e4c51440c5d6da38f297556843c0173f0153ee
alexhong33/PythonDemo
/PythonDemo/Day01/01print.py
1,140
4.375
4
#book ex1-3 print ('Hello World') print ("Hello Again") print ('I like typing this.') print ('This is fun.') print ('Yay! Printing.') print ("I'd much rather you 'not'.") print ('I "said" do not touch this.') print ('你好!') #print ('#1') # A comment, this is so you can read your program later. # A...
true
41af103a812a599e376b79251c7f1c76a01fe914
KevinOluoch/Andela-Labs
/missing_number_lab.py
787
4.4375
4
def find_missing( list1, list2 ): """When presented with two arrays, all containing positive integers, with one of the arrays having one extra number, it returns the extra number as shown in examples below: [1,2,3] and [1,2,3,4] will return 4 [4,66,7] and [66,77,7,4] will return 77 """ ...
true
b2875d7737c5fd6cc06a5299f9f8c888c93bebb8
byhay1/Practice-Python
/Repl.it-Practice/forloops.py
1,856
4.71875
5
#-------- #Lets do for loops #used to iterate through an object, list, etc. # syntax # my_iterable = [1,2,3] # for item_name in my_iterable # print(item_name) # KEY WORDS: for, in #-------- #first for loop example mylist = [1,2,3,4,5,6,7,8,9,10] #for then variable, you chose the variable print('\n') for num in m...
true
29d08b7acb73e2baeb8a2daf67be103e1ad302fc
byhay1/Practice-Python
/Repl.it-Practice/tuples.py
828
4.1875
4
#------------ #tuples are immutable and similar to list #FORMAT of a tuple == (1,2,3) #------------ # create a tuple similar to a list but use '()' instead of '[]' #define tuple t = (1,2,3) t2 = ('a','a','b') mylist = [1,2,3] #want to find the class type use the typle function type(PUTinVAR) print('',"Find the type o...
true
4f3e7af26400a2f4c309cffa69d5a6f874819731
byhay1/Practice-Python
/Repl.it-Practice/OOPattributeClass.py
2,069
4.5
4
#---------- # Introduction to OOP: # Attributes and Class Keywords # #---------- import math mylist = [1,2,3] myset = set() #built in objects type(myset) type(list) ####### #define a user defined object #Classes follow CamelCasing ####### #Do nothing sample class class Sample(): pass #set variable to class my_sa...
true
eef86cb4c54bf7d0b38ced84acff83220b0304e3
jongwlee17/teampak
/Python Assignment/Assignment 5.py
988
4.34375
4
""" Exercise 5: Take two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] and write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your program works on two lists...
true
3061d9515b321d746e69674f44b9550ae0e6f151
ankitoct/Core-Python-Code
/40. List/6. AppendMethod.py
222
4.125
4
# Append Method a = [10, 20, -50, 21.3, 'Geekyshows'] print("Before Appending:") for element in a: print (element) # Appending an element a.append(100) print() print("After Appending") for element in a: print (element)
true
0a064e70245373690e15b0a00b36ee1f2ba76c8d
ankitoct/Core-Python-Code
/45. Tuple/6. tupleModification.py
585
4.125
4
# Modifying Tuple a = (10, 20, -50, 21.3, 'GeekyShows') print(a) print() # Not Possible to Modify like below line #a[1] = 40 # Show TypeError # It is not possible to modify a tuple but we can concate or slice # to achieve desired tuple # By concatenation print("Modification by Concatenation") b = (40, 50) tup1 = a...
true
a60165af0986981ea6097e34278a844d9b9b2f70
MirandaTowne/Python-Projects
/grade_list.py
754
4.46875
4
# Name: Miranda Towne # Description: Creating a menu that gives user 3 choices # Empty list grade = [] done = False new_grade = '' # Menu options menu = """ Grade Book 0: Exit 1: Display a sorted list of grades 2: Add a grade to the list """ # Display menu at start of a while loop while not done: ...
true
bffb8076b777e4962c687e0f9c790b5fafc93041
Silentsoul04/2020-02-24-full-stack-night
/1 Python/solutions/unit_converter.py
697
4.25
4
def convert_units(data): conversion_factors = { 'ft': 0.3048, 'mi': 1609.34, 'm': 1, 'km': 1000, 'yd': 0.9144, 'in': 0.0254, } value, unit_from, unit_to = data converted_m = conversion_factors[unit_from] * value return round(converted_m / conversi...
true
63756dbda9070dd378118718383a7dbebcc469d9
haaks1998/Python-Simple
/07. function.py
1,011
4.1875
4
# A function is a set of statements that take inputs, do some specific computation and returns output. # We can call function any number of times through its name. The inputs of the function are known as parameters or arguments. # First we have to define function. Then we call it using its name. # format: # def ...
true
1520b9faa5b957da64ea48e158adacc0e5987adf
pixeltk623/python
/Core Python/Datatypes/string.py
478
4.28125
4
# Strings # Strings in python are surrounded by either single quotation marks, or double quotation marks. # 'hello' is the same as "hello". # You can display a string literal with the print() function: # print("Hello") # print('Hello') # a = "hello" # print(a) # a = """cdsa # asdasdas # asdasdassdasd # asdasdsa""...
true
4b3f9e149707817aefa696ce2d336453cd93f34a
undergraver/PythonPresentation
/05_financial/increase.py
766
4.125
4
#!/usr/bin/env python import sys # raise in percent raise_applied=6 raise_desired=40 # we compute: # # NOTE: the raise is computed annually # # 1. the number of years to reach the desired raise with the applied raise # 2. money lost if the desired raise is applied instantly and no other raise is done salary_now=100...
true
6a293c64aabc496cc4e1669935d1659dc1042c39
Kjartanl/TestingPython
/TestingPython/Logic/basic_logic.py
368
4.21875
4
stmt = True contradiction = False if(stmt): print("Indeed!") if(contradiction): print("Still true, but shouldn't be! Wtf?") else: print("I'm afraid I'm obliged to protest!") print("------- WHILE LOOP ---------") number = 0 while(number < 5): print("Nr is %s" %number) number = num...
true
0e07914cfa997c6ee2bef28123972e089f49b454
montaro/algorithms-course
/P0/Task4.py
1,234
4.125
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 4: The telephone company want to i...
true
d3eb57ca3377dcb7462afd86e43997a1f220e940
shivanshutyagi/python-works
/primeFactors.py
566
4.3125
4
def printPrimeFactors(num): ''' prints primeFactors of num :argument: number whose prime factors need to be printed :return: ''' for i in range(2, num+1): if isPrime(i) and num%i==0: print(i) def isPrime(num): ''' Checks if num is prime or not :param num: :r...
true
a89ba3ea381c392845379d369981fca1a0a16d1b
roberg11/is-206-2013
/Assignment 2/ex13.py
1,150
4.4375
4
from sys import argv script, first, second, third = argv print "The script is called:", script print "Your first variable is:", first print "Your second variable is:", second print "Your third variable is:", third ## Combine raw_input with argv to make a script that gets more input ## from a user. fruit = raw_inpu...
true
c232410e848da610102a0a08b4077aa2295847b0
roberg11/is-206-2013
/Assignment 2/ex20.py
1,803
4.53125
5
from sys import argv script, input_file = argv # Definition that reads a file given to the parameter def print_all(f): print f.read() # Definition that 'seeks' to the start of the file (in bytes) given to parameter # The method seek() sets the file's current position at the # offset. The whence argument is optio...
true
676817b23e15e5368746b750f48e518427c937ae
onerbs/w2
/structures/w2.py
1,914
4.28125
4
from abc import ABC, abstractmethod from typing import Iterable from structures.linked_list_extra import LinkedList class _Linear(ABC): """Abstract linear data structure.""" def __init__(self, items: Iterable = None): self._items = LinkedList(items) def push(self, item): """Adds one item...
true
7f7b411883c7f6985a354f163a11da1a879b0cac
nishaagrawal16/Datastructure
/Python/decorator_for_even_odd.py
1,363
4.21875
4
# Write a decorator for a function which returns a number between 1 to 100 # check whether the returned number is even or odd in decorator function. import random def decoCheckNumber(func): print ('Inside the decorator') def xyz(): print('*************** Inside xyz *********************') num =...
true
aa5bc400ed332b046f45db6233975294afa48494
nishaagrawal16/Datastructure
/Linklist/partition_a_link_list_by_a_given_number.py
2,555
4.125
4
#!/usr/bin/python # Date: 2018-09-17 # # Description: # There is a linked list given and a value x, partition a linked list such that # all element less x appear before all elements greater than x. # X should be on right partition. # # Like, if linked list is: # 3->5->8->5->10->2->1 and x = 5 # # Resultant linked list...
true
bf13df5bf072797b535624bca57f87f5f5c7b39c
nishaagrawal16/Datastructure
/sorting/bubble_sort.py
1,314
4.6875
5
# Date: 20-Jan-2020 # https://www.geeksforgeeks.org/python-program-for-bubble-sort/ # Bubble Sort is the simplest sorting algorithm that works by # repeatedly swapping the adjacent elements if they are in wrong order. # Once the first pass completed last element will be sorted. # On next pass, we need to compare till l...
true
da785b4c17fbed0a35787f7db82ee578ffaf07bf
nishaagrawal16/Datastructure
/Python/overriding.py
2,643
4.46875
4
# Python program to demonstrate error if we # forget to invoke __init__() of parent. class A(object): a = 1 def __init__(self, n = 'Rahul'): print('A') self.name = n class B(A): def __init__(self, roll): print('B') self.roll = roll ...
true
fee51facfda5df96e5aa73eaf6f7d3962df39c2c
cherkesky/urbanplanner
/city.py
762
4.59375
5
''' In the previous Urban Planner exercise, you practices defining custom types to represent buildings. Now you need to create a type to represent your city. Here are the requirements for the class. You define the properties and methods. Name of the city. The mayor of the city. Year the city was established. A collect...
true
8da1b3e55c7d3c0f941d28d2395c1e1d353be217
spikeyball/MITx---6.00.1x
/Week 1 - Problem 3.py
1,002
4.125
4
# Problem 3 # 15.0/15.0 points (graded) # Assume s is a string of lower case characters. # # Write a program that prints the longest substring of s in which the letters # occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your # program should print # # Longest substring in alphabetical order is: ...
true
832de19c8b9ab75f412d3f0ebc57f6791bc0d15f
Kpsmile/Learn-Python
/Basic_Programming/Collections.py
1,580
4.53125
5
a = [3, 6, 8, 2, 78, 1, 23, 45, 9] print(sorted(a)) """ Sorting a List of Lists or Tuples This is a little more complicated, but still pretty easy, so don't fret! Both the sorted function and the sort function take in a keyword argument called key. What key does is it provides a way to specify a function that return...
true
50febd52f27da540cc858944a37969ed932090c6
surya-lights/Python_Cracks
/math.py
293
4.15625
4
# To find the highest or lowest value in an iteration x = min(5, 10, 25) y = max(5, 10, 25) print(x) print(y) # To get the positive value of specified number using abs() function x = abs(-98.3) print(x) # Return the value of 5 to the power of 4 is (same as 5*5*5*5): x = pow(5, 4) print(x)
true
f8bbfd6363010700b233934b7392629138d29e66
sanazjamloo/algorithms
/mergeSort.py
1,395
4.4375
4
def merge_sort(list): """ Sorts a list in ascending order Returns a new sorted List Divide: Find the midpoint of the list and divide into sublists Conquer: Recursively sort the sublists created in previous step Combine: Merge the sorted sublists created in previous step Takes O(n log n) time...
true
73631147ca4cc0322de2a68a36290502ee230907
ytgeng99/algorithms
/Pythonfundamentals/FooAndBar.py
1,040
4.25
4
'''Write a program that prints all the prime numbers and all the perfect squares for all numbers between 100 and 100000. For all numbers between 100 and 100000 test that number for whether it is prime or a perfect square. If it is a prime number print "Foo". If it is a perfect square print "Bar". If it is neither prin...
true
44a002f5ed28792f31033331f79f49b24d6bc3ef
ytgeng99/algorithms
/Pythonfundamentals/TypeList.py
1,320
4.375
4
'''Write a program that takes a list and prints a message for each element in the list, based on that element's data type. Your program input will always be a list. For each item in the list, test its data type. If the item is a string, concatenate it onto a new string. If it is a number, add it to a running sum. At t...
true
c8bc084cc06c30404dbb8d5cd6653dd74d007405
KatePavlovska/python-laboratory
/laboratory1&2update/Lab2_Task2_calculation_pavlovska_km_93.py
640
4.25
4
print("Павловська Катерина. КМ-93. Варіант 14. ") print("Task2: Given an integer N (> 0), which is a degree of 2: N = 2K. Finding an integer K is an exponent of this degree.") print() import re re_integer = re.compile("^[-+]?\d+$") def validator(pattern, promt): text = input(promt) while not bool...
true
21a2fbe709284990b8d486f7aabd79ddc269d4bf
AlexChesser/CIT590
/04-travellingsalesman/cities.py
2,041
4.28125
4
def read_cities(file_name) """Read in the cities from the given file_name, and return them as a list of four-tuples: [(state, city, latitude, longitude), ...] Use this as your initial road_map, that is, the cycle Alabama → Alaska → Arizona → ... → Wyoming → Alabama.""" pass def print_cities(road_map...
true
40db83e086d8857643c10447811873e55740797b
kajalubale/PythonTutorial
/While loop in python.py
535
4.34375
4
############## While loop Tutorial ######### i = 0 # While Condition is true # Inside code of while keep runs # This will keep printing 0 # while(i<45): # print(i) # To stop while loop # update i to break the condition while(i<8): print(i) i = i + 1 # Output : # 0 # 1 # 2 # 3 # 4 #...
true
a991a9d07955fe00dad9a2b46fd32503121249e8
kajalubale/PythonTutorial
/For loop in python.py
1,891
4.71875
5
################### For Loop Tutorial ############### # A List list1 = ['Vivek', 'Larry', 'Carry', 'Marie'] # To print all elements in list print(list1[0]) print(list1[1]) print(list1[2]) print(list1[3]) # Output : # Vivek # Larry # Carry # Marie # We can do same thing easily using for loop # for ...
true
2a3ca27dd93b4c29a43526fa2894f79f38280b82
kajalubale/PythonTutorial
/41.join function.py
971
4.34375
4
# What is the join method in Python? # "Join is a function in Python, that returns a string by joining the elements of an iterable, # using a string or character of our choice." # In the case of join function, the iterable can be a list, dictionary, set, tuple, or even a string itself. # The string that separates...
true
060eb25956088487b27ab6fe31077f73b6691857
mondler/leetcode
/codes_python/0006_ZigZag_Conversion.py
1,866
4.15625
4
# 6. ZigZag Conversion # Medium # # 2362 # # 5830 # # Add to List # # Share # The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) # # P A H N # A P L S I I G # Y I R # And then read line by...
true
4decf52cae21f429395dbb079c3bada56f7bf326
basu-sanjana1619/python_projects
/gender_predictor.py
683
4.21875
4
#It is a fun program which will tell a user whether she is having a girl or a boy. test1 = input("Are you craving spicy food? (Y/N) :") test2 = input("Are you craving sweets? (Y/N) :") test3 = input("Are you suffering from extreme morning sickeness or hyperemesis (Y/N) :") test4 = input("Is the baby's heart rate abov...
true
9d77a0ee4b5f9d90d48c67fcc19a686f6cb3b508
cookcodeblog/python_work
/ch07/visit_poll.py
543
4.125
4
# 7-10 Visit Poll visit_places = {} poll_active = True while poll_active: name = input("What is your name? ") place = input("If you could visit one place in the world, where would you go? ") visit_places[name] = place # It is like map.put(key, value) repeat = input("Would you like to let another perso...
true
bdeab6a046d4236f6dd006dd5c44bdcdf62bf029
amigojapan/amigojapan.github.io
/8_basics_of_programming/fruits.py
580
4.71875
5
fruits=["banana","apple","peach","pear"] # create a list print(fruits[0]) # print first element of list print(fruits[3]) # print last element print("now reprinting all fruits") for fruit in fruits: # loops thru the fruits list and assigns each values to th> print(fruit) # prints current "iteration" of the fruit pri...
true
c087789647cad25fc983acd3bfceee19ab0a507f
Narfin/test_push
/controlFlows.py
636
4.28125
4
# if, elif, else def pos_neg(n): """Prints whether int n is positive, negative, or zero.""" if n < 0: print("Your number is Negative... But you already knew that.") elif n > 0: print("Your number is super positive! How nice.") else: print("Zero? Really? How boring.") my_num =...
true
e80688442c643ed05976d0b872cffb33b1c3c054
Minashi/COP2510
/Chapter 5/howMuchInsurance.py
301
4.15625
4
insurance_Factor = 0.80 def insurance_Calculator(cost): insuranceCost = cost * insurance_Factor return insuranceCost print("What is the replacement cost of the building?") replacementCost = float(input()) print("Minimum amount of insurance to buy:", insurance_Calculator(replacementCost))
true
039b84d58b8410e1017b71395ac44082e19323ec
milolou/pyscript
/stripMethod.py
1,756
4.65625
5
# Strip function. '''import re print('You can strip some characters by strip method,\n just put the characters you want to strip in the parenthese\n followed function strip') print('Please input the text you wanna strip.') text = input() print('Please use the strip function.') def strip(string): preWhiteSpace = ...
true
d00c5dd8c996aaed2784a30a925122bee2a4ac9d
rafaeljordaojardim/python-
/basics/exceptions.py
1,891
4.25
4
# try / Except / Else / Finally for i in range(5): try: print(i / 0) except ZeroDivisionError as e: print(e, "---> division by 0 is not allowed") for i in range(5): try: print(i / 0) except NameError: # it doesn't handle ZeroDivisionError print("---> division by 0 is no...
true
7521cbf4b76c785fe8d0b78e837fba5cdf41cce1
evanlihou/msu-cse231
/clock.py
1,436
4.4375
4
""" A clock class. """ class Time(): """ A class to represent time """ def __init__(self, __hour=0, __min=0, __sec=0): """Constructs the time class. Keyword Arguments: __hour {int} -- hours of the time (default: {0}) __min {int} -- minutes of the time...
true
f5d77a708522b6febacc4c1e43704d1c63a2d07d
evanlihou/msu-cse231
/proj01.py
1,123
4.3125
4
########################################################### # Project #1 # # Algorithm # Prompt for rods (float) # Run conversions to other units # Print those conversions ########################################################### # Constants ROD = 5.0292 # meters FURLONG = 40 # rods MILE = 1609.34 # me...
true
4fc1e7a055c830baa4ea154de82a4568a60b3bdf
alicevillar/python-lab-challenges
/conditionals/conditionals_exercise1.py
1,058
4.46875
4
####################################################################################################### # Conditionals - Lab Exercise 1 # # Use the variable x as you write this program. x will represent a positive integer. # Write a program that determines if x is between 0 and 25 or ...
true
56870e9f3f322e09042d9e10312ed054fa033fa2
rghosh96/projecteuler
/evenfib.py
527
4.15625
4
#Define set of numbers to perform calculations on userRange = input("Hello, how many numbers would you like to enter? ") numbers = [0] * int(userRange) #print(numbers) numbers[0] = 0 numbers[1] = 1 x = numbers[0] y = numbers[1] i = 0 range = int(userRange) #perform fibonacci, & use only even values; add sums sum ...
true
3c21bd12834e39d8fd1c53bb5d9885c2cc75a360
biniama/python-tutorial
/lesson6_empty_checks_and_logical_operators/logical_operators.py
490
4.1875
4
def main(): students = ["Kidu", "Hareg"] name = input("What is your name? ") if name not in students: print("You are not a student") else: print("You are a student") # if name in students: # print("You are a student") # else: # print("You are not a student") ...
true
bac2a9c57de523788893acc83ddfb37a2e10ce0d
biniama/python-tutorial
/lesson2_comment_and_conditional_statements/conditional_if_example.py
1,186
4.34375
4
def main(): # Conditional Statements( if) # Example: # if kidu picks up her phone, then talk to her # otherwise( else ) send her text message # Can be written in Python as: # if username is ‘kiduhareg’ and password is 123456, then go to home screen. # else show error message # Conditio...
true
62ac86c00c6afcbb16dcc58a1a12bc426070001a
aiperi2021/pythonProject
/day_4/if_statement.py
860
4.5
4
# Using true vs false is_Tuesday = True is_Friday = True is_Monday = False is_Evening = True is_Morning = False if is_Monday: print("I have python class") else: print("I dont have python class") # try multiple condition if is_Friday or is_Monday: print("I have python class") else: print("I dont have p...
true
f6c60e2110d21c44f230ec710f3b74631b772195
aiperi2021/pythonProject
/day_7/dictionar.py
298
4.3125
4
# Mapping type ## Can build up a dict by starting with the the empty dict {} ## and storing key/value pairs into the dict like this: ## dict[key] = value-for-that-key #create dict dict = {} dict['a'] = 'alpha' dict['g'] = 'gamma' dict['o'] = 'omega' for key in dict: print(key, '->', dict[key])
true
00e3304a1b6216c18d5cd8fc9ea5c266ed72149e
Vaspe/Coursera_Python_3_Programming_Michigan
/Python_Project_pillow_tesseract_and_opencv_Mod5/Week2_Tesseract/ipywidgets_stuff.py
2,172
4.15625
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 30 19:49:51 2020 @author: Vasilis """ # In this brief lecture I want to introduce you to one of the more advanced features of the # Jupyter notebook development environment called widgets. Sometimes you want # to interact with a function you have created and call it mul...
true
0229eae841f5fec0563ad643a508650a3b1b235c
nadiiia/cs-python
/extracting data with regex.py
863
4.15625
4
#Finding Numbers in a Haystack #In this assignment you will read through and parse a file with text and numbers. #You will extract all the numbers in the file and compute the sum of the numbers. #Data Format #The file contains much of the text from the introduction of the textbook except that random numbers are inser...
true
59bb55684bffde3abd337b0617af2117a9e4abb4
jinwei15/java-PythonSyntax-Leetcode
/LeetCode/src/FindAllAnagramsinaString.py
2,464
4.1875
4
# 438. Find All Anagrams in a String # Easy # 1221 # 90 # Favorite # Share # Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. # Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100. # The order of output...
true
795cbf40f98ad3a775af177e11913ce831752854
MenacingManatee/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
504
4.21875
4
#!/usr/bin/python3 '''Prints a string, adding two newlines after each of the following: '.', '?', and ':' Text must be a string''' def text_indentation(text): '''Usage: text_indentation(text)''' if not isinstance(text, str): raise TypeError('text must be a string') flag = 0 for char in text: ...
true
d5d557f24d2e74375e95cf22f7df5d2ed5587e8c
MenacingManatee/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
321
4.3125
4
#!/usr/bin/python3 '''Defines a function that appends a string to a text file (UTF8) and returns the number of characters written:''' def append_write(filename="", text=""): '''Usage: append_write(filename="", text="")''' with open(filename, "a") as f: f.write(text) f.close() return len(text)...
true
d91f8e862b939ab0131fab2bf97c96681fba005a
MenacingManatee/holbertonschool-higher_level_programming
/0x0B-python-input_output/100-append_after.py
595
4.1875
4
#!/usr/bin/python3 '''Defines a function that inserts a line of text to a file, after each line containing a specific string''' def append_after(filename="", search_string="", new_string=""): '''Usage: append_after(filename="", search_string="", new_string="")''' with open(filename, "r") as f: res = ...
true
faefe53c66424e822ce06109fc4d095f013e64c0
MenacingManatee/holbertonschool-higher_level_programming
/0x06-python-classes/102-square.py
1,442
4.40625
4
#!/usr/bin/python3 '''Square class''' class Square: '''Defines a square class with logical operators available based on area, as well as size and area''' __size = 0 def area(self): '''area getter''' return (self.__size ** 2) def __init__(self, size=0): '''Initializes size'''...
true
61a293256dff4c87004e8627f0afadd9a9d202ca
shea7073/More_Algorithm_Practice
/2stack_queue.py
1,658
4.15625
4
# Create queue using 2 stacks class Stack(object): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def size(self): return len(self.items) def pop(self): return self.items.pop() def push(self, item): self.it...
true
29436d6802295d6eb8992d2f510427219d29f35b
Mark9Mbugua/Genesis
/chatapp/server.py
1,892
4.125
4
import socket #helps us do stuff related to networking import sys import time #end of imports ### #initialization section s = socket.socket() host = socket.gethostname() #gets the local hostname of the device print("Server will start on host:", host) #gets the name of my desktop/host of the whole connectio...
true
80192a8c2357a805072936ccb99b9dabc8e27778
GANESH0080/Python-WorkPlace
/ReadFilePractice/ReadDataOne.py
291
4.25
4
# Created an File file = open("ReadFile.txt" ,"w+") # Enter string into the file and stored into variable file.write("Ganesh Salunkhe") # Open the for for reading file = open("ReadFile.txt" ,"r") # Reading the file and store file date into variable re= file.read() # Printing file data print(re)
true
de3cf5eec6681b391cddf58e4f48676b8e84e727
KapsonLabs/CorePythonPlayGround
/Decorators/instances_as_decorators.py
660
4.28125
4
""" 1. Python calls an instance's __call__() when it's used as a decorator 2. __call__()'s return value is used as the new function 3. Creates groups of callables that you can dynamically control as a group """ class Trace: def __init__(self): self.enabled = True def __call__(self, f): def wr...
true
ee9cf22dae8560c6ee899431805231a107b8f0e6
smalbec/CSE115
/conditionals.py
1,110
4.4375
4
# a and b is true if both a is true and b is true. Otherwise, it is false. # a or b is true if either a is true or b is true. Otherwise, it is false. # # if morning and workday: # wakeup() # # elif is when you need another conditional inside an if statement def higher_lower(x): if x<24: ...
true
4c403bd4174b1b71461812f9926e6dac87df2610
JasmanPall/Python-Projects
/lrgest of 3.py
376
4.46875
4
# This program finds the largest of 3 numbers num1 = float(input(" ENTER NUMBER 1: ")) num2 = float(input(" ENTER NUMBER 2: ")) num3 = float(input(" ENTER NUMBER 3: ")) if num1>num2 and num1>num3: print(" NUMBER 1 is the greatest") elif num2>num1 and num2>num3: print(" NUMBER 2 is the greates...
true
c8b69c1728f104b4f308647cc72791e49d84e472
JasmanPall/Python-Projects
/factors.py
370
4.21875
4
# This program prints the factors of user input number num = int(input(" ENTER NUMBER: ")) print(" The factors of",num,"are: ") def factors(num): if num == 0: print(" Zero has no factors") else: for loop in range(1,num+1): if num % loop == 0: factor = l...
true
9718066d59cdbd0df8e277d5256fd4d7bb10d90c
JasmanPall/Python-Projects
/Swap variables.py
290
4.25
4
# This program swaps values of variables. a=0 b=1 a=int(input("Enter a: ")) print(" Value of a is: ",a) b=int(input("Enter b: ")) print(" Value of b is: ",b) # Swap variable without temp variable a,b=b,a print(" \n Now Value of a is:",a) print(" and Now Value of b is:",b)
true
87dfe7f1d78920760c7e1b7131f1dd941e284e5a
JasmanPall/Python-Projects
/odd even + - 0.py
557
4.375
4
# This program checks whether number is positive or negative or zero number=float(input(" Enter the variable u wanna check: ")) if number < 0: print("THIS IS A NEGATIVE NUMBER") elif number == 0: print(" THE NUMBER IS ZERO") else: print(" THIS IS A POSITIVE NUMBER") if number%2...
true
17739c9ef743a4eea06fc2de43261bfc72c21678
elijahwigmore/professional-workshop-project-include
/python/session-2/stringfunct.py
1,612
4.21875
4
string = "Hello World!" #can extract individual characters using dereferencing (string[index]) #prints "H" print string[0] #prints "e" print string[1] #print string[2] #Slicing #of form foo[num1:num2] - extract all elements from and including num1, up to num2 (but not including element at num2) ...
true
50a3e1da1482569c0831227e0e4b5ead75433d43
PatrickKalkman/pirplepython
/homework01/main.py
1,872
4.59375
5
""" Python Is Easy course @Pirple.com Homework Assignment #1: Variables Patrick Kalkman / patrick@simpletechture.nl Details: What's your favorite song? Think of all the attributes that you could use to describe that song. That is: all of it's details or "meta-data". These are attributes like "Artist", "Year Released"...
true
b884cc6e8e590ef59a9c3d69cad3b5d574368916
Ardrake/PlayingWithPython
/string_revisited.py
1,674
4.21875
4
str1 = 'this is a sample string.' print('original string>>', str1,'\n\n') print('atfer usig capitalising>>',str1.capitalize()) #this prints two instances of 'is' because is in this as well print('using count method for "is" in the given string>>', str1.count('is')) print('\n\n') print('looking fo specfic string lit...
true
93f34502472cddeb27d9d3404fb0f4f5269bb920
ladipoore/PythonClass
/hass4.py
1,239
4.34375
4
""" I won the grant for being the most awesome. This is how my reward is calculated. My earnings start at $1 and can be doubled or tripled every month. Doubling the amount can be applied every month and tripling the amount can be applied every other month. Write a program to maximize payments given the number of month...
true
aaf077c666e7c6d687e953d9b3e7d35596e7f430
dxab/SOWP
/ex2_9.py
427
4.5
4
#Write a program that converts Celsius temperatures to Fahrenheit temp. #The formula is as follows: f = 9 / 5 * C + 32 #This program should ask the user to enter a temp in Celsius and then #display the temp converted to Fahrenheit celsius = float(input('Please enter todays temperature (in celsius): ')) fahr = 9 / 5 *...
true
fe0ed51cf0cdab74d7d87b9f8317e18776d0c27d
ostanleigh/csvSwissArmyTools
/dynamicDictionariesFromCSV.py
2,363
4.25
4
import csv import json from os import path print("This script is designed to create a list of dictionaries from a CSV File.") print("This script assumes you can meet the following requirements to run:") print(" 1) The file you are working with has clearly defined headers.") print(" 2) You can review the headers ('.h...
true
89ec0897f99163edb014c185425b3054332f6dbe
RamyaRaj14/assignment5
/max1.py
258
4.25
4
#function to find max of 2 numbers def maximum(num1, num2): if num1 >= num2: return num1 else: return num2 n1 = int(input("Enter the number:")) n2 = int(input("Enter the number:")) print(maximum(n1,n2))
true
f8ec2566b82d611fe6e8ae0ecff036978de9a002
ayaabdraboh/python
/lap1/shapearea.py
454
4.125
4
def calculate(a,c,b=0): if c=='t': area=0.5*a*b elif c=='c': area=3.14*a*a elif c=='s': area=a*a elif c=='r': area=a*b return area if __name__ == '__main__': print("if you want to calculate area of shape input char from below") ...
true
ef3f6373867dbacee7aae3af141d9fcd1edbd311
PabloG6/COMSCI00
/Lab4/get_next_date_extra_credit.py
884
4.28125
4
from datetime import datetime from datetime import timedelta '''the formatting on the lab is off GetNextDate(day, month, year, num_days_forward) would not return 9/17/2016 if GetNextDate(2, 28, 2004) is passed because 28 is not a month. ''' def GetNextDate(day, month, year, num_days_forward): num_days_forward = int...
true
af817ff14fbc1b00968c49da3f427ddb3d75622d
PabloG6/COMSCI00
/Lab2/moon_earths_moon.py
279
4.125
4
first_name = input("What is your first name?") last_name = input("What is your last name?") weight = int(input("What is your weight?")) moon_gravity= 0.17 moon_weight = weight*moon_gravity print("My name is", first_name, last_name+".", "And I weigh", moon_weight, "on the moon")
true
683ce144348dbb8d1f15f38ada690d70e9b1a22f
joeschweitzer/board-game-buddy
/src/python/bgb/move/move.py
827
4.3125
4
class Move: """A single move in a game Attributes: player -- Player making the move piece -- Piece being moved space -- Space to which piece is being moved """ def __init__(self, player, piece, space): self.player = player self.piece = piece self.space =...
true
2b0293a0bd0452e9e94a7c6aea0d13a803cc9dbd
Demesaikiran/MyCaptainAI
/Fibonacci.py
480
4.21875
4
def fibonacci(r, a, b): if r == 0: return else: print("{0} {1}".format(a, b), end = ' ') r -= 1 fibonacci(r, a+b, a+ 2*b) return if __name__ == "__main__": num = int(input("Enter the number of fibonacci series you want: ")) if num =...
true