blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
5031ef63a8e97b9b55df8c872002e5a03fff41e2
Magical-Man/Python
/Learning Python/practice/listprc.py
1,269
4.25
4
##Here what we are doing is just declaring a variable, and then printing some stuff ten_things = "Apples Oranges Crows Telephone Light Sugar" print("Wait, there are not 10 things in that list. Let's fix that.") ##Here we declare a variable assigned to the ten_things var, but split ##Then we make a list called more_...
true
07e495cda7220ffa3299cb09e7ee082ba57210e2
Magical-Man/Python
/Learning Python/functions/functions.py
994
4.75
5
#Functions let you make our own mini-scripts or tiny commands. #We create functions by using th word def in python #This function is like argv scripts #So here we create a function named print_two, and we call *args on it, just #Like argv def print_two(*args): arg1, arg2 = args print("arg1: %r, arg2: %r" %(ar...
true
fb20e6839f882a85e11b7275a54458dc1c3046a7
kalensr/pygrader
/prog_test_dir/Debug2.py
1,407
4.15625
4
# Debug Exercise 2 # Create a change-counting game that gets the user to enter the number of # coins required to make exactly one dollar. The program should prompt # the user to enter the number of pennies, nickels, dimes, and quarters. # If the total value of the coins entered is equal to one dollar, the # progr...
true
d4af8a596aed03f073999cf901a4d130875b8807
DWaze/CreateDB
/checkdb.py
230
4.15625
4
import sqlite3 conn = sqlite3.connect("contacts.sqlite") name = input("Please enter your name : ") sql_query = "SELECT * FROM contacts WHERE name LIKE ?" for row in conn.execute(sql_query, (name,)): print(row) conn.close()
true
e3a318a9cadbfc7d82b3ca5885c80c1bad4e1b36
VanessaTan/LPTHW
/EX03/ex3.py
1,178
4.375
4
#Subject introduction print "I will now count my chickens:" #Calculation of how many Hens. 30.0 divided by 6.0 + 25.0. print "Hens", 25.0 + 30.0 / 6.0 #Calculation of how many Roosters. (25.0x3.0 = 75.0) Take 75.0 ÷ 4.0 = 18 with remainder 3.0. Therefore: 100.0 - 3.0 = 97 print "Roosters", 100.0 - 25.0 * 3.0 % 4.0 #N...
true
4e72c4f48e96103d758a6c766d0b2aa76aed1822
anandkrthakur/AlgorithmsEveryProgrammerShouldKnow
/01a. BinarySearch_Iterative.py
1,206
4.15625
4
# Find out if a key x exists in the sorted list A # or not using binary search algorithm def binarySearch(A, x): # search space is A[left..right] (left, right) = (0, len(A) - 1) # till search space consists of at-least one element while left <= right: # we find the mid value in the ...
true
0dccf3b276606b24679a1fc520dc963f8f32600d
TsunamiMonsoon/InternetProgramming
/Homework3/Homework3.py
1,124
4.1875
4
import sqlite3 from os.path import join, split conn = sqlite3.connect("Courses.sq") # create a query cmd = "select * from Courses" # create a cursor crs = conn.cursor() # send a query and receive query result crs.execute(cmd) Courses = crs.fetchall() for row in Courses: print(row) cmd2 = "...
true
59924003253bf6eaf850df9876ceef651c38f84f
KuldeepJagrotiya/python
/function/isPalindrome.py
254
4.21875
4
## Q3 take the input from user and check if number is palindrome inp = (input("enter the number : ")) out = str() for i in range(len(inp)-1,-1,-1): out+=inp[i] if out==inp: print(inp,"is a palindrome") else: print(inp,"is not a palindrome")
true
46734740a355dcfab21ca9ed817eda423b106c51
mohitKhanna1411/COMP9020_19T3_UNSW
/Assignment_3/count_full_nodes.py
1,250
4.34375
4
# Python program to count full # nodes in a Binary Tree class newNode(): def __init__(self, data): self.data = data self.left = None self.right = None # Function to get the count of # full Nodes in a binary tree def getfullCount(root): if (root == None): return -1 if (ro...
true
cf326c3bd46d29e86cfa3574178dc2857a1d1a84
natanonsilver/General-Knowledge-City-Quiz-
/version 3.py
2,036
4.125
4
# In version 3 of my quiz i will doing my 10 question quiz that is a multichoice quiz. #asking user for name try: name=str(input("enter your name:")) if name == "1234": raise Exception except: input("Please try again, enter your name \n") #ask the user to enter there age. try: ...
true
d2af3f9c481bf5d868e446c186eb9c48efd75157
rdoherty2019/Computer_Programming
/forwards_backwards.py
1,024
4.1875
4
#setting accumulator num = 0 print("Using while loops") #Iterations while num <31: #If number is divisably by 4 and 3 if num % 4 == 0 and num % 3 == 0: #accumalte num += 3 #continue to next iterations continue #IF number is divisable by 3 print if num % 3 == 0 : ...
true
780e01cf0530b9f534adb390d52365ea99ca36aa
jc23729/day-1-3-exercise-1
/main.py
220
4.3125
4
#Write your code below this line 👇 #This code prints the number of characters in a user's name. print( len( input("What is your name? ") ) ) #Notes #If input was "Jack" #1st: print(len("Jack")) #2nd: print(4)
true
841bfb0cf506bdd439d2aa0f5b54814dfda31ebf
ani17/data-structures-algorithms
/merge-sort.py
906
4.15625
4
import math def mergeSort(A): # If no more divison possible through mergeSort return to "merge" logic # for merging subarrays back into same array by repacing values # accordingly if len(A) < 2: return # Keep Dividing Array in to Left & Right Sub Arrays mid = int(math.floor(len(A) / 2)) L = A[0 : mid] R ...
true
891262eabe5174b820a8b43673c21e222e8bad85
LeonVillanueva/Projects
/Daily Exercises/daily_17.py
473
4.15625
4
''' The ancient Egyptians used to express fractions as a sum of several terms where each numerator is one. For example, 4 / 13 can be represented as 1 / 4 + 1 / 18 + 1 / 468. Create an algorithm to turn an ordinary fraction a / b, where a < b, into an Egyptian fraction. ''' import numpy as np def e_frac (n, d...
true
bfc8e8f9574f6cdbe394ebeabee29b2b3a12f80e
aliabbas-s/tathastu_week_of_code
/day3/3.py
246
4.1875
4
#Day-3 #Program 3 string = input("Enter a Word") length = len(string) duplicate_string = "" for i in range(0,length): if string[i] in duplicate_string: continue else: duplicate_string += string[i] print(duplicate_string)
true
d0b6cc898aca8d016713caf44b36612a9f662fa1
SteeveJose/luminarpython
/languagefundamentals/largestamong2.py
243
4.125
4
num1=float(input("enter the first number:")) num2=float(input("enter the second number:")) if (num1>num2): print(num1,"is greater than",num2) elif (num2>num1): print(num2,"greater than",num1) else: print("the two numbers are equal")
true
0aee0120683e267da353a0af63e518cefebdd7da
TheodoreAI/puzzle
/algorithm.py
2,753
4.125
4
# Mateo Estrada # CS325 # 03/01/2020 # Description: This algorithm checks to see if the input solution to the 8-puzzle (also known as the sliding puzzle) is solvable. # Step 1: I choose my favorite puzzle: the 8-puzzle (puzzle number 12 from the list). # Step 2: The following rules were taken from: file:///Users/ma...
true
fd3a67b45acba3593efdd159ba41e1aa57b3c256
SushanShakya/pypractice
/Functions/14.py
298
4.21875
4
# Write a Python program to sort a list of dictionaries using Lambda nameSort = lambda x: x['name'] sample = [ { "name" : "Sushan" }, { "name" : "Aladin" }, { "name" : "Sebastian" }, ] sorted_list = sorted(sample,key=nameSort) print(sorted_list)
true
34dd81b6d4c5480951d6be4595848f0f4da63cdc
morisasy/data-analysis-with-python
/week1/multiplication.py
580
4.21875
4
#!/usr/bin/env python3 """ Make a program that gives the following output. You should use a for loop in your solution. 4 multiplied by 0 is 0 4 multiplied by 1 is 4 4 multiplied by 2 is 8 4 multiplied by 3 is 12 4 multiplied by 4 is 16 4 multiplied by 5 is 20 4 multiplied by 6 is 24 4 multiplied by 7 is 28 4 multiplie...
true
cb6eb22fff86e8a80974c2a21bbe88c2e53af786
PetersonZou/astr-119-session-4
/operators.py
724
4.1875
4
x=9 y=3 #integers #arithmetic operators print(x+y) #addition print(x-y) #subtraction print(x*y) #multiplication print(x/y) #division print(x%y) #modulus print(x**y) #exponentiation x=9.1918123 print(x//y) #floor division #Assignment operators x=9 #sets x to equal 9 x+=3 #x=x+3 print(x) x=9 x-=3 #x=x-3 pri...
true
09164664fb940298ad2dfa5fefa78c52121ab04d
carlavieira/code-study
/algorithms/sorting_searching/sparse_search.py
1,250
4.125
4
def sparse_search(arr, string): if not arr or not string: return -1 return recursive_binary_search(arr, string, 0, len(arr)-1) def recursive_binary_search(arr, string, first, last): if first > last: return -1 mid = (first + last) // 2 #that is not midd, find the closest nonempty value if not ...
true
edd7c8fb9a385d76702d906104eb9ccde836fa1e
vishnu2981997/Programming_Ques
/PROG QUES/1.py
2,902
4.1875
4
""" ID: 437 Given an array of n numbers. sort the array in ascending order based on given conditions: ---convert the elements of array to filesize formats ---convert the file sizes to corresponding binary representations ---sort the actual array based on number of 1's present in the binary representation of th...
true
74e106cda0e7a685124ea86603fe61faf9c2fa7f
Rich43/rog
/albums/3/challenge145_easy/code.py
1,818
4.34375
4
''' Your goal is to draw a tree given the base-width of the tree (the number of characters on the bottom-most row of the triangle section). This "tree" must be drawn through ASCII art-style graphics on standard console output. It will consist of a 1x3 trunk on the bottom, and a triangle shape on the top. The tree must ...
true
c8305d2dcb7962c7f460d4e44851d4a24c495e6e
Rich43/rog
/albums/3/challenge160_easy/code.py
2,037
4.25
4
''' (Easy): Trigonometric Triangle Trouble, pt. 1 A triangle on a flat plane is described by its angles and side lengths, and you don't need to be given all of the angles and side lengths to work out the rest. In this challenge, you'll be working with right-angled triangles only. Here's a representation of how this ...
true
f2a5494dea131dd5bacd09931c98aa04a4fb6e43
Rich43/rog
/albums/3/challenge87_easy/code.py
1,235
4.15625
4
''' Write a function that calculates the intersection of two rectangles, returning either a new rectangle or some kind of null value. You're free to represent these rectangles in any way you want: tuples of numbers, class objects, new datatypes, anything goes. For this challenge, you'll probably want to represent your...
true
401ec919e87f936bd9e31a9d4e413da50bddb44e
Rich43/rog
/albums/3/challenge23_easy/code.py
524
4.125
4
''' Input: a list Output: Return the two halves as different lists. If the input list has an odd number, the middle item can go to any of the list. Your task is to write the function that splits a list in two halves. ''' lst = [1, 2, 3, 4, 5] half_lst = len(lst) // 2 first_lst = [] second_lst = [] for x in rang...
true
d758ed97ea2aea49f6e70a9253952f6ba271e398
Rich43/rog
/albums/3/challenge168_easy/code.py
2,067
4.46875
4
''' So my originally planned [Hard] has issues. So it is not ready for posting. I don't have another [Hard] so we are gonna do a nice [Easy] one for Friday for all of us to enjoy. Description: We know arrays. We index into them to get a value. What if we could apply this to a string? But the index finds a "word". Imag...
true
12f29461a004ea1e8264153d5cfb473973ee153f
Rich43/rog
/albums/4/problem18.py/code.py
418
4.15625
4
def panagram(strng): '''(str) -> bool return whether the string is a panagram ''' sett = set() strng = strng.lower() for letter in strng: if letter.isalpha(): sett.add(letter) return len(s...
true
16652e2897466142fd0b285578018c150e0a5a5e
Rich43/rog
/albums/3/challenge126_easy/code.py
2,287
4.15625
4
''' Imagine you are an engineer working on some legacy code that has some odd constraints: you're being asked to implement a new function, which basically merges and sorts one list of integers into another list of integers, where you cannot allocate any other structures apart from simple temporary variables (such as...
true
5bcf6fd1c5bb4eb598aca0a9c70d0ee65d883a7a
Rich43/rog
/albums/3/challenge171_easy/code.py
1,983
4.125
4
''' Description: Today we will be making some simple 8x8 bitmap pictures. You will be given 8 hex values that can be 0-255 in decimal value (so 1 byte). Each value represents a row. So 8 rows of 8 bits so a 8x8 bitmap picture. Input: 8 Hex values. example: 18 3C 7E 7E 18 18 18 18 Output: A 8x8 picture that represen...
true
469bcb352f966ce525cc49271d3c707085ce1e17
Rich43/rog
/albums/3/challenge10_easy/code.py
866
4.53125
5
'' The exercise today asks you to validate a telephone number, as if written on an input form. Telephone numbers can be written as ten digits, or with dashes, spaces, or dots between the three segments, or with the area code parenthesized; both the area code and any white space between segments are optional. Thus, all...
true
458fcbc5b06298bd4fc084465f91f1a86bae2e17
Rich43/rog
/albums/3/challenge149_easy/code.py
1,838
4.25
4
''' Disemvoweling means removing the vowels from text. (For this challenge, the letters a, e, i, o, and u are considered vowels, and the letter y is not.) The idea is to make text difficult but not impossible to read, for when somebody posts something so idiotic you want people who are reading it to get extra frustrate...
true
d702030522318f0d1aa5c9c134e670bf2dd23db5
Rich43/rog
/albums/3/challenge41_easy/code.py
967
4.15625
4
''' Write a program that will accept a sentence as input and then output that sentence surrounded by some type of an ASCII decoratoin banner. Sample run: Enter a sentence: So long and thanks for all the fish Output ***************************************** * * * So long and th...
true
dc507cd0c38636a157f79882827f66505af93ee2
Rich43/rog
/albums/3/challenge193_easy/code.py
1,657
4.4375
4
''' An international shipping company is trying to figure out how to manufacture various types of containers. Given a volume they want to figure out the dimensions of various shapes that would all hold the same volume. Input: A volume in cubic meters. Output: Dimensions of containers of various types that would hold ...
true
93ea951e7c2eb9c49eab5ecaefba68570832a79a
Rich43/rog
/albums/3/challenge191_easy/code.py
1,995
4.25
4
''' You've recently taken an internship at an up and coming lingustic and natural language centre. Unfortunately, as with real life, the professors have allocated you the mundane task of counting every single word in a book and finding out how many occurences of each word there are. To them, this task would take hours...
true
83e038b449f0db56788edf9ac5a8d41898141dd9
Rich43/rog
/albums/3/challenge199_easy/code.py
2,042
4.15625
4
''' You work for a bank, which has recently purchased an ingenious machine to assist in reading letters and faxes sent in by branch offices. The machine scans the paper documents, and produces a file with a number of entries which each look like this: _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_| ||_ _| |...
true
7634f458818e574f22aee33c9c64e0263bc51312
Rich43/rog
/albums/3/challenge194_easy/code.py
2,678
4.25
4
''' Most programming languages understand the concept of escaping strings. For example, if you wanted to put a double-quote " into a string that is delimited by double quotes, you can't just do this: "this string contains " a quote." That would end the string after the word contains, causing a syntax error. To remedy...
true
b22a560b7c2cdfae02f5a0e47cfc9a9714f5986f
Rich43/rog
/albums/3/challenge33_easy/code.py
885
4.125
4
''' This would be a good study tool too. I made one myself and I thought it would also be a good challenge. Write a program that prints a string from a list at random, expects input, checks for a right or wrong answer, and keeps doing it until the user types "exit". If given the right answer for the string printed, it...
true
84e5a596be210ab77c029504c094f3328162aba2
Rich43/rog
/albums/3/challenge34_easy/code.py
373
4.25
4
''' A very basic challenge: In this challenge, the input is are : 3 numbers as arguments output: the sum of the squares of the two larger numbers. Your task is to write the indicated challenge. ''' #nums = input('Input three numbers in the form 1/2/3 : ') nums = '5/8/4' nums = sorted(nums.split('/')) ans = (fl...
true
3fda92e3ae36967245d8366a30d54987ef9f3694
kaczifant/Elements-of-Programming-Interviews-in-Python-Exercises
/string_integer_interconversion.py
1,767
4.25
4
# 6.1 INTERCONVERT STRINGS AND INTEGERS # Implement an integer to string conversion function, and a string to integer conversison function. # Your code should handle negative integers. You cannot use library functions like int in Python. from test_framework import generic_test from test_framework.test_failure imp...
true
57f902e278e495aa66de4b3cc1408aaebfbda91e
cory-schneider/random-article-generator
/writer.py
2,873
4.21875
4
#!/usr/bin/python3 #Pulls from a word list, creates "paragraphs" of random length, occasionally entering a blank line. #User Inputs: # word list file path # test file, exit if bad path # print word count # file name for output # number of paragraphs # min words per paragraph (prompt user not to use...
true
dc282841394adaf3cd83d97bf55e1e7bedfbab15
saarco777/Centos-REpo
/User age - Pub.py
672
4.21875
4
# define your age name = input('Hi there, whats your name?') # user defines their name age = input('How old are you?') # user gets asked whats their age if int(age) > 20: print('Hi', name, 'Welcome in, Please have a Drink!') # if age is bigger than 20, user gets inside and HAS a drink elif int(age) < 20 and...
true
dacafce3f5455a01d105f0f3e017dc17d5f3efde
dark-glich/data-types
/Tuple.py
874
4.59375
5
# tuple : immutable - ordered tuple_1 = (1, 2, 3, 4, 2, 5, 2, ) print(f"original name : {tuple_1}") # tuple[index] is used to access a single item from the tuple. print(f"tuple[2] : {tuple_1[2]}") # tuple.index[value] is used to get the index of a value. x = tuple_1.index(3) print(f"tuple.index : {x}") # tupl...
true
cecd850e5ac271d9cf8f27faf059188ecf53f8c6
xiaojias/python
/development/script.py
1,383
4.28125
4
my_name = "Codecademy" print("Hello and welcome " + my_name + " !") # Operators message = "First Name" message += ", Sure Name" print(message) # Comment on a single line user = "Jdoe" # Comment after code # Arithmetic operators result = 10 + 20 result = 40 - 30 result = 20 * 2 result = 16 / 4 result = 25 % 2 resul...
true
b5694e5bb2c3d591d886a5f21f63f5ef0f1dcadc
gururajh/python-standard-programs
/Fibonacci.py
1,995
4.15625
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 29 14:27:50 2022 @author: Gururaja Hegde V' """ """Write a program to generate Fibonnaci numbers. The Fibonnaci seqence is a sequence of numbers where the next number in the sequence is the sum of the previous two numbers in the sequence. The sequence looks like...
true
1382f8c14d706cf5c5a089821a0e0211b5d5c8f4
AmGhGitHub/SAGA_Python
/py_lesson8.py
1,164
4.40625
4
# Arithmetic operators x = 10.0 y = 3.1415 exponent = 3 print("sum:", x + y) # addition print("subtraction:", x - y) # addition print("multiplication:", x * y) # multiplication print("float division:", x / y) # float division print("floor division:", int(x) // int(y)) # floor division print("modulus:", in...
true
9ec395003a967ab68c644c01cd3a792fc27a0d67
AmGhGitHub/SAGA_Python
/py_lesson17.py
1,657
4.1875
4
class Well: """ Well class for modelling vertical well performance """ def __init__(self, radius, length): """ Initialize well attributes :param radius (float): radius of the well in ft :param length (float): productive length of the well ...
true
6e21a23abb976fbfd248c0e107ad86250bed9c12
raberin/Sorting
/src/recursive_sorting/recursive_sorting.py
2,749
4.25
4
# TO-DO: complete the helpe function below to merge 2 sorted arrays def merge(arrA, arrB): merged_arr = [] arrA_index = 0 arrB_index = 0 # Until the merged_arr is as big as both arrays combined while len(merged_arr) < len(arrA) + len(arrB): print( f"arrA_index = {arrA_index}, arr...
true
26c5201471d8948cfe707093710a05820f85e72b
CatLava/oop_practice
/car.py
697
4.28125
4
class Car: def __init__(self, color, mileage): self.color = color self.mileage = mileage # This is a built in function for only car # Put a repr on any defined class, this helps to understand it def __repr__(self): return 'Car({self.mileage})'.format(self=self) # Python buil...
true
de853c093fd83515f4a98a5f4c453272a6b5579c
sethifur/cs3030-seth_johns_hw5
/seth_johns_hw5.py
918
4.25
4
#!/usr/bin/env python3 import sys def GetInput(): """ Function: asks for a pin input <9876> validates the size, type, and number. returns pin if correct if incorrect 3 times exits program """ for index in range(3): try: pin = int(input('Enter your p...
true
cdcdb23d6ac63da1b095a1ee68be9b97e4643c20
niko-vulic/sampleAPI
/leetcodeTester/q35.py
1,744
4.1875
4
# 35. Search Insert Position # Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. # You must write an algorithm with O(log n) runtime complexity. from typing import List class Solution: def ...
true
7fff33692bf4f4aad318681b76b177bb021f6637
niko-vulic/sampleAPI
/leetcodeTester/q121.py
1,311
4.125
4
# 121. Best Time to Buy and Sell Stock # You are given an array prices where prices[i] is the price of a given stock on the ith day. # You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. # Return the maximum profit you can achieve f...
true
1aca8af29f7519569145abfe34d3cd2efa535327
enderceylan/Projects
/Solutions/FibonacciSequence.py
390
4.3125
4
# Fibonacci Sequence - Enter a number and have the program generate the Fibonacci # sequence to that number or to the Nth number. # Solution by Ender Ceylan x = 1 y = 1 num = int(input("Enter the amount of Fibonacci values to be viewed: ")) while num <= 0: num = int(input("Input must be above 0: ")) for i in range...
true
08eb776f982387f55fe513b09a624472c158dc5f
dhrvdwvd/practice
/python_programs/34_pr_04.py
206
4.1875
4
names = ["dhruv", "ratnesh", "abhinav", "jaskaran"] name = input("Enter a name to search: ") if name in names: print(name+" is present in the list.") else: print("Name entered is not in the list.")
true
3ff3ba9cd497c199e24a8683e59595802bedc4f2
dhrvdwvd/practice
/python_programs/06_operators.py
238
4.3125
4
a = 3 b = 4 # Arithmetic Operators print("a + b = ", a+b) print("a - b = ", a-b) print("a * b = ", a*b) print("a / b = ", a/b) # Python gives float when two ints are divided. # Assignment operators. a = 12 a+=22 a-=12 a*=2 a/=4 print(a)
true
06ead9d50bb8b9eaad3a0c1bf43434331bcda7cb
dhrvdwvd/practice
/python_programs/66_try.py
425
4.21875
4
while(True): print("Press q to quit") a = input("Enter a number: ") if(a == 'q'): break try: a = int(a) if(a>6): print("Entered number is greater than 6.") except Exception as e: print(e) # This breaks the loop as well. print("Thanks for playing the game.") # The try-exc...
true
bdec843924ca0e0e4e45ccd6bd315245098bf6ec
dhrvdwvd/practice
/python_programs/12_strings_slicing.py
331
4.15625
4
greeting = "Hello, " name = "DhruvisGood" #print(greeting + name) #print(name[0]) #name[3] = 'd' --> does not work # String can be accessed but not changed. print(name[0:3]) # is same as below print(name[:3]) print(name[1:]) # will print from index 1 to last index print(name[1:8:2]) # will start printing index 1, 1+...
true
0137946f7a9ea9bbdae58fc8d79266575689cf32
dhrvdwvd/practice
/python_programs/50b_genrators.py
1,590
4.78125
5
""" Iterables are those objects for which __iter__() and __getitem__() methods are defined. These methods are used to generate an iterator. Iterators are those objects for __next__() method is defined. Iterations are process through which the above are accessed. If I wish to traverse in a python object (string, lis...
true
6769020adb8b369e75113cf4f75cc06060dc5214
ma-henderson/python_projects
/05_rock_paper_scissors.py
2,297
4.34375
4
import random message_welcome = "Welcome to the Rock Paper Scissors Game!" message_name = "Please input your name!" message_choice = "Select one of the following:\n- R or Rock\n- P or Paper\n- S or Scissors" message_win = "You WON!" message_loss = "You LOST :(" message_end = "If you'd like to quit, enter 'q' or 'quit'"...
true
1184cff6fc360e4a0bfd5754ed1312be4cf624f1
ivanjankovic16/pajton-vjezbe
/Exercise 9.py
885
4.125
4
import random def Guessing_Game_One(): try: userInput = int(input('Guess the number between 1 and 9: ')) random_number = random.randint(1, 9) if userInput == random_number: print('Congratulations! You guessed correct!') elif userInput < random_number: print(f'You guessed to low! The correct answer is...
true
4b3d8f8ce9432d488a4ee4ebdc2bec1256939dbe
ivanjankovic16/pajton-vjezbe
/Exercise 16 - Password generator solutions.py
675
4.21875
4
# Exercise 16 - Password generator solutions # Write a password generator in Python. Be creative with how you generate # passwords - strong passwords have a mix of lowercase letters, uppercase # letters, numbers, and symbols. The passwords should be random, generating # a new password every time the user asks for a...
true
4713b2790c09b0f5f98e8f544c0a961ef87c2ea5
ivanjankovic16/pajton-vjezbe
/Exercise 13 - Fibonacci.py
1,204
4.625
5
# Write a program that asks the user how many Fibonnaci numbers # to generate and then generates them. Take this opportunity to # think about how you can use functions. Make sure to ask the user # to enter the number of numbers in the sequence to generate.(Hint: # The Fibonnaci seqence is a sequence of numbers wher...
true
e1d4247baca7c6291bd0fa90b51d920c86adb81b
csdaniel17/python-classwork
/string_split.py
1,387
4.125
4
## String split # Implement the string split function: split(string, delimiter). # Examples: # split('abc,defg,hijk', ',') => ['abc', 'defg', 'hijk'] # split('JavaScript', 'a') => ['J', 'v', 'Script'] # split('JaaScript', 'a') => ['J', '', 'Script'] # split('JaaaScript', 'aa') => ['J', 'aScript'] def str_split(str,...
true
cf6b1e2e097358113767dc766af9ebd853d52933
Audodido/IS211_Assignment1
/assignment1_part2.py
716
4.28125
4
class Book: """ A class to represent a book Attributes: author (string): Name of the author title (string): Title of the book """ def __init__(self, author, title): """ Constructs all the necessary attributes for the Book object. """ sel...
true
9f020702dc8684050f12bca0a0610309033c7bc3
saradcd77/python_examples
/abstract_base_class.py
1,120
4.40625
4
# This example shows a simple use case of Abstract base class, Inheritance and Polymorphism # The base class that inherits abstract base class in python needs to override it's method signature # In this case read method is overriden in methods of classes that inherits Electric_Device # Importing in-built abstract base...
true
22e801ed46b26007bbd7880dce3197fbc3e04a7c
simonzahn/Python_Notes
/Useful_Code_Snippets/DirectorySize.py
522
4.375
4
#! python3 import os def dirSize(pth = '.'): ''' Prints the size in bytes of a directory. This function takes the current directory by default, or the path specified and prints the size (in bypes) of the directory. ''' totSize = 0 for filename in os.listdir(pth): totSize += os.pa...
true
1672167ecd1302e8bfff3da2f790d69ff6889be4
KatGoodwin/LearnPython
/python_beginners/sessions/strings-basic/examples/.svn/text-base/string_concatenation.py.svn-base
734
4.125
4
# concatenating strings newstring = "I am a " "concatenated string" print newstring concat = "I am another " + "concatenated string" print concat print "Our string is : " + newstring # The above works, but if doing a lot of processing would be inefficient. # Then a better way would be to use the string join() met...
true
54415d27cdec4ce01ede31c8a87f330bb703ce59
tomgarcia/Blabber
/markov.py
2,284
4.21875
4
#extra libraries used import queue import tools import random """ markov_chain class is a class that creates a(n) markov chain statistical model on an inputted list of objects. The class is then able to generate randomly a new list of objects based on the analysis model of the inputted list. """ class markov_chain: ...
true
e52255d28a1e9c0d55ce5a296e384e1d7746b87d
mediter/Learn-Python-the-Hard-Way-notes-and-practices
/ex7.py
1,138
4.46875
4
# -*- coding: utf-8 -*- # Exercise 7: More Printing print "Mary had a little lamb." print "Its fleece was white as %s." % 'snow' print "And everywhere that Mary went." print "." * 12 # what would that do? end1 = 'C' end2 = 'h' end3 = 'e' end4 = 'e' end5 = 's' end6 = 'e' end7 = 'B' end8 = 'u' end9 = 'r' end10 = 'g' ...
true
660472dd3ec4d4ab685c784ea85dc540e6eb45c9
mediter/Learn-Python-the-Hard-Way-notes-and-practices
/ex9.py
923
4.28125
4
# -*- coding: utf-8 -*- # Exercise 9: Printing, Printing, Printing # Here's some new strange stuff, remember to type it exactly days = "Mon Tue Wed Thu Fri Sat Sun" # \n would make the stuff after it begin on a new line months = "\nJan\nFeb\nMar\nApr\nMay\nJun" # if a comma is added to the above statement, it woul...
true
10dc31cc92bc284cb08fde0fda5cdb312da06025
Sayed-Tasif/my-programming-practice
/math function.py
256
4.34375
4
Num = 10 Num1 = 5 Num2 = 3 print(Num / Num1) # used to divide print(Num % Num2) # used to see remainder print(Num2 ** 2) # indicates something to the power {like ( "number" ** "the power number")} print(Num2 * Num1) # used to multiply the number
true
c781089190d266c5c3649f4ff96736fc1dfe8b1d
YanSongSong/learngit
/Desktop/python-workplace/homework.py
217
4.1875
4
one=int(input('Enter the first number:')) two=int(input('Enter the second number:')) three=int(input('Enter the third number:')) if(one!=two and one!=three and two!=three): a=max(one,two,three) print(a)
true
95cafd3e875061426d39fd673bbf6327c5eb7c14
krwinzer/web-caesar
/caesar.py
489
4.25
4
from helpers import alphabet_position, rotate_character def encrypt(text, rot): code = '' for char in text: if char.isalpha(): char = rotate_character(char, rot) code = code + char else: code = code + char return (code) def main(): text = input(...
true
a337618daafddfb9224eda521e2e03644f204a0e
Seun1609/APWEN-Python
/Lesson2/quadratic.py
1,141
4.21875
4
# Get inputs a, b and c # The coefficients, in general, can be floating-point numbers # Hence cast to floats using the float() function a = float(input("Enter a: ")) b = float(input("Enter b: ")) c = float(input("Enter c: ")) # Compute discriminant D = b*b - 4*a*c if D >= 0: # There are real roots # x1...
true
30115c3de0f19d9878f2b00c1abf998b7b36a9fb
stansibande/Python-Week-Assignments
/Functions.py
2,048
4.25
4
#name and age printing function def nameAge(x,y): print ("My name is {} and i am {} Years old.".format(x,y)) #take two numbers and multiply them def multiply(x,y): result=x*y print("{} X {} = {}.".format(x,y,result)) #take two numbers and check if a number x is a multiple of a number Y def mul...
true
1f07e8a2872c37d2a6a74c0ef5a6e9c997d3d6ea
UCSD-CSE-SPIS-2021/spis21-lab03-Vikram-Marlyn
/lab03Warmup_Vikram.py
928
4.40625
4
# Vikram - A program to draw the first letter of your name import turtle def draw_picture(the_turtle): ''' Draw a simple picture using a turtle ''' the_turtle.speed(1) the_turtle.forward(100) the_turtle.left(90) the_turtle.forward(100) the_turtle.left(90) the_turtle.forward(100) ...
true
9a7ed39510c516c2e7da84be43a8f8c2a488a337
v-stickykeys/bitbit
/python/mining_simplified.py
2,043
4.1875
4
import hashlib # The hash puzzle includes 3 pieces of data: # A nonce, the hash of the previous block, and a set of transactions def concatenate(nonce, prev_hash, transactions): # We have to stringify it in order to get a concatenated value nonce_str = str(nonce) transactions_str = ''.join(transactions) ...
true
63c362549cdfdeeea249d6d31df11e8fca7748e3
herr0092/python-lab3
/exercise8.py
400
4.34375
4
# Write a program that will compute the area of a circle. # Prompt the user to enter the radius and # print a nice message back to the user with the answer. import math print('===================') print(' Area of a Circle ') print('===================') r = int(input('Enter radius: ')) area = math.pi * ( r * r) ...
true
02096c3d2fcff25f2a680e34586a56d8d7ca1f89
evb-gh/exercism
/python/guidos-gorgeous-lasagna/lasagna.py
1,299
4.1875
4
"""Functions used in preparing Guido's gorgeous lasagna. Learn about Guido, the creator of the Python language: https://en.wikipedia.org/wiki/Guido_van_Rossum """ EXPECTED_BAKE_TIME = 40 PREPARATION_TIME = 2 def bake_time_remaining(minutes): """Calculate the bake time remaining. :param elapsed_bake_time: i...
true
80df60b4c750e3e98e1c00c0d083e3582cbd4093
zee7han/algorithms
/sorting/insertion_sort.py
504
4.28125
4
def insertion_sort(arr): for i in range(1,len(arr)): position = i current_value = arr[i] print("position and current_value before", position, current_value) while position > 0 and arr[position-1] > current_value: arr[position] = arr[position-1] position = pos...
true
027a6c2e0251e68ff32feef6b1b1710692c7e8f2
Sem31/Data_Science
/2_Numpy-practice/19_sorting_functions.py
1,376
4.125
4
#Sorting Functions import numpy as np #np.sort() --> return sorted values of the input array #np.sort(array,axis,order) print('Array :') a = np.array([[3,7],[9,1]]) print(a) print('\nafter applying sort function : ') print(np.sort(a)) print('\nSorting along axis 0:') print(np.sort(a,0)) #order parameter in sort func...
true
e6c02fe3a07681cc415d9aa0e0257705aca65492
Rishivendra/Turtle_Race_Game
/3.Turtle_race.py
1,281
4.25
4
from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) # sets the width and height of the main window user_bet = screen.textinput(title="Make your bet", prompt="Which turtle will win the race? Enter color:") # Po...
true
6206eb9dc2cb71a50b5f75a1e9c8ffd11ba8e15c
Polaricicle/practical03
/q3_find_gcd.py
1,231
4.40625
4
#Filename: q3_find_gcd.py #Author: Tan Di Sheng #Created: 20130218 #Modified: 20130218 #Description: This program writes a function that returns the greatest common #divisor between two positive integers print("""This program displays a the greatest common divisor between two positive integers.""") #Creates a loop so...
true
5a734d271228ba71cd34021f260885193bba923d
abbyto/QUALIFIER
/main.py
495
4.125
4
import difflib words= ['i','have','want','a','test','like','am','cheese','coding','sleeping','sandwich','burger'] def word_check(s): for word in s.casefold().split(): if word not in words: suggestion= difflib.get_close_matches(word, words) print(f'Did you mean {",".join(str(x)for x in suggestion)} i...
true
7ed458e350f78585fc568c5ad7fc9913077b7890
BethMwangi/DataStructuresAndAlgorithms
/Arrays/operations.py
1,693
4.34375
4
# Accessing an element in an array array = [9,4,5,7,0] print (array[3]) # output = 7 # print (array[9])---> This will print "list index out of range" since the index at 9 is not available. # Insertion operation in an array # One can add one or more element in an array at the end, beginning or any given index #...
true
b2ecec901924b48a30b420c2b87c3f9087872bd5
alabiansolution/python-wd1902
/day4/chapter7/mypackage/code1.py
755
4.4375
4
states = { "Imo" : "Owerri", "Lagos" : "Ikeja", "Oyo" : "Ibadan", "Rivers" : "Port Harcourt", "Taraba" : "Yalingo", "Bornu": "Maidugri" } def my_avg(total_avg): ''' This function takes a list of numbers as an argument and returns the average of that list ''' sum = 0 for x in total_avg...
true
d9b7c5980339a47d34694780934f8828440ff379
666176-HEX/codewars_python
/Find_The_Parity_Outlier.py
524
4.5
4
""" You are given an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer N. Write a method that takes the array as an argument and returns this "outlier" ...
true
053d6552e18849fe13c14f0e4d229624f1f19076
mohitsoni7/oops_concepts
/oops5_dunder_methods.py
2,300
4.40625
4
""" Dunder methods / Magic methods / Special methods ================================================ These are special methods which are responsible for the certain types of behaviour of objects of every class. Also, these methods are responsible for the concept of "Operator overloading". O...
true
a47be7352926ddacb098ca2fd795af56e691c137
mickyaero/Practice
/read.py
951
4.71875
5
""" #It imports the thing argv from the library already in the computer "sys" from sys import argv #Script here means that i will have to type the filename with the python command and passes this argument to the "filename" script, filename = argv #OPen the file and stores it in text variable text = open(filename) #pr...
true
535282c6449efc953b8fc171d0ca08e95fb79ac2
DonalMcGahon/Problems---Python
/Smallest&Largest.Q6/Smallest&Largest.py
515
4.4375
4
# Create an empty list lst = [] # Ask user how many numbers they would like in the list num = int(input('How many numbers: ')) # For the amount of numbers the user wants in the list, ask them to enter a number for each digit in the list for n in range(num): numbers = int(input('Enter number ')) # .append adds ...
true
10781a10fa8cbac266fb58bcd1b87a033d2e842b
DonalMcGahon/Problems---Python
/Palindrome.Q7/Palindrome.py
349
4.59375
5
# Ask user to input a string user_string = str(input('Enter a string to see if it is palindrome or not: ')) # This is used to reverse the string string_rev = reversed(user_string) # Check to see if the string is equal to itself in reverse if list(user_string) == list(string_rev): print("It is palindrome") else: ...
true
df5d470412dbee029d29972f1dc66b8fe4af7912
bernardukiii/Basic-Python-Scripts
/YourPay.py
611
4.28125
4
# Write a program to prompt the user for hours and rate per hour using input to compute gross pay. # Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25). # You should use input to read a string and float() to convert the string to a number. # Do not worry about error checking or...
true
1f85c84c848524dd0056d74fa6cb6ca3e4bbe3f2
pratikmahajan2/My-Python-Projects
/Guess The Number Game/06 GuessTheNumber.py
536
4.15625
4
import random my_number = random.randint(0,100) print("Please guess my number - between 0 and 100: ") while True: your_number = int(input("")) if your_number > 100 or your_number < 0: print("Ohhoo! You need to enter number between 0 and 100. Try again") elif (your_number > my_number): print("You...
true
924fde1d0ded0a114f314cfe2560672f7736a629
Theodora17/TileTraveller
/tile_traveller.py
1,911
4.46875
4
# Functions for each movement - North, South, East and West # Function that updates the position # Function that checks if the movement wanted is possible def north(first,second) : if second < 3 : second += 1 return first, second def south(first,second) : if second > 1 : second -= 1 ...
true
58872f4d3554c2849ffeb4c978451bfbf415cfb3
mparker24/EvensAndOdds-Program
/main.py
622
4.25
4
#This asks the user how many numbers they are going to input question = int(input("How many numbers do you need to check? ")) odd_count = 0 even_count = 0 #This asks for a number and outputs whether its even or odd for i in range(question): num = int(input("Enter number: ")) if (num % 2) == 0: print(f"{num} is...
true
50934c184a7b7248bfae0bdcfba6c6a002d38f59
erikseyti/Udemy-Learn-Python-By-Doing
/Section 2 - Python Fundamentals/list_comprehension.py
766
4.46875
4
# create a new list with multiples by 2. numbers = [0,1,2,3,4] doubled_numbers = [] # a more simple way with a for loop # for number in numbers: # doubled_numbers.append(number *2) # print(doubled_numbers) # with list comprehension: doubled_numbers = [number *2 for number in numbers] print(doubled_numbers) # u...
true
f3b0cd25318048ca749c91aecd7ee53e36327221
sloaneluckiewicz/CSCE204
/CSCE204/exercises/mar9/functions3.py
1,190
4.28125
4
def factorial(): num = int(input("Enter number: ")) answer = 1 # error invalid input return = takes you out of the function if num < 1: print("Invalid number") return for i in range(1, num+1): answer *= i print(f"{num}! = {answer}") def power(): base = int(input...
true
e8ba520b71bcb4af787d39ad3bca0521c806c433
sloaneluckiewicz/CSCE204
/CSCE204/exercises/feb23/mult_tables.py
449
4.125
4
# multiplication table """ 1 2 3 4 5 1 4 6 8 10 """ tableSize = int(input("Enter size of table: ")) for row in range(1, tableSize+1): # loop through rows for col in range(1, tableSize+1): # for every row loop their cols ans = row * col # if there is just one digit in the number ...
true
09c598aa5bfd2a7489b5e30d6723ae6a39cdc04a
ceeblet/OST_PythonCertificationTrack
/Python1/python1/space_finder.py
287
4.15625
4
#!/usr/local/bin/python3 """Program to locate the first space in the input string.""" s = input("Please enter a string: ") pos = 0 for c in s: if c == " ": print("First space occurred at position", pos) break pos += 1 else: print("No spaces in that string.")
true
5bbd0ab39d4112ccac8775b398c37f8f13f42345
ceeblet/OST_PythonCertificationTrack
/Python1/python1/return_value.py
1,259
4.375
4
#!/usr/local/bin/python3 def structure_list(text): """Returns a list of punctuation and the location of the word 'Python' in a text""" punctuation_marks = "!?.,:;" punctuation = [] for mark in punctuation_marks: if mark in text: punctuation.append(mark) return punctuation, text.find('Py...
true