blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
58dc7132e5d27b817d7e7e0addd084bcbc13514a
dpattayath/algo
/sort/insertion_sort.py
620
4.125
4
""" Time Complexity: O(n*2) Auxiliary Space: O(1) Boundary Cases: Insertion sort takes maximum time to sort if elements are sorted in reverse order. And it takes minimum time (Order of n) when elements are already sorted. Algorithmic Paradigm: Incremental Approach Sorting In Place: Yes Stable: Yes """ def insertion_...
true
f6a276e00d0c508aced99af680c5264e032a7396
LillianGab/gwc
/secretword.py
1,733
4.375
4
# import random # # A list of words that # potential_words = ["example", "words", "someone", "can", "guess"] # word = random.choice(potential_words) secret_word = "hydration" # Use to test your code: # print(word) # Converts the word to lowercase secret_word = secret_word.lower() # Make it a list of letters for s...
true
d8208f57056742c2c01a5f4f26495e2dafe51799
cbowler6/cp1404practicals
/prac_02/ascii_table.py
722
4.25
4
def main(): UPPER = 127 LOWER = 33 # character = input("Enter a character:") # print("The ASCII code for {} is {}".format(character, ord(character))) # ASCII_code = int(input("Enter a number between 33 and 127")) # while ASCII_code < LOWER or ASCII_code > UPPER: # print("must be a numbe...
true
894667c6e084f71ede0690d4f48a46b126417897
vknguyen1902/python-practice
/basic-python/16-enter-name-list-comprehension.py
484
4.40625
4
names = [] for _ in range(5): name = input("Please enter a name: ") names.append(name) #Use list comprehension to create list of lowercased names lowercased = [name.lower() for name in names] #Use list comprehension to create list of titlecased names titlecased = [name.title() for name in lowercased] invitat...
true
49ce77d15f0141a29451169982a9832f0e3d3e59
avinash142857/numerical
/mc_pi_array.py
1,668
4.25
4
#This is numerical estimate of pi based on Monte Carlo method using unit circle inscribed in rectangle. #Outputs pi estimate in terminal and also plot based on number of random points inputed by user. #This code based on previous version at https://gist.github.com/louismullie/3769218. import numpy as np import matplot...
true
6d7d99bf118f93498c7b2a21a0a78069607aa1c4
kHarshit/python-projects
/newton's_square_root.py
917
4.5625
5
# Suppose that you want to know the square root of n. If you start with almost any approximation, you can compute # a better approximation (closer to the actual answer) with the following formula: # better = (approx + n/approx)/2 # This is an example of an indefinite iteration problem: we cannot predict in advance h...
true
cbfa11223c6ce5844abc0725600abf0625b20ac3
mihaimusat/Multithreaded-Marketplace
/tema/consumer.py
2,025
4.21875
4
""" This module represents the Consumer. Computer Systems Architecture Course Assignment 1 March 2020 """ from threading import Thread from time import sleep class Consumer(Thread): """ Class that represents a consumer. """ def __init__(self, carts, marketplace, retry_wait_time, **kwargs): "...
true
d859c73b33eaddc37b7dd93da75126c199742e01
nicocra/AutomateTheBoringStuffWithPython
/Chapter_6_Project/printTable.py
764
4.15625
4
#! Python3 # Take a list of lists and prints a well arranged table tableData = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose']] def printTable(table): itemLength = [0] * len(table) colWith = [0] * len(table) for i in range(len(table))...
true
6c8ab7e61538e3362241be0f84cd48606f5a7028
RobertoAffonso/Python-Course
/StringFormatting/StringFormatting.py
1,068
4.40625
4
age = 21 print("My age is: " + str(age) + " Years") # The "str()" Method, converts the value inside the brackets to a String # # print("My age is: {0} years".format(age)) # The {0} is called a replacement field, where the object inside the field # # will be converted to a Stri...
true
d3b87f0fe615e81e9271521a6cbc8974900e80c6
RobertoAffonso/Python-Course
/RangesChallenge/.idea/rangesChallenge.py
654
4.125
4
alphabet = "abcdefghijklmnopqrstuvwxyz" print("{}".format(alphabet[1:5:2])) small_decimals = range(0, 10) my_range = small_decimals[::2] print(my_range) print(my_range.index(4)) o = range(0, 100, 4) print(o) p = o[::5] # If you set a new value in the 'step' value, it will multiply the previously set value by the n...
true
b2b2a2162b497ccc33d698bf05395da1fcfccdcb
RobertoAffonso/Python-Course
/ContinueBreakElse/continuebreak.py
889
4.1875
4
# shopping_list = ["Milk", "Pasta", "Rice", "Spam", "Eggs", "Bread"] # # for item in shopping_list: # if item == 'Spam': # continue # 'continue' skips the current value, and forces the loop to begin the next iteration # print("Buy " + item) # # print('') # Empty space just to organize the code :) # pr...
true
079e849a61a1dc34a374a50267ceded79c022f6e
tjr127/bitesofpy
/106/vowels.py
1,349
4.1875
4
from typing import Tuple text = """ The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special...
true
56fa8fde317ed64e373e086e463d793e17d8430a
willianantunes/python-playground
/python_tricks_the_book/src/topic_6/list_comprehensions.py
792
4.21875
4
squares = [x * x for x in range(10)] print(squares) # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] ''' value = [expression for item in collection] value = [] for item in collection: values.append(expression) The `squares = [x * x for x in range(10)]` is translated to the following: squares = [] for x in range(10): ...
true
f0575e89cce327e813782d5aee31d767f61e72e1
ShantanuJhaveri/LM-Intro_ML
/AppofML_ITP449/Code_repo/hw3_files/HW3_Q1_Shantanu_Jhaveri.py
618
4.40625
4
# Shantanu Jhaveri # ITP 449 Fall 2020 # HW3 # Question 1 # Use numpy to create 200 random integers between 1 and 200. Store them in X. Similarly, create # 200 more random integers between 1 and 200. Then display a scatter plot of X vs Y. from numpy import random from numpy.random import seed import matplotlib.pyplot...
true
c5011d676fea12dad63fe3e39044376f94e57188
chrisleewilliams/github-upload
/Exercises/Chapter5/exercise8.py
755
4.34375
4
# A ceaser cipher to encrypt/ decrypt messages # Author: Chris Williams def main(): # get key value key = int(input("Enter a key value: ")) # get message to encrpyt message = input("Enter the message you would like to encrypt: ") charString = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz...
true
e16415ec0fddf0e772d8e06f32b1e715434e1f26
chrisleewilliams/github-upload
/Exercises/Chapter7/quadratic3.py
799
4.1875
4
# Program to fid the real solutions to a quadratic # Author: Chris Williams from math import sqrt def getVars(): print("Enter 3 numbers.") a = float(input("Enter coefficient a: ")) b = float(input("Enter coefficient b: ")) c = float(input("Enter coefficient c: ")) return a, b, c def main(): p...
true
bdfbd1caac96a16abbe6db988f449d2a19316f61
chrisleewilliams/github-upload
/Exercises/Chapter3/Exercise2.py
409
4.28125
4
# A program to calculate the cost per square inch of a circlular pizza # Author: Chris Williams import math def main(): print("Hello! Enter a price and diameter to find out the cost per square inch of a pizza.") print() d = float(input("Diameter: ")) p = float(input("Price: ")) A = math.pi * (...
true
36f650b8774db9e32046a77add75b35593681f96
IeuanOwen/LPTHW
/LPTHW/LPTHWEX17.py
2,174
4.3125
4
# Learn Python the hard way EX17 #A program that copies the contents of a given file, to a different specified file. from sys import argv from os.path import exists script, from_file, to_file = argv ##print "Copying from %s to %s" % (from_file, to_file) # -> we could do these two on one line too, how? ##in_file = o...
true
12ff5e8575c3329d7178efdf712d23fc535c6f08
IeuanOwen/LPTHW
/LPTHW/LPTHWEX16.py
2,134
4.65625
5
# Learn Python the hard way EX16 #imports argv from sys from sys import argv #Creates 2 variables and assins them to argv script, filename = argv #These three seteps print the text inside the strings, replacing the % in line 1 with th value for filename print "We're going to erase %r." % (filename) print "If you don'...
true
42b8804483618364476a4ac41e5416f3de63cf6e
imgagandeep/searching-sorting-algorithms
/014-shell-sort.py
524
4.125
4
# Shell Sort Algorithm def shellsort(list): interval = len(list) // 2 while interval > 0: for index in range(interval, len(list)): current_element = list[index] pos = index while pos >= interval and current_element < list[pos - interval]: lis...
true
14e7622a487ae12f73725f2edff16dbf77c3f42a
Priyankavad/Python-Programs
/Hcf.py
531
4.1875
4
# defining a function to calculate HCF def calculate_hcf(h, p): # selecting the smaller number if h > p: smaller = p else: smaller = h for i in range(1,smaller + 1): if((h % i == 0) and (p % i == 0)): hcf = i return hcf # taking input from...
true
292246a4027337c4182eff21e813bf390b75e3cf
Priyankavad/Python-Programs
/Square root.py
204
4.3125
4
# Python program to find square root of the number hp = float(input('Enter the number: ')) # calculate square root sqrt = hp ** 0.5 # display result print('Square root of %0.2f is %0.2f '%(hp, sqrt))
true
c5afd6aac7f6f6aa5c9b422a4ad08e0e18a8901f
ershadhesami/KardanUniversity
/homework_and_classworks.py
903
4.125
4
# 1- Find max of 2 numbers def find_max(first, second): if first > second: return first else: return second x = int(input("Enter first number: ")) y = int(input("Enter second number: ")) print("Max value is {} ".format(find_max(x,y))) # 2- Multiply three numbers def multiply_three_nums(num1, ...
true
fa50dcb45486345fdb1660195f83378cbd4f5d1f
hysl/IntroToCompProg
/assign5/assign5_problem1.py
1,232
4.375
4
# Helen Li # March 25, 2015 # Assignment #5: Problem #1: 99 Bottles of Beer on the Wall # This code prompts the user to enter bottles of beer on the wall, then present the lyrics # for the road trip song "99 Bottles of Beer" # Ask user for a positive number bottles of beer on the wall while True: bottles = int(inpu...
true
f91c6399c08f2c2a227b0d28d43b0bbd63f69c77
hysl/IntroToCompProg
/assign2/assign2_problem3.py
748
4.21875
4
# Helen Li # February 11, 2015 # Assignment #2: Problem #3: Data Size Converter # prompt user for file size size = int(input("Enter a file size, in kilobytes (KB): ")) print () print (size, "KB ...") print () # convert KB to bits, bytes, MB, GB bits = size*1024*8 byte = size*1024 megabytes = float(size/1024) gigabyte...
true
02e80450a78e8b1e7ee3f1134da14a6df4be6087
Alalalalaki/Guide2EconRA
/python/util/sqlitetools.py
1,791
4.15625
4
""" Functions that are useful for explore sqlite data ref: https://stackoverflow.com/questions/305378/list-of-tables-db-schema-dump-etc-using-the-python-sqlite3-api """ import sqlite3 import pandas as pd def read_data(file_path): """ return (conn, c) """ conn = sqlite3.connect(file_path) # 'example...
true
66e903136f3508da608a28344bb13b0796a19d3c
tonyxiahua/CIS-40-Python
/Labs/Lab5.py
1,807
4.25
4
''' Create a program that reads words.txt (link near top of our home page) in order to: Determine the length of the longest word(s) and output that length plus the first word of this length found. Determine the length of the shortest word(s) and output that length plus the first word of this length found Determine and...
true
26b8439db15bce7e5b351d51e86b44d728542d57
MON7Y/Simple-Python-Programs-
/reverseNo.py
613
4.28125
4
''' Python Program to Reverse a Given Number This is a Python Program to reverse a given number. Problem Description The program takes a number and reverses it. Problem Solution 1. Take the value of the integer and store in a variable. 2. Using a while loop, get each digit of the number and store the rev...
true
134ba95ec13eeef181bcf303ba7adbe38f4e5e74
MON7Y/Simple-Python-Programs-
/rangeDivisibles.py
675
4.5
4
''' Python Program to Print all Numbers in a Range Divisible by a Given Number This is a Python Program to print all numbers in a range divisible by a given number. Problem Description The program prints all numbers in a range divisible by a given number. Problem Solution 1. Take in the upper range and lo...
true
97d7f81971191fa31f719c162814254bd2c383b6
wuikhan/Python
/methods2.py
455
4.15625
4
print("----- Program 1-----") def sum_nums(num1=2, num2=4): return num1 + num2 sum = sum_nums(2, 8) #another way print(sum) #output will be 10 print("----- Program 2 -----") def sum_nums(num1=2, num2=4): return num1 + num2 sum = sum_nums() #another way print(sum) #output will be 6 print("----- Program 3 ---...
true
3d6d5e5c332a2f22c2a8fd2b94030a87a3940a8a
mk1107/Python-LAB
/lab1q8.py
392
4.125
4
'''Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right.''' import random a=(random.choice([1,2,3,4,5,6,7,8,9])) b=int(input("ENTER ANY No. BETWEEN 0-9:- ")) if(a>b): print("TOO LOW") el...
true
cbaabcc83f163325bcea905f2606412e98fd1b80
BokaDimitrijevic/Exercises-in-Python
/rotate_list.py
325
4.25
4
def rotate_list(some_list): """Take a list as input and remove the first item from the list and add it to the end of the list. Return the item moved""" x=some_list.pop(0) some_list.append(x) return x fruits = ['apples', 'grapes', 'peaches', 'apricots', 'bananas'] print(rotate_list(fruit...
true
66d6f4881a6ce8ae2c5b5e531b8721bcec740a72
laboyd001/python-crash-course-ch8
/great_magicians.py
851
4.375
4
#Start with a copy of the program from 8-9. Write a function called make_great() that modifies the list of magicians by adding the phrase the great to each name. Call the show_magicians() to see that the list has been modified. def show_magicians(magicians): """show the name of each magician.""" for magi...
true
7d0b28fcaba79211efa2c8249a99d91dc1c750ed
enjuguna-zz/GOLClinics
/Pilot 1/Arrays and Strings/Algorithm-analysis/sqrt.py
557
4.15625
4
def int_sqrt(x): for i in range(x): if i * i == x: return i return -1 # TIME COMPLEXITY # ------------- # The loop runs in linear time # The if statement is done in constant time with respect to the loop that runs in linear time O(n) # There for the time complexity for the progr...
true
108f1c602fd5c32b3f5d8ab7c3a3ac6405ad2cbf
zoldello/fencing
/fencing/service/display.py
1,750
4.28125
4
"""Used to Display content to the screen.""" import operator class Display: """class for displaying content to screen.""" def __init__(self, is_verbose=False): """Constructor.""" self._is_verbose = is_verbose def print_info(self, message): """Informational. Display if isVerbose i...
true
dbabfb67afe0717b22f8abc2f7350e05436a89b0
vinnav/Python-Crash-Course
/7InputAndWhile/7-2.RestaurantSeating.py
231
4.15625
4
people = input("How many people are in your group? Insert number: ") people = int(people) if people > 8: print("I'm afraid you will have to wait for an available table...") else: print("Come this way, your table is ready!")
true
6e9e9d464e8c95369842e03b0098f1bc96e976ea
vinnav/Python-Crash-Course
/CheatSheets/6inputAndWhile.py
1,370
4.125
4
# Input var = input("prompt: ") # Input example int(var) # The input always gives a String # While Loops number = 0 while number < 5: # While loop example print(number) number += 1 # Flag flag = True # Flag example to stop a while loop while flag: message = ...
true
12f3e583fcec88b0352696f72218c792da912bc0
vinnav/Python-Crash-Course
/7InputAndWhile/7-10.DreamVacation.py
411
4.125
4
vacation = {} activeFlag = True while activeFlag: user = input("Input your name: ") place = input("If you could visit one place in the world, where would you go? ") vacation[user] = place repeat = input("Do you want to add other users? (y/n): ") if repeat.lower() == "n": activeFlag = False...
true
b9b9e9e4dd8c6468f031714a6980f2a59059e8d9
vinnav/Python-Crash-Course
/10Files/10-1.LearningPython.py
657
4.46875
4
# Print by reading the entire file with open("learning_python.txt") as file_object: # Opena a file and close it when not needed contents = file_object.read() # Read from a file and assign its content print(contents) # Print by looping over the file object with open("learning_python.txt") as fil...
true
a0baa8ff5a9994fd3c93a67af82fc3d6b40128f2
kmussar/Calendar_CodeAcademy
/Calendar_Project.py
2,970
4.53125
5
"""This is a calendar program. Features include: viewing the calendar, adding events, updating events, and deleting events. It will also print a welcome message to the user, prompt the user to view, add, update, or delete events on the calendar. The program will not terminate unless the user decides to exit.""" # Im...
true
b2b47ca4ac512c7cb4fb64d7308694d4dc0d3182
JakeSeib/Python-Practice
/Isolated problems/roman_numeral_converter.py
2,763
4.15625
4
# return a roman numeral using the specified integer value ranging from 1 to 3999 def digit_to_roman_numeral(number): """Given an integer from 1 to 3999, return the corresponding Roman numeral as a string. Letter M can appear as many times as possible. Letters D, L, and V should not appear more than once....
true
bc66f4853e434a6dd3cf0785a42ec2a10cc7bcbe
JakeSeib/Python-Practice
/Isolated problems/sort by frequency.py
941
4.21875
4
# Sort an iterable so that its elements end up in the decreasing frequency order, that is, the number of times they # appear in elements. If two elements have the same frequency, they should end up in the same order as the first # appearance in the iterable. def frequency_sort(items): items = sorted(items,key=item...
true
a43662244a562b7e3e80536f268a93f8fd458c3e
toniramon/CFGS_Web_Development_Dual
/Programacion/Python/codewars/POO/color_ghost.py
401
4.28125
4
""" Color Ghost Create a class Ghost Ghost objects are instantiated without any arguments. Ghost objects are given a random color attribute of white" or "yellow" or "purple" or "red" when instantiated ghost = Ghost() ghost.color #=> "white" or "yellow" or "purple" or "red" """ import random class Ghost: def __i...
true
5b230a47825c31f6d2cf7e04a06e75bf6d28872a
toniramon/CFGS_Web_Development_Dual
/Programacion/Python/codewars/kyu8/fake-binarty.py
341
4.28125
4
""" Given a string of digits, you should replace any digit below 5 with '0' and any digit 5 and above with '1'. Return the resulting string. """ def fake_bin(x): expected = "" for number in x: if(number < "5"): expected = expected + "0" else: expected = expected + "1...
true
8415b0113242d6a364400ceb8c5cf6ca0e36547b
toniramon/CFGS_Web_Development_Dual
/Programacion/Python/DuplicateEncode/duplicate-encoder.py
1,274
4.15625
4
""" The goal of this exercise is to convert a string to a new string where each character in the new string is '(' if that character appears only once in the original string, or ')' if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate. ...
true
c5fba8f0281f1d7e171b41444ec0b0abcab27de8
JakobSonstebo/IN1900
/Oblig/Uke 38/quadratic_roots_input.py
649
4.21875
4
from math import sqrt def find_roots(a, b, c): """Function that takes a, b, c and returns the roots of a the polynomial ax^2 + bx + c""" x = (-b + sqrt(b*b - 4*a*c))/(2*a) y = (-b - sqrt(b*b - 4*a*c))/(2*a) return x, y a, b, c = [float(x) for x in input("""Please provide values for a, b, c. (They shou...
true
916f46b401004840eaf73094ee23f1f3ab1291e3
JakobSonstebo/IN1900
/Oblig/Uke 38/quadratic_roots_error.py
1,629
4.25
4
from math import sqrt import sys def find_roots(a, b, c): """Function that takes a, b, c and returns the roots of a the polynomial ax^2 + bx + c""" x = (-b + sqrt(b*b - 4*a*c))/(2*a) y = (-b - sqrt(b*b - 4*a*c))/(2*a) return x, y coeff = ['a', 'b', 'c'] ...
true
e4cae31e683a93c3cca9efa26b1577ce71ebe74f
shankarpentyala07/python
/set_examples.py
330
4.21875
4
my_set = {"January", "February", "March"} for element in my_set: print(element) my_set.add("April") print(my_set) my_set.remove("January") print(my_set) my_list = ["January","February","March","January"] my_list.append("April") print(my_list) my_list.remove("January") #List removes the first matching value prin...
true
d2a098a88bf70231146783205f724220b9699a64
jaggureddy/ZTM
/ZeroToMastery/Assignments/96_WrapText.py
393
4.15625
4
""" You are given a string S and width W. Your task is to wrap the string into a paragraph of width. If the following string is given as input to the program: ABCDEFGHIJKLIMNOQRSTUVWXYZ 4 Then, the output of the program should be: ABCD EFGH IJKL IMNO QRST UVWX YZ Hints Use wrap function of textwrap module """ impo...
true
f3a382b2d67ccb2bc5707be6ef4d2a744c092c92
jaggureddy/ZTM
/ZeroToMastery/Assignments/43_FilterEvenNumbers.py
272
4.15625
4
""" Write a program which can filter() to make a list whose elements are even number between 1 and 20 (both included). Hints: Use filter() to filter elements of a list.Use lambda to define anonymous functions. """ l = filter(lambda x: x%2==0, range(1,21)) print(list(l))
true
392dd3893025d3efd6673ea7c171b60c63764a6a
jaggureddy/ZTM
/ZeroToMastery/Assignments/57_UnicodeEncode.py
247
4.46875
4
""" Write a program to read an ASCII string and to convert it to a unicode string encoded by utf-8. Hints Use unicode()/encode() function to convert. """ # s = 'hello world' # print(s.encode('utf-8')) s = input() u = s.encode('utf-8') print(u)
true
36f637781769390030eee5c346856457664ed548
jaggureddy/ZTM
/ZeroToMastery/Assignments/51_trycatch.py
314
4.125
4
""" Write a function to compute 5/0 and use try/except to catch the exceptions. Hints Use try/except to catch exceptions. """ def divide(n,d): try: c = n/d except ZeroDivisionError: print("divide by zero exception") except Exception: print("Exception captured") divide(5,0)
true
cc1f23f9188c21c0c15f0fbc1b1f003eac7188fe
jaggureddy/ZTM
/ZeroToMastery/Assignments/34_PrintFirst5.py
454
4.40625
4
""" Define a function which can generate a list where the values are square of numbers between 1 and 20 (both included). Then the function needs to print the first 5 elements in the list. Hints: Use ** operator to get power of a number.Use range() for loops.Use list.append() to add values into a list.Use [n1:n2] to sl...
true
c788c1d50fe4b70f79fece012c3d6e1a915dc2f8
data09a/python
/name_cards_manage_system/cards_tools.py
2,832
4.125
4
import cards_input # all cards list card_list = [] def show_menu(): """show menu """ print("*" * 50) print("Welcome【Name Card Manage System】V1.0") print("") print("1. Create new name card") print("2. Show All cards") print("3. Search cards") print("") print("0. Exist") pr...
true
41081398ad2c4f4dc6ef17de05cffbe959ca29e0
MarcelloLins/LeetcodePractice
/Easy/020_valid_parenthesis.py
2,114
4.125
4
""" Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. """ import unittest class Solution: def are_pare...
true
5d30e80c6806e1a3256fd675db43fff419b729b3
hbarua05/MyPythonProjects
/SQRT using Newton method.py
365
4.125
4
#p(x)=x^2-k=0. The root of polynomial gives us the sqrt of k #The code uses the Newton-Raphson method. It uses the iterative formula: #guess=guess – p(guess)/p’(guess) k=float(input('Find SQRT of...')) diff=0.0000000001 guess=k-1 while abs(guess**2-k)>=diff: guess=guess-(((guess**2)-k)/(2*guess)) print('Square roo...
true
712a6cd49ded92022839f359d9de3bedfa7d01e3
krteja97/using-Google-maps-api-with-Python3
/main_script.py
2,005
4.125
4
#urllib package is used for making HTTP requests and manipulating URL's #JSON package is used for manipulating the data sent by the API. #sqlite3 package is used for Database purposes. import urllib.request, urllib.parse, urllib.error import json import ssl import sqlite3 #set your api-key. API key acts like a secur...
true
e73fd78c683b230b3ddac880c5f0ab990725f901
Remus1992/TA_Labs
/day_07/guess_the_number.py
1,727
4.15625
4
import random cpu = random.randint(1, 10) print(cpu) last_guess_target = 0 while True: guess = int(input("Number: ")) current_guess_target = guess if guess == cpu: # print(last_guess_target) # print(current_guess_target) print("%s is right!" % guess) break elif guess > ...
true
fae45884537aff47ed261b6bb0f03c1dd221dc5b
Merg12/Learning_Python
/ex8_6_city_names.py
466
4.4375
4
#write a function called city_country() that takes in the name #of a city and its country. the function should return a string #formatted like this: "Santiago, Chile". Call your function with #at least three city-country pairs, and print the value that's #returned def city_country(city_name, country_name): format ...
true
7c15303074c61c89127134df98a6002bd1933ab1
Merg12/Learning_Python
/ex8_9magicians.py
287
4.15625
4
#make a list of magician's names. pass the list to a function called #show_magicians(), which print the name of each magician in the list magician_list = ['hudini', 'amazo', 'starman'] def show_magicians(names): for name in names: print(name) show_magicians(magician_list)
true
599787d37ef965a0bfd81b0631a507e1d8a4409c
knolan514/code_challenge
/challenge2_update/nazgul.py
1,579
4.1875
4
# import text import sys # search for patterns in text import re # if the command line only receives one argument (i.e $python nazgul.py) it will send an error message because you need to send the text file as an argument as well if len(sys.argv) != 2: print "Error: Enter 1 argument." else: with open(sys.argv[1...
true
21aeeae19a3c29a70e07ddb9157038a1220c6ba3
marlenaJakubowska/codecademy_py
/dict_challenge/values_that_are_keys.py
536
4.25
4
# Create a function named values_that_are_keys that takes a dictionary named my_dictionary as a parameter. # This function should return a list of all values in the dictionary that are also keys. def values_that_are_keys(my_dict): values_that_are_keys = [] for value in my_dict.values(): if value in my...
true
d4063ee4b7b24e060d4cf3904fc32911e52db652
marlenaJakubowska/codecademy_py
/dict_challenge/sum_values.py
393
4.125
4
# Write a function named sum_values that takes a dictionary named my_dictionary as a parameter. # The function should return the sum of the values of the dictionary def sum_values(my_dictionary): total = 0 for value in my_dictionary.values(): total += value return total print(sum_values({"milk":...
true
1c0dcf9016106e698c7be637bce757821c2af5ee
MMR1998-DEV/python-excersise-workbook
/39.py
353
4.15625
4
""" Question: The script is supposed to output the cosine of angle 1 radian, but instead, it is throwing an error. Please fix the code so that it prints out the expected output. import math print(math.cosine(1)) Expected output: 0.5403023058681397 """ import math print(math.cos(1)) # there is no method ca...
true
d881f9b2580a0cae8babfb234a641fe4a9b17c77
puziop93/Python-programming-exercises
/ListEnds.py
522
4.1875
4
""" 12)List Ends Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. For practice, write this code inside a function. Solution """ def num(): return input("Enter numbers: ") lista=[] numbers = num().split() f...
true
9894c4c1945958e171617cfd71ee58973f5d3e00
usmanchaudhri/azeeri
/companies/atlassian/min_forward_backward_jumps.py
1,616
4.15625
4
""" Given the index of the desired tool in the tools, determines the minimum number of forward or backward moves needed to reach a certain tool Example: tools: [‘ballendmill’, ‘keywaycutter’, ‘slotdrill’, ‘facemill’] k=1 tool=’ballenmill’ The tool currently in use is ‘keywaycutter’ at index 1. The desired tool is ‘ba...
true
a87f90f3b1c1bedd29a9e9110855877dd42befc8
usmanchaudhri/azeeri
/balancing_brackets/balance_brackets.py
860
4.21875
4
""" Given an input string composed of opening and closing brackets, determine if the brackets are balance. input = "([])(){}(())()(" """ def is_balance_brackets(input): opening_brackets = '([{' closing_brackets = ')]}' stack = [] matching_brackets = {')': '(', ']': '[', ...
true
e6700095104789ee9068a6a9de270ec64ce20a75
usmanchaudhri/azeeri
/companies/beyond_limits/pairs_of_numbers_sum_to_target.py
596
4.15625
4
""" Return all indices which return pairs of numbers whose sum equal to target """ def find_pair_target_sum(numbers, target): numbers.sort() all_pairs = [] startIdx = 0 endIdx = len(numbers) - 1 while startIdx < endIdx: sum = numbers[startIdx] + numbers[endIdx] if sum == target: ...
true
20f59292b2b9a7477fac30b031b97a62f366b119
candytale55/Area_Calculator_Python_2
/AreaCalculator.py
1,188
4.625
5
# Python 2 # To run: python AreaCalculator.py """ # Python is especially useful for doing math and can be used to automate many calculations. This project is a calculator that can compute the area of Circles and Triangles. # The program will: #Prompt the user to select a shape. #Calculate the area of that shape. #Pr...
true
efe4cb7edd6b8b5bccaebdcb2c15839b5f265e21
cherry-wb/quietheart
/tmpdoc/experiment/python_demos/sourceforge/pythonDemo/01_cmd_arg.py
423
4.125
4
#!/usr/bin/python import sys def print_arg(): '''Print the arguments of command. if runs alone, print arguments of command; if imported as a module don't print command arguments.''' for arg in sys.argv: print arg if __name__ == "__main__": argc=len(sys.argv) print "the argument count is:%d" %(argc-1) if argc...
true
07122e8805d187eccb55eeaa438786293962ca2b
NiallOFGalway/NiallOFGalway
/Week03/Lab3.3.3-normalise.py
495
4.375
4
# Lab3.3.3-normalise.py # Author: Niall O Flaherty # This program reads in a string, strips all leading and trailing spaces and converts the string to lower case inputString = input("Enter a string: ") normaliseString = inputString.strip().lower() lengthOfinputString = len(inputString) lengthofnormaliseString = len(n...
true
7a7c2973c667de40228c3fb1bebb726c05201ddb
NiallOFGalway/NiallOFGalway
/Week02/hello2.py
351
4.3125
4
# hello2.py # Author: Niall O Flaherty # This program asks you to input your name and gives a response after entering your name name = input ("Please enter your name") # This asks the person to enter their name, hence an INPUT print('Hello ' + name + '.\nNice to meet you') # This will output whatever the user input a...
true
f76114bb6a0feeee8a7b4c04a2401f93f657cff6
Harizzon/Python_HW_Podhora_Dmytro
/HW_OOP/HW_3/models/Employee.py
1,680
4.46875
4
from datetime import date class Employee: """ This is main class for all another classes in this python package """ def __init__(self, name, sec_name, email, p_numb, salary): self.name = name self.sec_name = sec_name self.email = email self.p_numb = p_numb self....
true
4bc23498393610044e681227eb2684012837a6a1
payscale/payscale-course-materials
/python/timer.py
258
4.25
4
import sys import time def print_time_left(minutes): while minutes > 0: print('Minutes left:', minutes) minutes -= 1 time.sleep(60) print('Time is up!') minutes = int(input('How many minutes? ')) print_time_left(minutes)
true
4b2a82d60db18ebc16b0072040295b9b1d934556
shree7796/python-programs
/q29.py
510
4.25
4
lastmonth = int(input("Enter last months unit:--")) currentmonth = int(input("Enter current months unit:--")) units = currentmonth - lastmonth print("total units:--",units) if units<=100: total = units*2 print("your total bill is:--",total) elif units>=101 and units<=200: total = units*3 print("your tot...
true
bc17d6f4c666c794614d753e7d06a6bfd54268f4
hranatunge/Hello_World
/recap_4.py
1,478
4.21875
4
# Recap 4 # Variable Operators name = "Hashan" print(len(name)) if len(name) < 3: print("Name must be at least 3 characters!") elif len(name) > 50: print("Name must be less than 50 characters!") else: print("Looks good") print("*" * 36) # Simple conditional program using if else statements isHot = True isC...
true
b203dc0ffd66107167ff9938c5987c30d9e75dab
hranatunge/Hello_World
/recap_3.py
1,352
4.4375
4
# Recap 3 # Formatted Strings # Need to import Math for this one import math # Variables firstName = "John" lastName = "Smith" rapperName = "mf doom" course = "Python for beginners" message = firstName + " [" + lastName + "] is a programmer." print(message) print("*" * 36) # Formatted Strings make it easier to visual...
true
d8c484bb493f55f2c498d157ac463b65269e95cb
tasha06/Python-Programs
/Queue Using LL.py
2,754
4.25
4
""" -------------------------------------------- Queue Using LL ---------------------------------------------- You need to implement a Queue class using linked list. All the required data members should be private. Implement the following public functions : 1. Constructor - Initialises the data members. 2. enq...
true
9e67573a9782635a6592158d3cbafa37e34d1ba4
JaydenKearney/Cp1404-Workshops
/Practical 1 - Pycharm, Control/Checkout.py
816
4.15625
4
def main(): """" The program allows the user to enter the number of items and the price of each different item. Then the program computes and displays the total price of those items. If the total price is over $100, then a 10% discount is applied to that total before the amount is displayed on the scree...
true
9af29f707b855f54ca7dd716c9f0729481ed07c7
TonyJenkins/python-workout
/30-flatten-a-list/list_flatten.py
622
4.21875
4
#!/usr/bin/env python3 """ Exercise 30: Flatten a List Convert a list of lists into a single list. Two implementations. One with list comprehension, one without. """ def flatten(list_of_lists): return [ an_element for each_list in list_of_lists for an_element in each_list...
true
a31e65dc0ec3f277082be6e8bbab6b3a1127d9f0
TonyJenkins/python-workout
/20-word-count/wordcount.py
689
4.15625
4
#!/usr/bin/env python3 """ Exercise 20: Word Count Mimic the Un*x "wc" command to count lines, words, and characters. """ def wc(filename): lines = 0 words = 0 characters = 0 distinct_words = set() with open(filename) as f: for line in f: lines += 1 wor...
true
712af03861120f904d2364af45ec3337ff12d980
TonyJenkins/python-workout
/21-longest-word-per-file/longest_words.py
847
4.15625
4
#!/usr/bin/env python3 """ Exercise 21: Longest Word per File Find the longest word in each text file in the current folder. """ from os import listdir def find_longest_word(filename): longest = '' with open(filename, 'r', encoding='UTF8') as f: for line in f: for word in line....
true
ef7d7570bc2a841f626b309c9dc23c6d6513def1
TonyJenkins/python-workout
/06-pig-latin-sentence/pig-latin-sentence.py
560
4.15625
4
#!/usr/bin/env python3 """ Exercise 06: Pig Latin Sentence Convert a complete sentence into a "Pig Latin" sentence using the function from exercise 05. """ from pig_latin import pig_latin def pig_latin_sentence(sentence): words = [] for each_word in sentence.split(): words.append(pig_...
true
9c3bd6a23088d30055ac0092d234e043a7dfa221
chuazhe/ugly-number
/main.py
1,437
4.125
4
def getUglyNumber(n): # Initialise the array uglyArray = [0] * n # The First ugly number is 1 uglyArray[0] = 1 # Used to track the index for 2,3 and 5 count2 = 0 count3 = 0 count5 = 0 # Multiples for finding the ugly number multipleOf2 = 2 multipleOf3 = 3 multipleOf5 = ...
true
5ee88edd347b178b8894317489d01f20e1980e55
laurenor/algorithms_practice
/primes/primes.py
986
4.15625
4
def is_prime(num): """Is num a prime number? num will always be a positive integer. >>> is_prime(0) False >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(7) True >>> is_prime(25) False """ ...
true
f55f56707301446c3049186cfc4a2af3f636b3d5
NenadPantelic/HackerRank-Problem-Solving
/Problem Solving - Interview preparation/1.Warmup/CountingValleys.py
473
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Feb 8 18:15:53 2020 @author: nenad """ def count_valleys(pattern): valley_no = 0 height = 0 for step in pattern: if step == 'U': height += 1 prev = 'up' else: height -= 1 prev...
true
47aebe8f239ac5a17193b17750c9482d1bf28ce8
RyanLBuchanan/Simple_Linear_Regression
/Simple_Linear_Regression.py
1,617
4.28125
4
# Simple Linear Regression from Machine Learning A-Z - SuperDataScience # Input by Ryan L Buchanan 10SEP20 # Import the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Import the dataset dataset = pd.read_csv('Salary_Data.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, -1]...
true
b23b06dc68bcf954c6984429ec3e52a0a47d985a
stevegleds/fun
/checkio/stack.py
1,361
4.40625
4
__author__ = 'Steve' # This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed. # This is equivalent to the requirement that once a new element is added, all elements that were added before have to be removed bef...
true
79226fffe32274922dfc893bf9699885ef08078d
Parasdave420/Python-Timepass
/list_methods.py
800
4.3125
4
#program to demonstrate methods available for list in python numbers = [5, 2, 5, 1, 6] #add number at the end of list numbers.append(25) print(numbers) #insert item on specific index list.insert(index, item) numbers.insert(2, 22) print(numbers) #remove specific item from a list numbers.remove(2) print(numbers) #r...
true
c25fd5407cf4c1120ca03b698d1fb2d856668b1c
kiranbkulkarni/redesigned-disco
/.vscode/Data Structures/15. Tuples.py
415
4.375
4
point = 1, 2 point2 = 1, point3 = (1, 2) * 3 # How to convert a list to a tuple list_tuple = tuple([1, 2]) print(list_tuple) # How to convert a string to a tuple string_tuple = tuple("Hello World") print(string_tuple) point_i = (1, 2, 3) print(point[0:2]) x, y, z = point_i # The one main thing to remember about t...
true
07db59c113d278a16e07f3415f4c573559860e02
kiranbkulkarni/redesigned-disco
/.vscode/Data Structures/7. Sorting Lists.py
316
4.15625
4
numbers = [3, 51, 2, 8, 6] numbers.sort() numbers.sort(reverse=True) print(numbers) sorted(numbers) sorted(numbers, reverse=True) # What if we tuples items = [ ("Product1", 10), ("product2", 9), ("Product3", 12) ] def sort_item(item): return item[1] items.sort(key=sort_item) print(items)
true
a8c37f07ee5cadeb986fc4634976fd21e4f498fa
Shrishti904/PuneetAssigment
/ResverseString.py
336
4.28125
4
def reversestring(sentence): reversewords=[] words=sentence.split(" ") for word in words: newword=word[::-1] #print(newword) newstring=newword.capitalize() print(newstring) reversestring("This is a demo string My name is shriSHTI...
true
a27f07c94a67c9f1a06aecdab9292d9c5209b63c
CodeGuySGT/Battleship
/Battleship.py
2,486
4.3125
4
""" 8/16/2018 Project from Codecademy. The project thus far was basically just following hand-holding instructions, but I don't like some of what they did and want to expand the program to include other cool features. """ from random import randint board = [] #Will hold the board values ...
true
0f1ec5d8c87515746c8ab25d5046da20782bd026
vina19/camelCase-UnitTesting
/CamelCase.py
723
4.53125
5
#Convert sentence to camelCase def camelcase(sentence): title_case = sentence.title() upper_camel_case = title_case.replace(' ', '') return upper_camel_case[0:1].lower() + upper_camel_case[1:] #displaying the banner def display_banner(): msg = 'Awesome camelCaseGenerator program' instructions = 'St...
true
467a80c0e86798fdb2ec837a86346b515c8c1267
zhsee/daily_coding_challenge
/day46_longest_palindrome_substring.py
1,074
4.125
4
# Given a string, find the longest palindromic contiguous substring. If there are more than one with the maximum length, return any one. # For example, the longest palindromic substring of "aabcdcb" is "bcdcb". The longest palindromic substring of "bananas" is "anana". def is_palindrome(s): return s == s[::-1] ...
true
7e15a74f1c4a4977318fcae1eee13bc80ac86fc5
zhsee/daily_coding_challenge
/day63_hidden_word.py
2,705
4.28125
4
# Given a 2D matrix of characters and a target word, write a function that returns whether the word can be found in the matrix by going left-to-right, or up-to-down. # For example, given the following matrix: # [['F', 'A', 'C', 'I'], # ['O', 'B', 'Q', 'P'], # ['A', 'N', 'O', 'B'], # ['M', 'A', 'S', 'S']] # and the...
true
fc72bbfe077e98a57bee81fc6947ab6d9847490e
zhsee/daily_coding_challenge
/day44_inversion_count.py
1,520
4.21875
4
# We can determine how "out of order" an array A is by counting the number of inversions it has. Two elements A[i] and A[j] form an inversion if A[i] > A[j] but i < j. That is, a smaller element appears after a larger element. # Given an array, count the number of inversions it has. Do this faster than O(N^2) time. #...
true
4106c1246824bb67bed42320e6225e2fd89bcb32
ThatGuyChristianT/pythonBasics
/datastructure.py
1,073
4.4375
4
##Data Structure #List: Mutable, meaning data can be manipulated #List instantiation with specific values my_list = [1,2,3] #Nested List instantiation my_list = [1,2,[3,4]] print('Before appending anything:',my_list) #Appending list value my_list.append(5) print('After appending \'5\' to the list:',my_list) #Retrie...
true
b3effba752c4c9bf7107aba859b84b971a3e225c
jmois/2020-Python-ZtH
/code/list-div-by-3.py
299
4.34375
4
# Use a list comprehension to create a list of all numbers between 1 and 50 that are divisible by 3. def list_dev_by_3(): lista = [] for num in range (1,50): if num % 3 == 0: lista.append(num) return lista if __name__ == '__main__': print(list_dev_by_3())
true
5786302ae026ed02c60dcca27233eb48e6fce7a5
tasops/coin-changer
/coin_changer.py
2,582
4.21875
4
#!/usr/bin/env python3 def main(): print('#####################################') print('--------Coin Changer by Tellu--------') print('#####################################\n') while True: print('##############################') cost = numVal('Enter total cost: ') cash = num...
true