blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
046bd214c938e63595f3d9fdeed82ecf1327b6b7
ayushtiwari7112001/Rolling-_dice
/Dice_Roll_Simulator.py
640
4.4375
4
#importing modual import random #range of the values of dice min_val = 1 max_val = 6 #to loop the rolling through user input roll_again = "yes" #loop while roll_again == "yes" or roll_again == "y": print("Roll the dices...") print("** The values are **") #generating and printing 1st random intege...
true
93278240e775bbba67da1572331d7a1d3cb279db
YeomeoR/codewars-python
/sum_of_cubes.py
656
4.25
4
# Write a function that takes a positive integer n, sums all the cubed values from 1 to n, and returns that sum. # Assume that the input n will always be a positive integer. # Examples: # sum_cubes(2) # > 9 # # sum of the cubes of 1 and 2 is 1 + 8 ### from cs50 video python, lecture 2 # def sum_cubes(n): # cubed...
true
4f481dd9a6205e9979b2f9f17103dd3816a226ab
YeomeoR/codewars-python
/count_by_step.py
827
4.21875
4
# Implement a function named generateRange(min, max, step), which takes three arguments and generates a range of integers from min to max, with the step. The first integer is the minimum value, the second is the maximum of the range and the third is the step. (min < max) # def generate_range(min, max, step): # lis...
true
3d40b4229c78f200c882547349bf5ad433a87908
goruma/CTI110
/P2HW1_PoundsKilograms_AdrianGorum.py
586
4.40625
4
# Program converts pounds value to kilograms for users. # 2-12-2019 # CTI-110 P2HW1 - Pounds to Kilograms Converter # Adrian Gorum # #Pseudocode #input pound amount > calculate pound amount divided by 2.2046 > display #conversion in kilograms #Get user input for pound amount. poundAmount = float(input('En...
true
1ef83617a069d51eb924275376f133f4c323d375
goruma/CTI110
/P4HW4_Gorum.py
796
4.3125
4
# This programs draws a polygonal shape using nested for loops # 3-18-19 # P4HW4 - Nested Loops # Adrian Gorum # def main(): #Enable turtle graphics import turtle #Set screen variable window = turtle.Screen() #Set screen color window.bgcolor("red") #Pen Settings myPen = ...
true
f3de93f96f4247c3bccba5f699eadd168e4439d0
vincent1879/Python
/MITCourse/ps1_Finance/PS1-1.py
844
4.125
4
#PS1-1.py balance = float(raw_input("Enter Balance:")) AnnualInterest = float(raw_input("Enter annual interest rate as decimal:")) MinMonthPayRate = float(raw_input("Enter minimum monthly payment rate as decimal:")) MonthInterest = float(AnnualInterest / 12.0) TotalPaid = 0 for month in range(1,13): print "Month",...
true
b272382f80edeabc91c1a33ba847e34ebff32ac0
Holly-E/Matplotlib_Practice
/Dealing_with_files.py
1,051
4.125
4
# -*- coding: utf-8 -*- """ Spyder Editor Master Data Visualization with Python Course """ #open pre-existing file or create and open new file to write to # you can only write strings to txt files- must cast #'s to str( ) file = open('MyFile.txt', 'w') file.write('Hello') file.close() # can reuse file variable nam...
true
39818a02bdab25b77dbfbc76cba087baecbd55d8
nibbletobits/nibbletobits
/python/day 6 in class.py
624
4.21875
4
# ******************************************** # Program Name: Day 5, in class # Programmer: Jordan P. Nolin # CSC-119: Summer 2021 # Date: June 21, 2021 # Purpose: A program to add the sum of all square roots # Modules used: # Input Variables: number() ect # Output: print statements, that output variable answe...
true
3431a14f55b66f3f0c4f9a2010534957f510bd2f
liyi0206/leetcode-python
/225 implement stack using queues.py
821
4.15625
4
class Stack(object): def __init__(self): """ initialize your data structure here. """ self.queue=[] def push(self, x): """ :type x: int :rtype: nothing """ self.queue.append(x) def pop(self): """ :rtype: nothing ...
false
dd9873e3979fc3621a89d469d273f830371d757a
kingamal/OddOrEven
/main.py
500
4.1875
4
print('What number are you thinking?') number = int(input()) while number: if number >=1 and number <= 1000: if number % 2 != 0: print("That's an odd number! Have another?") number = int(input()) elif number % 2 == 0: print("That's an even number! Have another?") ...
true
d6a5f32aea3864aea415514dad886b81d434a8cc
sahilbnsll/Python
/Inheritence/Program01.py
949
4.25
4
# Basics of Inheritance class Employee: company= "Google Inc." def showDetails(self): print("This is a employee") class Programmer(Employee): language="Python" company= "Youtube" def getLanguage(self): print(f"The Language is {self.language}") def showDetails(self): ...
true
6e0f7759356bbfbf474fc5af93eb902e8a875661
sahilbnsll/Python
/Projects/Basic_Number_Game.py
406
4.15625
4
# Basic Number Game while(True): print("Press 'q' to quit.") num =input("Enter a Number: ") if num == 'q': break try: print("Trying...") num = int(num) if num >= 6: print("Your Entered Number is Greater than or equal to 6\n") except Exception as e: ...
true
029de1a6a99a93e8b0cf273c51675120a3bcaad6
kashifusmani/interview_prep
/recursion/reverse_string.py
213
4.125
4
def reverse(s): if len(s) == 1 or len(s) == 0: return s return s[len(s)-1] + reverse(s[0: len(s)-1]) # or return reverse(s[1:]) + s[0] if __name__ == '__main__': print(reverse('hello world'))
false
09a14e49b6bb2b7944bc5ec177586a40761ca6f7
kashifusmani/interview_prep
/fahecom/interview.py
2,489
4.125
4
""" Write Python code to find 3 words that occur together most often? Given input: There is the variable input that contains words separated by a space. The task is to find out the three words that occur together most often (order does not matter) input = "cats milk jump bill jump milk cats dog cats jump milk" """ fro...
true
b1da56330aaed2070bd2a2cf71e7905f800f11db
LaytonAvery/DigitalCraftsWeek1
/Day4/todolist.py
1,089
4.21875
4
choice = "" task = {} def add_task(choice): task = [{"title": name, "priority": priority}] task.append("") for key, value in task.append(""): print(key, value) # print(task) def delete_task(choice): del task def view_all(): for key, value in task.items(): print(key, value)...
true
00aec8932d5749f9f5af478ebb9dbeff183a5c11
krizo/checkio
/quests/singleton.py
874
4.125
4
''' https://py.checkio.org/en/mission/capital-city/ You are an active traveler who have visited a lot of countries. The main city in the every country is its capital and each country can have only one capital city. So your task is to create the class Capital which has some special properties: the first created instance...
true
f5c9eb271fbd7da172fa9af87960faff1bd5f675
abhishektzr/sangini
/learning-python_Teach-Your-Kids-to Code/fibfunctions.py
267
4.15625
4
def fibonacci(num): print("printing fibonacci numbers till ", num) v = 1 v1 = 1 v2 = v + v1 print(v) print(v1) while v2 < num: print(v2) v = v1 v1 = v2 v2 = v + v1 fibonacci(10) fibonacci(20) fibonacci(500)
false
68e086044625f54a75bf362a4dd6d63c4632cff6
NALM98/Homework-Course-1
/HW3/HW1.py
1,689
4.125
4
print("Введите, пожалуйста,три любых числа") a = int(input()) b = int(input()) c = int(input()) #1. a и b в сумме дают c #2. a умножить на b равно c #3. a даёт остаток c при делении на b #4. c является решением линейного уравнения ax + b = 0 #5. a разделить на b равно c #6. a в степени b равно c. #1 if a+b == c: ...
false
2c4041af39e9c050adb9f1aa6352a6b9c25c8436
SwethaGullapalli/PythonTasks
/PrintFileNameHavingPy.py
866
4.375
4
#program to print the file extension having py """give input as list of file names iterate each file name in file names list declare one variable for holding file extension declare variables for index and dot index iterate each character in the file name increment the index by 1 if Character is equal to "." ass...
true
012065e8a85e1ac86c2e563e5df3d7feab87101a
Exodus76/aoc19
/day1.py
759
4.125
4
#day 1 part 1 #find the fuel required for a module, take its mass, divide by three, round down, and subtract 2 #part1 function def fuel_required(mass): if(mass < 0): return 0 else: return (mass/3 - 2) #part2 fucntion def total_fuel(mass): total = 0 while(fuel_required(mass) >= 0): ...
true
eb78d593489b33d1a5cd3cb14268aef27b553962
Binovizer/Python-Beginning
/TheBeginning/py_basics_assignments/50.py
897
4.1875
4
import re student_id = input("Enter student id : ") if(re.search("[^0-9]", student_id)): print("Sorry! Student ID can only contains digit") else: student_name = input("Enter student name : ") if re.search("[^a-zA-Z]", student_name): print("Name can only contain alphabets") else: ...
false
50807cca27c1d9b15e8a43d36a3fe2249529c96c
alixoallen/todos.py
/adivinhação.py
327
4.15625
4
from random import randint computer=randint(0,5) print('pensei no numero{}'.format(computer))#gera um numero aleatorio, ou faz o computador """"""pensar""""""""""""""" escolha=int(input('digite um numero:')) if escolha == computer: print('parabens voce acertou!') else: print('ora ora voce é meio pessimo nisso!...
false
9eb137a3f310eeb8c6d006bfd72fce5e035e06b2
mansiagnihotrii/Data-Structures-in-python
/Linked List/4_linkedlist_partition.py
851
4.125
4
''' Given a linked list and an element , say 'x'. Divide the same list so that the left part of the list has all the elements less that 'x' and right part has all elements greater than or equal to 'x'. ''' #!/usr/bin/env python3 import linkedlist from linkedlist import LinkedList,Node def partition_list...
true
c696a2980ffe52412000a0f0deda444cea00badf
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/strings/funny_string.py
1,059
4.34375
4
def funny_string(s): """Hackerrank Problem: https://www.hackerrank.com/challenges/funny-string/problem In this challenge, you will determine whether a string is funny or not. To determine whether a string is funny, create a copy of the string in reverse e.g. abc -> cba. Iterating through each string, compa...
true
0562ecb6074ee2c8d62d863db65a1c5a5325fd66
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/strings/mars_exploration.py
919
4.34375
4
def mars_exploration(s): """Hackerrank Problem: https://www.hackerrank.com/challenges/mars-exploration/problem Sami's spaceship crashed on Mars! She sends a series of SOS messages to Earth for help. Letters in some of the SOS messages are altered by cosmic radiation during transmission. Given the signal r...
true
ff2f6d4c31e79e2249438839b9e85049e4f2c4e0
kcc3/hackerrank-solutions
/python/python_functionals/validating_email_addresses_with_filter.py
1,146
4.15625
4
"""Hackerrank Problem: https://www.hackerrank.com/challenges/validate-list-of-email-address-with-filter/problem""" def fun(s): """Determine if the passed in email address is valid based on the following rules: It must have the username@websitename.extension format type. The username can only contain lett...
true
10a395af6ac6efa71d38074c2d88adff4665435e
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/bit_manipulation/maximizing_xor.py
932
4.3125
4
def maximizing_xor(l, r): """Hackerrank Problem: https://www.hackerrank.com/challenges/maximizing-xor/problem Given two integers, l and r, find the maximal value of a xor b, written a @ b, where a and b satisfy the following condition: l <= a <= b <= r Solve: We XOR the l and r bound and ...
true
6d15fcd0279049189d9a54c882f0b27a46034a59
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/implementation/the_grid_search.py
2,824
4.21875
4
def grid_search(g, p): """Hackerrank Problem: https://www.hackerrank.com/challenges/the-grid-search/problem Given a 2D array of digits or grid, try to find the occurrence of a given 2D pattern of digits. For example: Grid ---------- 1234567890 0987654321 1111111111 1111111111 22222...
true
6eba8809d2c6d10aadc221ea78cf0d08d458d967
kcc3/hackerrank-solutions
/data_structures/python/stacks/maximum_element.py
1,176
4.34375
4
"""Hackerrank Problem: https://www.hackerrank.com/challenges/maximum-element/problem You have an empty sequence, and you will be given queries. Each query is one of these three types: 1 x -Push the element x into the stack. 2 -Delete the element present at the top of the stack. 3 -Print the maximum element in...
true
54e29a17af6dfcb36c102bba527a588a533d29f3
kcc3/hackerrank-solutions
/python/built_ins/any_or_all.py
548
4.15625
4
""" Hackerrank Problem: https://www.hackerrank.com/challenges/any-or-all/problem Given a space separated list of integers, check to see if all the integers are positive, and if so, check if any integer is a palindromic integer. """ n = int(input()) ints = list(input().split(" ")) # Check to see if all integers in the ...
true
048f4a1843a7cb34f846a62ff3cc70225a74c763
kcc3/hackerrank-solutions
/data_structures/python/stacks/balanced_brackets.py
2,594
4.40625
4
def is_balanced(s): """Hackerrank Problem: https://www.hackerrank.com/challenges/balanced-brackets/problem A bracket is considered to be any one of the following characters: (, ), {, }, [, or ]. Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the lef...
true
93d2c4f2eb3485d73051a93cfa531070aa46a563
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/implementation/bigger_is_greater.py
1,021
4.28125
4
def bigger_is_greater(w): """Hackerrank Problem: https://www.hackerrank.com/challenges/bigger-is-greater/problem Given a word, create a new word by swapping some or all of its characters. This new word must meet two criteria: - It must be greater than the original word - It must be the smallest word t...
true
49f4e08c38d8f2429e77d4af1d29e4010c381208
archeranimesh/pythonFundamentals
/code/pyworkshop/02_list/list_sort.py
556
4.21875
4
# Two ways to sort a list. lottery_numbers = [1, 3, 345, 123, 789, 12341] # 1st method does not modify the original list, # returns a shallow copy of original list. print("sorted list: ", sorted(lottery_numbers)) # reverse the list. print("reverse list: ", sorted(lottery_numbers, reverse=True)) x = sorted(lottery_...
true
63a6c50f451fd165eeff0b514a9c5e87b44b531d
michalecki/codewars
/sum_of_intervals.py
1,528
4.1875
4
''' Write a function called sumIntervals/sum_intervals() that accepts an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only be counted once. Intervals are represented by a pair of integers in the form of an array. The first value of the interval will always be less t...
true
aa970b317af5316d42807008efbc5b41e8347486
michalecki/codewars
/sum_of_numbers.py
582
4.34375
4
def get_sum(a,b): ''' Given two integers a and b, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return a or b. Note: a and b are not ordered! :param a: int :param b: int :return: int ''' i...
true
a72af4074104f47c32f8714796c4a1f6948bc8d1
ShreyanGoswami/coding-contests
/Leetcode weekly contest 189/rearrange_words_in_sentence.py
860
4.25
4
''' Given a sentence text (A sentence is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words hav...
true
1eb433504868fbaa75faaa7bac81000f9431dee6
cwang-armani/learn-python
/09 数据结构与算法/5 栈.py
699
4.1875
4
class Queue(object): '''定义一个栈''' def __init__(self): self.__item = [] def is_empty(self): # 判断列表是否为空 return self.__item == [] def enqueue(self,item): # 入队 self.__item.append(item) return item def dequeue(self): # 出队 r...
false
985bb44337d98dcf1b07803b84ae7417f48c0015
pragatij17/General-Coding
/Day 6/python/sum_of_numbers.py
256
4.25
4
# Write a program that asks the user for a number n and prints the sum of the numbers 1 to n. def sum_of_number(n): sum = 0 for i in range(1,n+1): sum =sum + i return sum n = int(input('Last digit of sum:')) print(sum_of_number(n))
true
c84859d03e6df77d8575dddd7192f2f36852ba31
RojieEmanuel/intro-python
/102.py
2,170
4.1875
4
weekdays = ['mon','tues','wed','thurs','fri'] print(weekdays) print(type(weekdays)) days = weekdays[0] # elemento 0 days = weekdays[0:3] # elementos 0, 1, 2 days = weekdays[:3] # elementos 0, 1, 2 days = weekdays[-1] # ultimo elemento test = weekdays[3:] # elementos 3, 4 weekdays ...
false
dcf7913f53b7ea31ba263c2a26ecd5a52334846e
SaidRem/algorithms
/find_biggest_(recursion).py
404
4.21875
4
# Finds the biggest element using recursion def the_biggest(arr): # Base case if length of array equals 2 . if len(arr) == 2: return arr[0] if arr[0] > arr[1] else arr[1] # Recursion case. sub_max = the_biggest(arr[1:]) return arr[0] if arr[0] > sub_max else sub_max if __name__ == '__mai...
true
6af4513c000f0bf8ae449e915e146515187fed08
PdxCodeGuild/class_mudpuppy
/Assignments/Terrance/Python/lab07-rock_paper_scissors.py
1,327
4.25
4
#lab07-rockpaperscissors.py import random user_input = 'yes' while user_input == 'yes': print('Let\'s play rock-paper-scissors!') print('The computer will ask the user for their choice of rock, paper or scissors, and then the computer will randomly make a selection.') #computer tell user how the game wil...
true
4885b4212545ee9f635fed82f045478503adc865
PdxCodeGuild/class_mudpuppy
/Reviewed/Brea/python/lab17/lab17_version2_checked.py
1,009
4.125
4
#Lab 17, Version 2 Anagram def split(word): return list(word) # good practice, but generally don't make a function # that calls a single function, especially one that's already well-known like list() def remove_spaces(str): new_str = '' for i in range(len(str)): if(str[i] != ' '): new_...
true
37675d15d25aa51006258ff94564fbc04ff6e685
PdxCodeGuild/class_mudpuppy
/1 Python/class_demos/function-lecture/add-number-words-ultimate-solution.py
986
4.125
4
import operator def get_valid_input(): valid_input = False while not valid_input: num1 = input("Spell out a number with letters: ") if num1 in number_dict: return num1 else: print(f"{num1} is not supported. Try entering a different number: ") def reduce_list_to...
true
096d0dc863ab7739debf8e8000545f4e7f7f3cda
PdxCodeGuild/class_mudpuppy
/Assignments/Devan/1 Python/labs/lab11-simple_calculator.py
1,098
4.21875
4
# Lab 11: Simple Calculator Version 3 def get_operator(op): return operators[op] def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y def eval(fn, n1, n2): return fn(n1, n2) operators = {'+': add, '-': subtrac...
true
50962379cef04f28b24854aeeaccc11e9f673a9b
PdxCodeGuild/class_mudpuppy
/Assignments/Eboni/labs06.py
1,170
4.21875
4
# Lab 6: Password Generator """ Let's generate a password of length `n` using a `while` loop and `random.choice`, this will be a string of random characters. """ import random import string # string._file_ = random.choice('string.ascii_letters + string.punctuation + string.digits') # #print((string._file_)) # pass_n...
true
2874845c72626487f96500a7aac40ba91891870e
PdxCodeGuild/class_mudpuppy
/1 Python/solutions/lab09-v2.5.py
617
4.34375
4
# Supported unit types supported_units = ["ft", "mi", "m", "km"] # Ask the user for the unit they want unit = input("What unit do you want: ") # If an invalid unit is specified, alert the user and exit if unit not in supported_units: print("Please enter a valid unit! Options are ft, mi, m, km...") exit() # Get t...
true
7d22fbd58d09e95c2ab94e8adb567da9c3932b36
PdxCodeGuild/class_mudpuppy
/Assignments/Eboni/lab18.py
439
4.125
4
import string input_string = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9] #change variable name #create an empty list for index in range(1,len(input_string)-1): left_side = input_string[index-1] middle = input_string[index] right_side = input_string[index + 1] if left_side < middle an...
true
91c7e627278fe3386b9db69c2bf8636072abbeaf
PdxCodeGuild/class_mudpuppy
/Assignments/Eboni/lab09-unit_converter.py
1,154
4.46875
4
""" Ask the user for the number of feet, and print out the equivalent distance in meters. Hint: 1 ft is 0.3048 m. So we can get the output in meters by multiplying the input distance by 0.3048. Below is some sample input/output. """ # import decimal # print("Enter number of feet ") # number_feet = float(input('')) # me...
true
c5d508427ca54175b9b640d81d451807aa07ac21
PdxCodeGuild/class_mudpuppy
/Assignments/Racheal/python/test.py
1,247
4.34375
4
import random #Twinkle, twinkle, little star, #How I wonder what you are! #Up above the world so high, #Like a diamond in the sky. # little = input("Enter adjective:") # wonder = input("Enter verb:") # world = input("Enter noun:") # high = input("Enter adjective:") # diamond = input("Enter noun:") # sky =input("Ent...
true
a8dd0814e6f3294f7c65ed85b0c49311589f6fb8
PdxCodeGuild/class_mudpuppy
/Assignments/Terrance/Python/lab25-atm.py
2,171
4.15625
4
#lab25-atm.py class ATM: def __init__(self, balance=0, interest_rate=.01): self.balance = balance self.interest_rate = interest_rate self.transactions = [] def check_balance(self): '''returns the account balance''' print(f"Your balance is {self.balance}") ...
true
4e17ad1e21e211e490a7e0b4ef34b71052415dc9
PdxCodeGuild/class_mudpuppy
/Assignments/Brea/Class Examples/Test_042220.py
225
4.1875
4
#Test Examples, April 22nd, 2020 data1 = {'a': 1} data2 = {'a': {'b': 1}} #if we call 'a', it'll return the dictionary data3 = {'a': {'b': 1}, 'z': ['Portland', 'Seattle', 'LA']} #if we call data3['z'][0], returns 'Portland'
false
a35cffa0ab2b6c4424709cf8693ef70106688eb9
PdxCodeGuild/class_mudpuppy
/Assignments/Brea/Class Examples/Test_042120.py
1,464
4.1875
4
#Test Examples April 21st, 2020 #average numbers lab re-do # nums = [5, 0, 8, 3, 4, 1, 6] # running_sum = 0 # for num in nums: # running_sum = running_sum + num # print(running_sum) # aver = running_sum / len(nums) # print(f"The average of your numbers is {aver}.") #--------REPL Version of average number...
true
750437c3c078315b3a3ee1981aa1173e2dfaeefe
charlotteviner/project
/land.py
1,632
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Nov 28 17:37:12 2017 @author: charlotteviner Credit: Code written by Andrew Evans. Create elevation data for use in the project. Provided for background on how the artificial environment 'land' was created. Returns: land (list) -- List containi...
true
a13f132c3ac6e87e313570bcc86e470c096ae0b5
koushik-chandra-sarker/PythonLearn
/a_script/o_Built-in Functions.py
1,608
4.125
4
""" Python Built-in Functions: https://docs.python.org/3/library/functions.html or https://www.javatpoint.com/python-built-in-functions """ # abs() # abs() function is used to return the absolute value of a number. i = -12 print("Absolute value of -40 is:", abs(i)) # Output: Absolute val...
true
681879f34aefef0a7ad1737bffab3fae05566bd1
victorboneto/Python
/src/sqc/exe9.py
266
4.1875
4
#Faça um Programa que peça a temperatura em graus Fahrenheit, #transforme e mostre a temperatura em graus Celsius. #C = 5 * ((F-32) / 9). graus = int(input("Digite o graus Fahrenheit aqui: ")) celsius = 5 * ((graus - 32) / 9) print("Tem {}ºc" .format(celsius))
false
19c94192bbd45a17858bd0b0348a077042c144b7
gibsonn/MTH420teststudent
/Exceptions_FileIO/exceptions_fileIO.py
2,762
4.25
4
# exceptions_fileIO.py """Python Essentials: Exceptions and File Input/Output. <Name> <Class> <Date> """ from random import choice # Problem 1 def arithmagic(): """ Takes in user input to perform a magic trick and prints the result. Verifies the user's input at each step and raises a ValueError with ...
true
577e6159eadade42ea06061c3fbe1a16536644f1
Rayff-de-Souza/Python_Geek-University
/SECAO-6-EXERCICIO-2/index.py
408
4.15625
4
""" GEEK UNIVERSITY - Exercício - Faça um programa que escreva de 1 até 100 duas vezes, sendo a primeira vez com o loop FOR e a segunda com o loop WHILE. """ print('FOR'.center(20, '_')) for n in range(1, 101): print(n) print('FOR'.center(20, '_')) print('\n') contador = 1 print('WHILE'.center(20, '_')) while con...
false
cd11542b28904b0865526267ec5db987183b714d
Yu4n/Algorithms
/CLRS/bubblesort.py
647
4.25
4
# In bubble sort algorithm, after each iteration of the loop # largest element of the array is always placed at right most position. # Therefore, the loop invariant condition is that at the end of i iteration # right most i elements are sorted and in place. def bubbleSort(ls): for i in range(len(ls) - 1): ...
false
69fe06f4d308eca042f3bf0c30f4a207d65473ac
Yu4n/Algorithms
/CLRS/insertion_sort.py
1,175
4.3125
4
# Loop invariant is that the subarray A[0 to i-1] is always sorted. def insertionSort(arr): # Traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] # Move elements of arr[0..i-1], that are # greater than key, to one position ahead # of their current position ...
true
46fd209659f3dd4ca466d6ca7e7af8f23c661238
mverini94/PythonProjects
/DesignWithFunctions.py
2,401
4.65625
5
''' Author....: Matt Verini Assignment: HW05 Date......: 3/23/2020 Program...: Notes from Chapter 6 on Design With Functions ''' ''' Objectives for this Chapter 1.) Explain why functions are useful in structuring code in a program 2.) Employ a top-down design design to assign tasks to functions 3.) Define a recursiv...
true
caaceae86ca5f9ac137756c98fccecba86b05c88
mverini94/PythonProjects
/__repr__example.py
540
4.34375
4
import datetime class Car: def __init__(self, color, mileage): self.color = color self.mileage = mileage def __repr__(self): return '__repr__ for Car' def __str__(self): return '__str__ for Car' myCar = Car('red', 37281) print(myCar) '{}'.format(myCar) print(str([myCa...
true
2e0c3573ed6698fa45e56983fb5940dc57daeb94
odai1990/madlib-cli
/madlib_cli/madlib.py
2,673
4.3125
4
import re def print_wecome_mesage(): """ Print wilcome and explane the game and how to play it and waht the result Arguments: No Arguments Returns: No return just printing """ print('\n\n"Welcome To The Game" \n\n In this game you will been asked for enter several adjectives,...
true
0dbfe08ed9fd0f87544d12239ca9505083c85986
mpsacademico/pythonizacao
/parte1/m004_lacos.py
1,641
4.15625
4
# codig=UTF-8 print("FOR") # repete de forma estática ou dinâmica animais = ['Cachorro', 'Gato', 'Papagaio'] # o for pode iterar sobre uma coleção (com interador) de forma sequencial for animal in animais: # a referência animal é atualizada a cada iteração print(animal) else: # executado ao final do laço (exceto com...
false
5cc5a1970d143188e1168d521fac27f4534f3032
fastestmk/python_basics
/dictionaries.py
441
4.375
4
# students = {"Bob": 12, "Rachel": 15, "Anu": 14} # print(students["Bob"]) #length of dictionary # print(len(students)) #updating values # students["Rachel"] = 13 # print(students) #deleting values # del students["Anu"] # print(students) my_dict = {'age': 24, 'country':'India', 'pm':'NAMO'} for key, val in my_dict....
false
07cd0f2a3208e04dd0c34a501b68de19f692c35a
Temesgenswe/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
364
4.3125
4
#!/usr/bin/python3 """Module defines append_write() function""" def append_write(filename="", text=""): """Appends a string to a text file Return: the number of characters written Param: filename: name of text file text: string to append """ with open(filename, 'a', encoding="UTF...
true
86e76c7aa9c052b23b404c05f57420750a5029b7
Temesgenswe/holbertonschool-higher_level_programming
/0x06-python-classes/103-magic_class.py
751
4.4375
4
#!/usr/bin/python3 import math class MagicClass: """Magic class that does the same as given bytecode (Circle)""" def __init__(self, radius=0): """Initialize radius Args: radius: radius of circle Raises: TypeError: If radius is not an int nor a float ""...
true
d3e203ffb4eac1ffe1bd1776de5f06220b81b6c1
LorenzoChavez/CodingBat-Exercises
/Warmup-1/sum_double.py
231
4.15625
4
# Given two int values, return their sum. Unless the two values are the same, then return double their sum. def sum_double(a, b): result = 0 if a == b: result = (a+b) * 2 else: result = a+b return result
true
7ce2d175697104c3df72fd437f9fe01fc0ed5053
alxanderapollo/HackerRank
/WarmUp/salesByMatchHR.py
1,435
4.3125
4
# There is a large pile of socks that must be paired by color. Given an array of integers # representing the color of each sock, determine how many pairs of socks with matching colors there are. # Example # There is one pair of color and one of color . There are three odd socks left, one of each color. # The number...
true
3b38c1507501d451d741da0daa812a4f63152941
kushagra65/Python-CLock-Project
/ANALOG CLOCK.py
2,034
4.28125
4
#import the essential modules import time# importing the time module import turtle #importing the turtle module from the LOGO days #---------------------------------------------------------------- #creating the screen of the clock wn = turtle.Screen()#creating a screen wn.bgcolor("black")#setting the backgroung color ...
true
e783154304256165ff443159d4181209454d2e08
kanishk333gupta/Elementary-Signals-in-continuous-and-discrete-time
/Exponential signal.py
1,765
4.34375
4
#EXPONENTIAL SIGNAL import numpy as np #Importing all definitions from the module and shortening as np import matplotlib.pyplot as mplot #Shortening as mplot ,an alias to call the library name ###CONTINUOUS x = np.linspace(-1, 2, 100) # 100 linearly spaced numbers from -1 to 2 xCT ...
true
26864be554f52e6a3dc2cee5455de74599228579
angellovc/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-number_of_lines.py
355
4.15625
4
#!/usr/bin/python3 """ number_of_lines function module """ def number_of_lines(filename=""): """Get the numbers of lines into a text file Keyword Arguments: filename {str} -- [text file] """ with open(filename, mode="r", encoding="UTF8") as f: lines = 0 for line in f: ...
true
687e728de6afc1a57f322db9204a20957055b25c
angellovc/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,770
4.125
4
#!/usr/bin/python3 """ Matrix_divided functions module """ def matrix_divided(matrix, div): """ Make a division of all the elements into the matrix by a div number returns a new result list Args: matrix: matrix of dividends, just floats or integers are allowed div: that's represent the...
true
f0c1ca32d74b47203d48ebe82b5520069a1bdacc
angellovc/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
515
4.21875
4
#!/usr/bin/python3 """ read_lines module """ def read_lines(filename="", nb_lines=0): """read and print n number of lines into a text file Keyword Arguments: filename {str} -- [text file] (default: {""}) nb_lines {int} -- [n lines to read] (default: {0}) """ with open(filename, mode="r...
true
13ecec23ce620311c11f33da1ba3bba90cbd7fec
angellovc/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/100-print_tebahpla.py
241
4.4375
4
#!/usr/bin/python3 """ print the ascii alphabet in reverse using upper and lower characters""" for lower, upper in zip(range(122, 96, -2), range(89, 64, -2)): print("{}{}".format(chr(lower), chr(upper)), end='') # print ascii numbers
true
70a97b65e8cb2c963b0ae981b52ae5b191743d57
emmaAU/CSC280
/Random.py
575
4.125
4
#import random #print(random.random) import math print(math) a = int(input('enter coefficient for x**2 ')) b = int(input('enter b: ')) c = int(input('what is c?: ')) disc = b**2 - 4*a*c if disc > 0: root1 = -b + math.sqrt(disc) / 2*2 print(root1) root2 = -b - math.sqrt(disc) / 2*2 print(root2) elif d...
true
57eb63f9f063deda592db8a58ebf420737f5f37c
etridenour/digitalCrafts
/classNotes/python/class7-2.py
2,516
4.3125
4
# class MyClass: # def SayHello(): # print("Hello there!") # MyClass.SayHello() class Person: def greet (self): #self points to object you are creating (ex. me, matt) print("Hello") me = Person() me.greet() matt = Person() matt.greet() # class MyClass: # Greeting = " " # lcass variable, ...
true
4f7ff64e0ec87b80e8689e8d484f9c0cefd3fbdf
ParkerCS/ch18-19-exceptions-and-recursions-aotoole55
/recursion_lab.py
1,152
4.78125
5
''' Using the turtle library, create a fractal pattern. You may use heading/forward/backward or goto and fill commands to draw your fractal. Ideas for your fractal pattern might include examples from the chapter. You can find many fractal examples online, but please make your fractal unique. Experiment with the vari...
true
6efd603459989c8fa85b848c52d05a96a2ff8a74
peluza/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/3-say_my_name.py
719
4.5625
5
#!/usr/bin/python3 """3-say_my_name """ def say_my_name(first_name, last_name=""): """say_my_name Arguments: first_name {str} -- the value is the first_name Keyword Arguments: last_name {str} -- the value is the las_name (default: {""}) Raises: TypeError: first_name must...
true
bbd1072f2a5f859b44c7b4acd7daa5a7ae8b6c48
misaka-umi/Software-Foundamentals
/07 stacks/64 stacks-reverse sentence.py
1,846
4.125
4
class Stack: def __init__(self): self.__items = [] def pop(self): if len(self.__items) > 0 : a= self.__items.pop() return a else: raise IndexError ("ERROR: The stack is empty!") def peek(self): if len(self.__items) > 0 : return ...
false
428fd8714cd7c2542af1000822bf90da9dd58847
linleysanders/algorithms
/Homework Week One (Average of Averages)/Linley Sanders Week One Homework.py
2,609
4.28125
4
# coding: utf-8 # # Lede Algorithms -- Assignment 1 # # In this assignment you will use a little algebra to figure out how to take the average of averages. # In[1]: import pandas as pd import matplotlib.pyplot as plt import requests get_ipython().run_line_magic('matplotlib', 'inline') # First, read in the tita...
true
d333b5c8fa654a867c5e54f599f2ca5a5c68746d
zhezhe825/api_test
/cases/test_1.py
1,297
4.5
4
''' unittest框架:单元测试框架,也可做自动化测试,python自带的 unittest:管理测试用例,执行用例,查看结果,生成 html 报告(多少通过,多少失败 ) 自动化:自己的代码,验证别人的代码 大驼峰命名:PrintEmployeePaychecks() 小驼峰:printEmployeePaychecks() 下划线命名:print_employee_paychecks() 类:大驼峰命名 其他:小驼峰,下划线命名 class:测试的集合,一个集合又是一个类 unittest.TestCase:继承 继承的作用:子类继承父类(TestExample 继承 TestCase),父类有的,子类都有 ''' ...
false
cbd8f93e9f6e1adbeebe0d612865c3d306ada0a1
ritaly/python-6-instrukcje-warunkowe
/Odpowiedzi/2.py
988
4.125
4
# -*- coding: utf8 -*- """ Do kalkulatora BMI z lekcji "Python 1 zabawy w konsoli" dodaj sprawdzanie czy BMI jest prawidłowe Niedowaga | < 18,5 Waga normaln | 18,5 – 24 Lekka nadwaga | 24 – 26,5 Nadwaga | > 26,5 W przypadku nadwagi sprawdź czy występuje otyłość: Otyłość I stopn...
false
61a496dde5f1d6faa1dfb14a79420f3730c0727f
DMRathod/_RDPython_
/Coding Practice/Basic Maths/LeapYear.py
441
4.21875
4
# leap year is after every 4 years, divisible by 4. # Every Century years are not leap years means if it is divisible by 100. # we need to confirm if it is divisible by 400 or not. year = int(input("Enter The Year :")) if(year%4 == 0): if(year%100 == 0): if(year%400 == 0): print(str(yea...
false
fbb3938b667cba8afe5144c023cacbd833028f03
crashtack/exercism
/python/clock/clock.py
1,144
4.34375
4
class Clock(object): """ A Clock class that ignores date """ def __init__(self, hours=0, minutes=0): """ Initialize the Clock object """ self.hours = hours % 24 self.minutes = minutes self.time_min = (self.hours * 60) + self.minutes self.time_min = self.time_min % 1440 ...
true
deb0106dadea39101d8c40357c3f41f9383a9937
GarryK97/Python
/Hashtable/Task5.py
2,715
4.4375
4
from Task3 import HashTable def read_file_removesp(file_name): """ Read a text file and convert it to a list of words without any special characters. :param file_name: File to read :return: the list of words """ f = open(file_name, 'rt', encoding='UTF8') file_list = [] for l...
true
606de1aa9e681af56f022880698088b3ea58904d
nidakhawar/PracticePythonExcercises
/AverageOfSubjects.py
510
4.1875
4
biology=float(input("Please input your Biology score:")) chemistry=float(input("Please input your Chemistry score:")) physics=float(input("Please input your Physics score:")) if biology<40: print("Fail") if chemistry<40: print("Fail") if physics<40: print("Fail") else: score=((biology+chemistry+physics)/3) ...
true
976cc8ab3327128b679d3d205e8c2dc1b2daae0b
zacharykaczor/Small-Programs
/odd_numbers.py
535
4.1875
4
# Based on https://www.youtube.com/watch?v=LkIK8f4yvOU. # The Difference of Two Squares. number = int(input("Please enter a positive odd number: ")) while number % 2 == 0 or number < 0: number = int(input( "Please enter a positive number: " if number < 0 else "Please enter an odd number: " ))...
true
cc84abe6637d76e56a7ac2c958ebd7c8a808c1c1
ProspePrim/PythonGB
/Lesson 2/task_2_1.py
628
4.125
4
#Создать список и заполнить его элементами различных типов данных. #Реализовать скрипт проверки типа данных каждого элемента. #Использовать функцию type() для проверки типа. #Элементы списка можно не запрашивать у пользователя, а указать явно, в программе. list_a = [5, "asdv", 15, None, 10, "asdv", False] def type_...
false
bce8bf614aca3883f2ac618caa8f00bc32a5dd73
costacoz/python_design_patterns
/behavioral/iterator.py
1,296
4.5
4
# Iterators are built into Python. # It can be engaged, using 'iter(arg*)' function # arg* - can be list, tuple, dic, set and string. # Below is the example of using it. # fruits_tuple = {'apple', 'blueberry', 'cherry', 'pineapple'} # fruits_tuple = ('apple', 'blueberry', 'cherry', 'pineapple') # fruits_tuple = ['appl...
true
2724d92157d61f930c089931f2b55042dcfe9f0e
plaer182/Python3
/FizzBuzz(1-100)(hw2).py
354
4.15625
4
number = int(input('Enter the number: ')) if 0 <= number <= 100: if number % 15 == 0: print("Fizz Buzz") elif number % 3 == 0: print("Fizz") elif number % 5 == 0: print("Buzz") else: print(number) elif number < 0: print("Error: unknown symbol") else: ...
false
db6a67f488a152ccc2768d3d24728afb318f10de
CodecoolBP20172/pbwp-3rd-si-code-comprehension-kristofilles
/comprehension.py
2,101
4.3125
4
"""Its a bot what randomly choose a number between 1 and 20, and the user need to guess within 6 round what number was choosen by the bot.""" import random #import the random module guessesTaken = 0 #assign 0 to guessesTaken variable print('Hello! What is your name?') #print out this sentence myName = input() #assig...
true
07bd3a329eafee4c2398a08943aeb985a282b6f2
onionmccabbage/pythonTrainingMar2021
/using_ternary.py
474
4.40625
4
# Python has one ternary operator # i.e. an operator that takes THREE parts # all other operators are binary, i.e. they take TWO parts # e.g. a = 1 or 3+2 # the ternary operator works like this # 'value if true' 'logical condition' 'value if false' x = 6 y = 5 print("x" if x>y else "y") # alternative syn...
true
375b0579cdbe45e4a66d954f8d5e767f8ef70546
justEhmadSaeed/ai-course-tasks
/Python Assignment 1/Part 2/Task 5.py
261
4.28125
4
# Write a list comprehension which, from a list, generates a lowercased version of each string # that has length greater than five strings = ['Some string', 'Art', 'Music', 'Artifical Intelligence'] for x in strings: if len(x) > 5: print(x.lower())
true
23d0b02ba64c2aca3becf467d88c692109aab9f8
patnaik89/string_python.py
/condition.py
1,696
4.125
4
""" Types of conditional statements:- comparision operators (==,!=,>,<,<=,>=) logical operators (and,or,not) identity operators (is, is not) membership operators (in, not in) """ x, y = 2,9 print("Adition", x + y) print("multiplication", x * y) print("subtraction", x - y) print("division", x/y) pr...
false
f21b75948484cc34cea7d9d166dc47e72611749d
liadbiz/Leetcode-Solutions
/src/python/degree_of_array.py
1,373
4.15625
4
""" Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible length of a (contiguous) subarray of nums, that has the same degree as nums. Example 1: Input: [1, 2, 2, 3, 1] Output: 2 Explan...
true
ea03689b8be9bd5fab6af7d4e20d2ceae0d8e88b
reesporte/euler
/3/p3.py
534
4.125
4
""" project euler problem 3 """ def is_prime(num): if num == 1: return False i = 2 while i*i <= num: if num % i == 0: return False i += 1 return True def get_largest_prime_factor(num): largest = 0 i = 2 while i*i <= num: if num%i == 0: ...
false
bbeb124cd35e865c17ae7a9691022031b81ba553
jonahtjandra/sudoku-solver
/Sudoku.py
2,939
4.15625
4
class Sudoku: def __init__(self, board:'list[list]') -> None: if (len(board) != 9 or len(board[0]) != 9): raise "Expected a 9 by 9 board" self.board = board self.iterations = [] # for printing out the 2d list representation of the board def display(self, board:'list[list]'): ...
true
53da6c914c6b7139abf47e3b214b47725e93c50b
comalvirdi/CPE101
/LAB4/loops/cubesTable.py
1,518
4.3125
4
# CPE 101 Lab 4 # Name: def main(): table_size = get_table_size() while table_size != 0: first = get_first() increment = get_increment() show_table(table_size, first, increment) table_size = get_table_size() # Obtain a valid table size from the user def get_table_size(): size = int(i...
true
e9cb86ab9b68ed4b6f0c061f48629cb0eb270316
lguychard/loispy
/src/loispy/interpreter/procedure.py
2,279
4.28125
4
from environment import Environment class Procedure(object): """ Represents a loisp procedure. A procedure encapsulates a body (sequence of instructions) and a list of arguments. A procedure may be called: the body of the procedure is evaluated in the context of an environment, and given """ ...
true
2fa3fbd312b86064da4f77d85dd226575de9dcaf
Heisenberg27074/Web-Scraping-with-Python3
/lists/maxmin.py
724
4.3125
4
#Rewrite the program that prompts the user for a list of #numbers and prints out the maximum and minimum of the numbers at #the end when the user enters “done”. Write the program to store the #numbers the user enters in a list and use the max() and min() functions to #compute the maximum and minimum numbers after t...
true