blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
1c91a446f45aedabc40bdc4480d377869bcf46c0
acgeist/wxgonk
/countries.py
966
4.34375
4
#!/usr/bin/env python3 #-*- coding: utf-8 -*- """Do stuff with ISO 3166 alpha-2 country codes. Reference: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 """ from typing import Dict def make_country_dict( csv_file:str = 'data/country_list.csv') -> Dict[str, str]: """Make a dictionary containing the ISO 3...
true
1eac9fb541bfc217ffab6469389ccd970376a382
Nimble85/Python
/Python/Empireofcode/005.py
2,933
4.125
4
def most_difference(*args): if args: maxel = max(args) print(maxel) minel = min(args) print(minel) res = maxel - minel print(res) #print(str(maxel)+'-'+str(minel)+'='+str(res)) #return str(str(maxel)+'-'+str(minel)+'='+str(res)) return res ...
true
1fe812654220d85d4d8f9b5d341b4c89ab1b6b98
XinCui2018/Python-Hard-Way
/ex6.py
1,113
4.3125
4
# use %d and show the number 10 x = "There are %d types of people." % 10 # string binary = "binary" do_not = "don't" # print a string with 2 string variable. Do not forget the percent mark % between the string and the variable. # Also, two variables should be in the parenthesis. y = "Those who knows %s and thos...
true
f99d297137c344681fbaf8cecb936e1254e4ca50
SushantBabu97/Python-HackerRank
/Find_The_Runner_Up_Score.py
643
4.34375
4
""" Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given n scores. Store them in a list and find the score of the runner-up. For list [2,3,6,6,5] print 5 as it is the second largest score. """ from collections import Counter if __name__ == '...
true
fff14d13bf623ca71ea5c4b56c521574d0382e90
SushantBabu97/Python-HackerRank
/Tuple.py
343
4.125
4
# Tuples """ Given an integer, n, and n space-separated integers as input, create a tuple, t, of those n integers. Then compute and print the result of hash(t). hash() is a builtin function. """ if __name__ =='__main__' : n=int(input()) integer_list=list(map(int,input().split())) t=tuple(integer_lis...
true
7b75f431526f1c1802d7aa217ed6ffe623642878
kaushikme123/my-python-project
/my first python project/number.py
470
4.1875
4
import random number = random.randrange(1,100) guess = int (input("Guess the number")) while guess != number: if guess < number: print ("You need to guess higher. Try again") guess = int (input("\n Guess a number between 1 and 100: ")) else: print ("You need to guess lower. Try again")...
true
67e75429d396037636a409c62fd717c28d023724
sannyve1/BSIT302_Activity1
/CRUDE.py
1,394
4.1875
4
Students = [] ans = True while ans: print(""" ************************************************ 1. Add a Student 2. Delete a Student 3. Update a Student 4. Look Up Student Record 5. Exit """) ans = input ("What would you like to do? ") if ans =="1": add = str (input ("Enter Student Name. ...
true
f7032429dfcd66cd1155b7bfc5b2538924b9e5e0
stak21/holbertonschool-higher_level_programming-1
/0x06-python-classes/1-square.py
458
4.21875
4
#!/usr/bin/python3 class Square: """class square Note: Do not include the `self` parameter in the ``Args`` section. Args: size (int): size of the square. Attributes: __size (int): size of square """ def __init__(self, size): """Instantiation Args: ...
true
75e6df22de59367817cc814279efee3d84ed28a9
stak21/holbertonschool-higher_level_programming-1
/0x07-python-test_driven_development/2-matrix_divided.py
1,197
4.15625
4
#!/usr/bin/python3 """ This module divides two list """ def matrix_divided(matrix, div): """ Divides two list inside the matrix if the Args: matrix: input matrix of numbers div: input division number Raises: TypeError: if marix is not a int or float or lists TypeErr...
true
cfd0fdaf56804c592834df44df998738b258a74c
stak21/holbertonschool-higher_level_programming-1
/0x07-python-test_driven_development/0-add_integer.py
747
4.40625
4
#!/usr/bin/python3 """ This module does simple addition """ def add_integer(a, b=98): """ Simple addition function that adds 2 integers or float first it checks if 2 given input is an integer or a float than converts float to integers Args: a: input variable b: input variable defau...
true
27e6969d8abab720ecaa9b44dfa36ba6247cdb14
dkbradley/Using-Python-to-Access-Web-Data
/Wk4_assignment.py
762
4.28125
4
# Coursera.org /Learn to Program and Analyze Data with Python Specialization # Course 3 - Using Python to Access Web Data # Week 4 # Assignment: Scraping HTML Data with BeautifulSoup """ The program will use urllib to read the HTML from the provided data file, parse the data, extracting numbers and compute the sum of t...
true
445dcd83833c22651333fe691a4a800f7d3564b2
amansharma2910/Python3Tutorials
/venv/PrimeList_Functions.py
1,050
4.5625
5
## In this program, we will see how the main function is used within python. This program will print a list of prime numbers upto the number that the user inputs. # First, we define a function isPrime that checks if a number is prime or not. If it is prime, then it will return a value True, or else, it will return Fal...
true
10e743eff092782209d2de35034164d6e2184de0
amansharma2910/Python3Tutorials
/venv/DictionaryOperations_Dict.py
922
4.53125
5
## Let us cosider the list given below as an example. # dict1 = {"f_name" : "Aman" , "l_name" : "Sharma" , "reg_no" : "19BAI10007" , "prog" : "BTECH"} ## dict1.values() will return all the values stored in the dictionary. # print(dict1.values()) ## dict1.keys() will return all the keys stored inside the dictionary. #...
true
1b47f2c4f4ee4a731a8de34e3f6062fe6049de25
amansharma2910/Python3Tutorials
/venv/AnonymousFunction_LambdaFunction.py
587
4.5
4
# Lambda function are one liner functions in Python. We can use them when we need a function to solve a specific problem but we don't want to make our function look messy by defining an entire new function for it. Given below is an example of how you can define a lambda function. # lambda arg1, arg2 : arg1 + arg2 """ ...
true
74cb56195c75bc48a70cd6fe7d2449ccbc1a2df0
lalidiaz/my-python-project
/main.py
521
4.25
4
from datetime import datetime user_input = input("Enter your goal with a deadline separated by colon\n") input_list = user_input.split(":") goal = input_list[0] deadline = input_list[1] print(input_list) dateline_date = datetime.strptime(deadline, "%d.%m.%Y") today_date = datetime.today() # calculate how many days ...
true
6c70c0fe38dcd5c6fd41e3b11a9c47ac68a45335
marufaytekin/hackerrank
/QuickSort.py
959
4.3125
4
""" Quick sort algorthm: 1. Select a random element (pivot) 2. Find all smaller elements and move them to the left of the pivot element. 3. Find all larger elements and move them to the right of the pivot element. 4. Repeat the same process for the left side of the pivot element 5. Repeat the same process for the right...
true
b9012a110c771646f7bf0def66ecc287afa4088e
marufaytekin/hackerrank
/AnagramGroup.py
509
4.28125
4
""" Group Anagram: Read in N Strings and determine if they are anagrams of each other. Ex: 'cat','act','tac' -> true 'cat', 'bat', 'act' -> false """ def anagram(str_list): sorted_list = [] for item in str_list: sorted_item = sorted(list(item)) sorted_list.append(''.join(sorted_item)) for ...
true
7fd5c460aff01dac00faf084efab0d05bd3da788
sukritgoyal/pythonFiles
/Python/simple_cal.py
730
4.34375
4
try: while True: oper = input("Enter the operator you want to use: ") if oper == "exit": break digit1 = float(input("Enter the first digit: ")) digit2 = float(input("Enter the second digit: ")) if oper == "+": print("Your answer is %d"%(digit1+...
true
81e6fe268e50c7d26951bcc65114cc1799893472
Ruchika1706/PythonCode
/Lambdas.py
348
4.1875
4
def square(x): return x**2 print(square(4)) #Lambdas are called Anonymous functions. Lambdas do not have return statements #Lambdas can be used anywhere and you do not need to assign it to particular variable # Alternative using Lamdas result = (lambda x: x**2)(30) print(result) #Alternative without using lambda...
true
5a5458322a58f7ee3bf563a6680399157e3f47a8
Ruchika1706/PythonCode
/Map.py
326
4.46875
4
#Map performs operation, perform function on given iterables like list #Say you want to add 2 to all members in a list def add(x): return x+2 new_list = [10,20,30,40,50] print(list(map(add,new_list))) print new_list #Usage of Lambda and map together new_list = [10,20,30,40,50] print(list(map(lambda x:x+2,new_lis...
true
95ce8c2797f5454f162796d46dd3d491ad3b0978
Ruchika1706/PythonCode
/while_loop.py
397
4.21875
4
counter = 0 while counter<=10: print(counter) counter+=1 for each in range(5): print("I am a programmer") #Task no 2: Create a function which displays out the square values of numbers from 1 to 9. def square(num): print(num*num) for each in range(1,10): square(each) #Alternative and better way d...
true
a34ec1a80fedcd6c91288765b2c5284ab890c38b
acastillosanchez/Foothill-CS3A-Python
/assignment2_GitHub.py
1,587
4.625
5
""" 01/16/2020 This program prompts the user for a enter three pieces of information mpg, gas price, and current fuel in tank. The program prints the calculations how much it costs to travel 100 miles and how many miles the user can drive with the amount of gas that is currently in her tank. """ #My Program MILES = 10...
true
a2647314218680e22ca5b568096737f8817b6721
chaisatire/Udacity-DS-algos-Project-3
/4-Dutch-national-flag.py
2,140
4.21875
4
def sort_012(input_list): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Args: input_list(list): List to be sorted """ """ The algorithm uses several pointers to traverse the array only once. We are keeping track of 3 values...
true
94b2a5fd51070a6e6133dfdf614d2293f99a9db6
gtripti/PythonBasics
/Basics/Lists.py
839
4.15625
4
my_list= [1,2,3] print(my_list) my_list =['HELLO' , 100 , 2.3] print(my_list) # Check Length print(len(my_list)) my_list= ['one' , 'two' , 'three'] # Indexing print(my_list[0]) # Slicing print(my_list[1:]) another_list = ['four' , 'five'] print(my_list + another_list) new_list = my_list + another_list print(new_lis...
true
c9e7c2e46a8a774c737534861277f1e87f088214
CateGitau/Python_programming
/Codesignal/fillinginData.py
765
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Feb 2 08:38:28 2020 @author: aims """ """ You're given a log of daily readings of mercury levels in a river. In each test case, there are missing mercury values for several of the days. Your task is to analyze the data and try to identify all of the m...
true
e481366297fe260e4892f34029d8e0b34e20c624
CateGitau/Python_programming
/LeetCode/thirty_days/Day30_check_if_string_is_valid_sequence.py
970
4.125
4
""" Given a binary tree where each path going from the root to any leaf form a valid sequence, check if a given string is a valid sequence in such binary tree. We get the given string from the concatenation of an array of integers arr and the concatenation of all values of the nodes along a path results in a sequen...
true
af2e5f2408cc96db92b0bb5404cc90572ec9ab72
CateGitau/Python_programming
/LeetCode/thirty_days/Day6_group_anagrams.py
2,471
4.1875
4
""" Given an array of strings, group anagrams together. """ import collections #Example # Input: ["eat", "tea", "tan", "ate", "nat", "bat"], # Output: # [ # ["ate","eat","tea"], # ["nat","tan"], # ["bat"] # ] #my approach words = ["eat","tea","tan","ate","nat","bat"] anagrams = {} def groupanagrams1(words): ...
true
875c7b5c422d99223292857eca4accb59c22864e
id40/python-project
/guess-and-win.py
1,176
4.34375
4
# importing random class import random # it randomly generate the number between one to twenty x = random.randint(1, 20) # putting variable value for number of chances n = 4 print("\n\nHello! Welcome to GUESS AND WIN game \n") print("GAMES RULES ") print("1. Rule number one, Guess the number between 1 to 20.") p...
true
a3093ec93d870b667fc5bd5787e8d8550b7329dd
Zapfly/Udemy-Rest-APIs-with-Flask-Alchemy-
/SECTION_1_and_2/37)Classmethod and staticmethod.py
1,397
4.28125
4
class ClassTest: def instance_method(self): print(f"Called instance_method of {self}") #needs an instance to call it #used for changing data inside an instance @classmethod def class_method(cls): print(f"Called class_method of {cls}") #used often as "factories" ...
true
8524dc3756e683b6dce8ae47f73ba5ad01d4f81b
dcf21/4most-4gp-scripts
/src/helper_code/interpolate_linear.py
2,687
4.21875
4
# -*- coding: utf-8 -*- """ A class for linearly interpolating [x,y] data sets. Can return either y(x), or solve for x(y) """ from operator import itemgetter class LinearInterpolate: """ A class for linearly interpolating [x,y] data sets. Can return either y(x), or solve for x(y) """ def __init__(s...
true
865582186b3d2610f38b94672df054e2f40217d1
BillMarty/PythonLearning
/read_contacts/.idea/Contact.py
1,211
4.15625
4
# Python learning project: # Build a Contacts management program that reads in my contacts (from a .csv file to start). # In this file: The class that holds each contact. class Contact(): """Contact holds one contact as a dictionary, likely multi-level dictionary.""" def __init__(self, header, contact_dat...
true
64ef7347b083817e1faa7448e01e7298e4de5af2
knowledgeforall/Shell_and_Script_Unix
/lab05-task01-ppolsine.py
456
4.21875
4
#!/usr/bin/python3 import math #input hypotenuse and angle B c = float(input("Enter length of c: ")) B = float(input("Enter angle of B: ")) #calculate angle A A = (180-90-B) #Convert angle A and B to decimal using trigonometry formula BB = (B*(3.14/180)) AA = (A*(3.14/180)) #calculate length a and b of the triangle b...
true
8350643c1bce4898060d1e8d8ae1cbb8a8e03f5d
knowledgeforall/Shell_and_Script_Unix
/lab06-task04-ppolsine.py
1,814
4.15625
4
#!/usr/bin/python3 # to import a module for reading and writing csv files import csv # to create a function that classifies number grades to letter grades def letter_grade(grade): if grade>=97 and grade<=100: return "A+" if grade >= 93 and grade <= 96: return "A" if grade >= 90 and grade <...
true
a79d00681d0fc58b1ebd476c57f5b85f72b8a17a
knowledgeforall/Shell_and_Script_Unix
/lab05-task03-ppolsine.py
393
4.3125
4
#!/usr/bin/python3 #prompts for input of the string as a map iterator object and splits the inputs on commas names = list(map(str, input().split(","))) #corrects and changes names to sort in proper order names[1] = "The Humans" names[2] = "Demon Days" names.remove("Face Value") names[4] = "Plastic Beach" names.sort()...
true
76c5ec84c1594de4409c50d612e9b9132831626e
jjustinm4/mytest1
/regression_linear.py
2,016
4.40625
4
#we are trying to implement a linear regression model (exact theoretical implmentation) import numpy as np import random import matplotlib.pyplot as plt #theta values are called regression coefficients initiate them to smaller random values theta=[] for c in range(2): theta.append(random.random()) #alpha i...
true
9bf170ab030091c7c1c98dd5bbe40c5be8fc9384
merkushov/hexlet
/python-project-lvl1/brain_games/games/progression.py
793
4.15625
4
"""The module that generates the game according to the given rules""" from random import randint TASK = 'What number is missing in the progression?' PROGRESSION_LENGTH = 7 def get_round(): """ The function of generating one round of the game. Returns a tuple consisting of 2 elements: ...
true
8854e83fea359ebdec75cbc5ebc953fe85c0f58e
timilak/codewithme
/strings.py
371
4.25
4
# concatenating strings mystring = "Hello World!" string1 = " I'm 17 years old" print(mystring + string1) #slicing strings: this prints the first 5 characters of the string sliced_string = mystring[:5] print(sliced_string) integer = 5 floating_number = 50075.95 string = "45" # convert string to float new_float = flo...
true
efc056b5ac6f8f96d671999e0fe24d9af765edfb
timilak/codewithme
/age.py
215
4.28125
4
# find out whether the user is eligible to vote or not age = input("What is your age?") int_age = int(age) if int_age>=18: print("Congrats! You can vote now!") else: print("Sorry, you can't vote this year.")
true
cbcc0206506be7a3ed71f87e767cd44579749049
RaviC19/Guessing_Game
/guessing_game.py
1,049
4.25
4
# handle user guesses # if they guess correct, tell them they won # otherwise tell them if they are too high or too low # BONUS - let player play again if they want! import random while True: random_number = random.randint(1, 10) # numbers 1 - 10 guess = int(input("Guess a number between 1 and 10 ")) ...
true
83e6d9d673397978f80eb7661c524a75d47ef18b
vinhlee95/python-sandbox
/getting-started/data-types/dictionary.py
1,206
4.4375
4
""" Dictionary 🔑 Allow to store data in key-value pairs 🔑 Dictionaries are MUTABLE 🔑 Keys can only be IMMUTABLE types 🔑 We use dictionaries when we want to be able to quickly access additional data associated with a particular key 📚 Resources: https://www.learnpython.dev/02-introduction-to-python/080-advanced-dat...
true
8d7f919f1892a6c34409edeba2f3c0bec2fd7960
anudita/Python-
/function.py
478
4.28125
4
def factorial(num) : if num == 1: return num else: return num*factorial(num-1) str = 'y' while (str == 'y' or str =='Y'): num = int(raw_input("Enter a number")) if num < 0: print("Cannot find factorial of negative number") elif num > 0: print "Factorial of number is",factorial(num) elif num == 0: prin...
true
96e2ef3e7fe620722838052d00e61a09b3ec83a6
ncfoa/100DaysOfCode_Python
/004/heads_tails.py
608
4.21875
4
import math import random callit = input("Call whether you think it will be 'heads' or 'tails'\n").lower() if callit != "heads" and callit != "tails": print("You didn't choose a side") exit(0) coin_toss = math.floor(random.random() * 2 + 1) if coin_toss == 1 and callit == "heads": print("The coin landed o...
true
ef6056a833f93753b0f71783991b577111d4ea05
HannanehGhanbarnejad/IntroductionToPythonProgramming
/ex1/Rand2.py
427
4.1875
4
a=int(input("Please enter a: ")) b=int(input("Please enter b: ")) def Rand2(a,b): """ (int,int)-> int Return a random even number within a specific range between two given values including the values themselves. >>> Rand2(30,127) 58 """ import random for i in range(a,b+1): ...
true
7745fd301b2c2a1e045f00cbcbb4ef04221303f9
Ryan-Brooks-AAM/cleverprogrammer
/Learn-Python/exercise3_len.py
321
4.15625
4
print("What word would you like to measure?") word = input() def count_words(word): count = 0 for i in word: print(i) count = count + 1 return count # returned results need to move out of the local def into global len = count_words(word) print(f"The word count for {word} is: {len}") ...
true
5558bd19b46d8fff6379cbf1ffaca8ba116399b3
PetterNas/ML-basics
/PolyNomialReg.py
1,639
4.34375
4
#Polynomial Linear Regression #Simple example showing how to create and plot a polynomial regression model. #In the example code below, I'm not using any test/training sets. #Also plotting a linear regression, for comparing linear - polynomial models. # Importing the libraries import numpy as np import matp...
true
a37f4c7e36319138119fef642dade5e4fee71e52
Ethan-source/E01a-Control-Structues
/main10.py
2,703
4.28125
4
#!/usr/bin/env python3 import sys, utils, random # import the modules we will need utils.check_version((3,7)) # make sure we are running at least Python 3.7 utils.clear() # clear the screen print('Greetings!') #Prints "greetings" in the terminal as the introduction. colors =...
true
6b53a748135b655e4b2d9690ba47a05dd588fefa
agrima13/PythonCoding
/Strings/StringPractice.py
539
4.21875
4
s = "The metahumans have atacked Central City again" #Method 1 to reverse the string print(s[len(s)::-1]) #Method 2 : Without specifying the length explicitly print(s[::-1]) ##Method 3 : Loop reversedString=[] index = len(s) # calculate length of string and save in index while index > 0: reversedString += s[ in...
true
c73a49cb24b13d887c1679bbaa9fbfe0b1778026
Musicachic/CITP_110-1
/CITP 110/Chapter 5/sum_numbers example.py
474
4.34375
4
# This program calculates the sum of a series # of numbers entered by the user. def main(): # Initialize an accumulator variable. total = 0 max = int(input("How many numbers will you add?: ")) # Get the numbers and accumulate them. for counter in range(max): number = int(input('Enter ...
true
0c926111dfecce39fc7dd60ecaa2a37c7751890e
altynai02/Chapter1-Part2-Task5
/task5.py
1,083
4.28125
4
# 5. A school decided to replace the desks in three classrooms. Each desk sits two # students. Given the number of students in each class, print the smallest # possible number of desks that can be purchased. # - The program should read three integers: the number of students in each of # the three classes, a, b and c re...
true
6aaf5cc5a743817bfbb325ffad668c01cbec5243
deepzsenu/python
/Doing_maths_with_python/1.Playing_with_numbers/New Folder/p3__multiple_table_printer.py
395
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 9 20:16:09 2020 @author: deepak """ #the program for our multiplication table printer: def multi_table(a): for i in range(1,11): print('{0} X {1} = {2}'.format(a, i, a*i)) if __name__ == '__main__': a = input("Enter t...
true
c58cb13c8940df12887ae4efc293a76095b6b77a
TrinUkWoLoz/Python
/list_in_not_in.py
955
4.125
4
# List in or not in examples #Simple true/false myList = [0, 3, 12, 8, 2] print(5 in myList) print(5 not in myList) print(12 in myList) # Print largest number in list - range = value 3 (element 1) to value 13 (last element len(myList)) myList = [17, 3, 11, 5, 1, 9, 7, 15, 13] largest = myList[0] for i in range(1, l...
true
3a0238deb8c54285349d3ef209f4b8d0e039cebf
TrinUkWoLoz/Python
/defining_functions.py
1,459
4.25
4
# DEFINING FUNCTIONS EXAMPLES # Definined function with positional parameter def message(what, number): print("Enter", what, "number", number) # invoke function (requires 2 parameters) message("Jaffacakes", 300) ############################ # Definined function with positional parameter def introduction(firstNa...
true
0e64bc2e1f9e9054737dda50c332c904c1aaacba
TrinUkWoLoz/Python
/list_append_insert_delete.py
982
4.5
4
# step 1: create an empty list named beatles; # step 2: use the append() method to add the following members of the band to the list: # John Lennon, Paul McCartney, and George Harrison; # step 3: use the for loop and the append() method to prompt the user to add the following # members of the band to the list: Stu Sut...
true
784bb535d6c61d3c472a9c97e28036ce90ccc571
diamondsky/Python-Programs
/format_output.py
812
4.25
4
#format_output.py def main(): temperature_str = input("Enter the temperature: ") temperature = float(temperature_str) count = int(input("Enter the number of students: ")) print("The temperature is " + str(temperature)) print("The number of students is " + str(count)) print("Students = " + forma...
true
cf89bd90db0f7c22dbde753c825c6f25c80dcca5
YManjunath/Python
/Guess-Number-Challenge-12/main.py
1,196
4.15625
4
from random import randint from art import logo print(logo) easy_level = 10 hard_level = 5 # Checking the user guess against the answer def check_answer(guess,answer,turns): """Checks the guess against answer and returns the remaining attempts """ if guess > answer: print("Too high") return turns -1 eli...
true
58cdc9bdd0450221daa56633e2d55811a4ebc0ef
novinary/Data-Structures
/heap/max_heap.py
2,664
4.125
4
''' In a max heap, each child node is less than or equal to parent node ''' class Heap: def __init__(self): self.storage = [] # insert adds the input value into the heap; this method should ensure that the inserted value is in the correct spot in the heap def insert(self, value): self.storage.append(value...
true
ec4c173b29ecab6b394c40b8be77aed312b7d083
raja21068/Machine-Learning-Toturials
/49_Multiclass_Logistic_Regression.py
2,155
4.40625
4
#Logistic regression can also be used to predict the dependent or target variable with #multiclass. Let’s learn multiclass prediction with iris dataset, one of the best-known #databases to be found in the pattern recognition literature. The dataset contains 3 classes #of 50 instances each, where each class refers to a ...
true
b93c3d8e6f5bfc9288a0dec2e90bd47883ea3afd
oWlogona/SS_exercise
/char_freq.py
469
4.21875
4
"""Write a function char_freq() that takes a string and builds a frequency listing of the characters contained in it. Represent the frequency listing as a Python dictionary. Try it with something like char_freq("abbabcbdbabdbdbabababcbcbab").""" def char_freq(line=''): if len(line): ans_dict = {item: 0 for item ...
true
cd1527a54199641f65d3b09750825a611e45af89
anastasiia42/Interview-practice
/check_if_binary_search_tree.py
1,685
4.21875
4
# check if a binary tree is a binary search tree class BinaryTreeNode(object): def __init__(self, value): self.value = value self.left = None self.right = None def insert_left(self, value): self.left = BinaryTreeNode(value) return self.left def insert_right(self,...
true
96aa84fc0b6ad809030616df64f99268b18d37c1
sarah-fitzgerald/pands-problem-sheet
/collatz.py
863
4.46875
4
#This program asks user to input any positive integer #Then outputs the successive values #Author: Sarah Fitzgerald #https://www.w3resource.com/python-exercises/challenges/1/python-challenges-1-exercise-23.php x = int(input("Please enter a positive number: ")) # Asks user to input a positive number def collatz(x): #...
true
6c0e49392b047a2687624460a7d36dcb356ed99c
basfl/data-science
/ml/Regression/Simple Linear Regression/GPA_SAT/app.py
1,187
4.15625
4
from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split import pandas as pd import numpy as np import matplotlib.pyplot as plt dataset = pd.read_csv("./resources/gpa-sat.csv") """ our DV is gpa and our IV is sat """ X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 1]....
true
b640a0cf4f8c3e30f4bdab9abe852262aa2ccfe9
ArtisanGray/python-exercises
/else-if.py
377
4.34375
4
# This program will take a numerical grade and give a letter grade output grade = int(input("Enter your grade: ")) if (grade >= 90) and (grade <=100): print("A") elif (grade >=80)and(grade <=89): print("B") elif(grade >=70)and(grade <=79): print("C") elif(grade >=60)and(grade <= 69): print("D") else: print("F") #...
true
dd8d121d8ba32dd8001e341f4bc5b8641a1f863e
ArtisanGray/python-exercises
/tic-tac-toe-pt3-UNFINISHED.py
1,340
4.375
4
print ("TIC TAC TOE board. Rows and Columns starting from 1,1") print ("Game board is printed each time to show progress!") # Declare the blank game game=[[0,0,0], [0,0,0], [0,0,0]] count = 0 # create the print gameboard function def print_game(game): print ("\n") for i in range...
true
d422f486d04edc5f363c4c144a077d1954b47309
ArtisanGray/python-exercises
/check-elements-of-input-array.py
669
4.125
4
# Use your code from the last exercise. # Now check to see how many of a number are in the array. # Hint: use the code from the examples in class. # Use your code from the last exercise. numbers = [] input_len = int(input("How many elements do you want?: ") ) # Now use a for loop to add to the array. for index in ...
true
74631801eb5e74b9edb65763a68e0d5f6af863eb
TanakitInt/Python-Year1-Archive
/In Class/Week 3/quadratic solve issue when crash (q14 HW).py
2,200
4.34375
4
#--------------------------Information------------------------------# #Tanakit Intaniyom DSBA #Assignment Week 3 #Question number 14 #Last updated on 26/08/2017 at 02.44 am #-------------------------------------------------------------------# # quadratic.py # A program that computes the real roots of a quadratic eq...
true
b9aac0c9b30875d909bf13d6157799c6668d86b9
TanakitInt/Python-Year1-Archive
/In Class/Week 5/max_speed.py
663
4.21875
4
"""Max speed""" def traffic(): """go drive!""" speed_limit = int(input()) current_speed = int(input()) fine = 0 #when drive illegal but not more than 90 if current_speed > speed_limit and current_speed <= 90: fine = 50 + abs((speed_limit-current_speed)*5) print("The speed is ille...
true
b2b1ec727846ee12bef756ae51d873de04af9410
robertz23/code-samples
/python scripts and tools/palindrome_prime.py
1,359
4.40625
4
""" Find the highest palindromic prime number between 1 and 1000 """ def is_prime(num): """ Checks if a number is prime """ prime_counter = 1 for x in range(1, num): if num % x == 0: prime_counter += 1 if prime_counter > 2: return False return True def ...
true
4400a20127476249bbc6ea7240e6718d792aa260
McLeedle/python-projects
/Example4 Conditionals/example4.py
738
4.125
4
print "This is our forth example and will cover conditionals and control flow" # create function storestock with a variable of instock def storestock(instock): print "This store has %s Items in stock." % (str(instock)) # conditional parameters to evaluate if instock is true and prints if true if instock == 4...
true
69e21a1b59751503111f0903d93d6e90a8392d16
csgray/IPND_lesson_4
/lesson_4-4.py
1,861
4.34375
4
"""Lesson 4.4: Modulus & Dictionaries Modulus Operator % <number> % <modulus> -> <remainder> 14 % 12 -> 2 """ """Lesson 4.4: Dictionaries Dictionaries are another crucial data structure to learn in Python in addition to lists. These data structures use string keywords to access data rather than an index number in li...
true
e0b42545cf9394ae335d92d6e9d8dc2a1e6a8143
UrszulaP/Learning-JavaScript-30days
/04 - Array Cardio Day 1/python_version.py
1,424
4.125
4
# 1. Filter the list of inventors for those who were born in the 1500's result = list(filter(lambda x: x["year"] >= 1900 and x["year"] < 2000, inventors)) print(result) # ZMIENIĆ NA LISTĘ STRINGÓW # 2. Give us an array of the inventors first and last names result = list(map(lambda x: {x["first"], x["last"]}, inventors...
true
7c8ec39deea879435ea3166fd31fa71d17d854ec
aba00002/Lab3-Python
/Lab3_Exercise10.py
305
4.375
4
#Program that will compute MPG (Miles covered Per Gallon used) for a car #Where M is miles driven and G is gallon used M = int(input("enter the number of miles driven")) G = float(input("enter the number of gallons used")) MPG = (M / G) print("Dear driver, the mile per gallon rate of your car is", MPG)
true
396012585de01ddc15a212334393e736cf3238ff
satishr01k/Python_Tasks
/variablestask.py
1,981
4.59375
5
#1. Create three variables in a single line and assign different values to them and make sure their data types are different. Like one is int, another one is float and the last one is a string. a, b, c=10, 11.5, 'satish' print(a) print(b) print(c) # 2. Create a variable of value type complex and swap it with ano...
true
969f76a0b45f7aee2e017b12579d8cd3cad1f68b
LouJi/PyUnitTest2
/functionz.py
1,915
4.25
4
from math import * def add (x,y): #Add function if type(x) in [bool]: raise TypeError('The operands must be a real number') if type(y) in [bool]: raise TypeError('The operands must be a real number') #if type(x, y) not in [int, float, str]: #raise TypeError('The operands must b...
true
5ef08a06702238a16fb0148ad228bfa4712c2814
young-geng/leet_code
/problems/170_two-sum-iii-data-structure-design/main.py
1,417
4.15625
4
# https://leetcode.com/problems/two-sum-iii-data-structure-design/ # Design and implement a TwoSum class. It should support the following operations: add and find. # # add - Add the number to an internal data structure. # find - Find if there exists any pair of numbers which sum is equal to the value. # # For example, ...
true
a9048140fd89a0ddd754998f28406df67c157237
nshirajee/pythonLab9
/Lab9_07.py
698
4.375
4
#function to calculate Fibonacci sequence def fibonaccisequence(number): #Initialize variable #second seq starts with 1 firstseq = 0 secondseq = 1 #loop through number of sequence parameter for x in range(number): #only print second seq, first time it'll print 1, after that it'll print b...
true
6457791201c288cedf1fed76ebb1d8d84c0d2a62
Ahsank01/Python-Crash-Course
/String/String.py
1,407
4.5
4
# Name: Ahsan Khan # Date: 09/15/2020 # Description: Using string and its built-in functions, and manipulating the string. # the function .title() will make the first initial a capital letter name = "ahsan khan" print(name.title()) #------------------------------------------------------------------# # the ...
true
5b4450467c870a1b744ffae3002531f8d2c201aa
Ahsank01/Python-Crash-Course
/User Input and While loop/Introducing_while_loops.py
2,380
4.15625
4
# Name: Ahsan Khan # Date: 10/06/20 # Description: Intro to while loops and user input current_number = 1 while current_number <= 5: print(current_number) current_number += 1 # ================================================================ # prompt = "\nTell me something, and I will repeat it back to you. " pr...
true
e7fef2eedf81f18684d7189811f2c4b880c84953
Ahsank01/Python-Crash-Course
/Dictonaries/Exercises/Polling.py
822
4.1875
4
# Name: Ahsan Khan # Date: 09/29/20 # Description: Make a list of people who should take the favorite language poll. # Loop through the list of people who should take the poll. # If they have already taken the poll, print a message thanking them for responding. # If they haven...
true
0bcb649346aeb69b41da7c9e562fad76306d2fc2
Ahsank01/Python-Crash-Course
/IF_Statement/if_statement.py
2,343
4.21875
4
# Name: Ahsan Khan # Date: 09/23/20 # Description: Get familiar with Python IF STATEMENT cars = ['honda', 'mercedes', 'toyota', 'bmw'] for car in cars: if car == 'bmw': print(car.upper()) else: print(car.title()) # --------------------------------------------------------- # #Checking for ineq...
true
0586323efb3299b119d17034d91e0a8553c72be9
ortizjs/algorithms_
/python-practice/command_line_calendar.py
2,660
4.53125
5
"""In this project, we'll build a basic calendar that the user will be able to interact with from the command line. The user should be able to choose to: View the calendar Add an event to the calendar Update an existing event Delete an existing event The program should behave in the following way: Print a welcome mes...
true
7fc53c96a3cfdadd93c48fffd1c1179c52119ef4
ortizjs/algorithms_
/InterviewCakeProblems/reverse_words.py
1,853
4.125
4
# def reverse_words(message): # mess1 = "".join(message) # # print mess1 # mess2 = mess1.split(" ") # # print mess2 # lower = 0 # upper = len(mess2) - 1 # while lower < upper: # temp = mess2[lower] # mess2[lower] = mess2[upper] # mess2[upper] = temp # lower +=...
true
a4ee1cb6352cb07b932d1b8c0540c2326a02fdd9
ortizjs/algorithms_
/python-practice/permutation_palindrome.py
788
4.28125
4
# Write an efficient function that checks whether any permutation of an input string is a palindrome. # You can assume the input string only contains lowercase letters. # Examples: # "civic" should return True # "ivicc" should return True # "civil" should return False # "livci" should return False def permutation_p...
true
0e8619e739be81640b2d3ceefd204b3b1cc719e8
dmellors/raspberry_pi_projects
/led_dice.py
2,066
4.25
4
# Simulate a random dice roll with LED's import RPi.GPIO as GPIO import time import random # list containing LED GPIO pin numbers LED = [18,23,24,25] button = 7 # set GPIO mode of operation to BCM GPIO.setmode(GPIO.BCM) # disable GPIO warning events if pin already in use GPIO.setwarnings(False) # Initialise the op...
true
e336c02a69906b8398611692056c7321f42a1403
zingpython/february2018
/day_six/insertionSort.py
1,201
4.40625
4
#Create function for insertion sort. This takes in a list to be sorted def insertionSort(starting_list): #Index is the current index we are comparing and sorting index = 0 #Run the code until every index has been sorted while index < len(starting_list): print(starting_list) #FOr each index check every index ...
true
835bc940203b3a7ce1d71ac96d756409334c5c18
Dallas-Johnson-Dev/AlgorithmsLowestCostPath
/lowestcost.py
2,030
4.125
4
""" Python Program written to find the lowest cost path from the bottom row of a grid to the top. Written by Dallas Johnson Requires one input which is the size of the grid. The grid is an N x N size grid, so only one positive integer is needed. """ import random from sys import argv class GridTile: value = None...
true
205c589c1f5b97c86b5fa75481d6b87577f6457f
Preetpalkaur3701/Python
/bitonic_sort.py
1,616
4.28125
4
# Python program for Bitonic Sort. Note that this program # works only when size of input is a power of 2. # The parameter direction indicates the sorting direction, ASCENDING # or DESCENDING; if (a[i] > a[j]) agrees with the direction, # then a[i] and a[j] are interchanged. def compAndSwap(array, i, j, direction): ...
true
09bfa0b20170187deeef2b87220cd36f6bcfe7e4
Preetpalkaur3701/Python
/order.py
375
4.3125
4
# Append Dictionary Keys and Values ( In order ) in dictionary from itertools import chain # initializing dictionary my_dict = {"I" : 1, "am" : 3, "the" : 2, "BEST" : 4} print("The original dictionary is : " + str(my_dict)) #appending the dictionary new_dict = list(chain(my_dict.keys(), my_dict.values())) print("...
true
a1e87853999274b199f412078a7f4dba9c5fb440
shills112000/django_course
/PYTHON/DATE-CALENDAR/patch_tuesday.py.old
2,199
4.3125
4
#!/usr/bin/python3.6 import calendar import datetime #https://www.w3schools.com/python/python_datetime.asp x = datetime.datetime.now() #print(x) #print(x.year) #print(x.month) #print(x.day) #print(x.strftime("%A")) # FULL DAY #print(x.strftime("%b")) # short month #print(x.strftime("%B")) # full month # Show every m...
true
9487d17d790c6f66438d80d4cedba7b778d105a7
shills112000/django_course
/PYTHON/STATEMENTS_WHILE_FOR_IF/useful_operators.py
1,733
4.15625
4
#!/usr/local/bin/python3.7 mylist = [1,2,3] #range (start,stop[,step[]) # This will pring all number up to 10 starting at 0 for num in range(10): print (num) for num in range(3,10): # start are 3 go up to 10 print (num) for num in range(0,10,2): # start at 0 going to up to 10 steping two at a time , even ...
true
8302bfb9bcb5228c8a0ac92d63bbafcf7937adb9
shills112000/django_course
/PYTHON/OBJECT_ORIENTATED_PROGRAMING/polymorphism.py
993
4.25
4
#!/usr/local/bin/python3.7 #Inheritance #form new classes using classes that have already been defined. # polymophism , refers to the way in different object classes can share same method name. class Animal(): # Base class def __init__(self,name): self.name = name def speak(self): raise No...
true
c1aa7cef2ceb1b17887c45cf442ef7b6ece52ceb
shills112000/django_course
/PYTHON/STATEMENTS_WHILE_FOR_IF/boolean_comparisons.py
740
4.15625
4
#!/usr/local/bin/python3.7 print( 2 == 2) # True print( 2 == 1) # False print ( 'hello' == 'bye') # False print ('2' == 2 ) # False as one is a string, one is a number print (2.0 == 2 ) # True even when using ints and floating points print (3 != 3) # False as 3 is = 3 print (4 != 5) # true 4 is not equal to 5 p...
true
89e3818196b7c7364fc2e5b4369eb63213be9471
juliocesardiaz/lpthw
/ex33/ex33.py
479
4.15625
4
def looper(x, increment): i = 0 numbers = [] while i < x: print "At the top i is %d" % i numbers.append(i) i += increment print "Numbers now: ", numbers print "At the bottom i is %d" % i print "The numbers: " for num in numbers: print num def fo...
true
9679509720a8f00a1fc92285f6bc4110dd1ec9e4
karolinanikolova/SoftUni-Software-Engineering
/3-Python-Advanced (May 2021)/02-Tuples-and-Sets/02_Exercises/02-Sets-of-Elements.py
859
4.15625
4
# 2. Sets of Elements # Write a program that prints a set of elements. On the first line, you will receive two numbers - n and m, # which represent the lengths of two separate sets. On the next n + m lines you will receive n numbers, # which are the numbers in the first set, and m numbers, which are in the second set. ...
true
be15efd47f50e86e0f1a2c10ad0aa47372b34fc1
karolinanikolova/SoftUni-Software-Engineering
/3-Python-Advanced (May 2021)/04-Comprehensions/02_Exercises/07-Flatten-Lists.py
497
4.375
4
# 7. Flatten Lists # Write a program to flatten several lists of numbers, received in the following format: #  String with numbers or empty strings separated by '|'. #  Values are separated by spaces (' ', one or several) #  Order the output list from the last to the first received, and their values from left to rig...
true
85261586cefefbe35e2d0bb6949de0e17d85dbf9
karolinanikolova/SoftUni-Software-Engineering
/3-Python-Advanced (May 2021)/01-Lists-as-Stacks-and_Queues/02_Exercises/07-Robotics-NOT-DONE.py
2,424
4.125
4
# 7. *Robotics # Somewhere in the future, there is a robotics factory. The current project is assembly line robots. # Each robot has a processing time – it is the time in seconds the robot needs to process a product. # When a robot is free it should take a product for processing and log his name, product and processing...
true
d241f7c3c5539d110722527a197dba0560112b18
karolinanikolova/SoftUni-Software-Engineering
/2-Python-Fundamentals (Jan 2021)/Course-Exercises-and-Exams/00-Exam-Prep/01_Mid_Exam_Prep/03-Programming-Fundamentals-Mid-Exam-Retake/01-Counter-Strike.py
1,467
4.25
4
# Problem 1. Counter Strike # Write a program that keeps track of every won battle against an enemy. # You will receive initial energy. # Afterwards you will start receiving the distance you need to go to reach an enemy until the "End of battle" command is given, or until you run out of energy. # The energy you need fo...
true
2ada51562fcc5a4ca7001ec06c36fe59cfeb906a
karolinanikolova/SoftUni-Software-Engineering
/2-Python-Fundamentals (Jan 2021)/Course-Exercises-and-Exams/06-Objects-and-Classes/02_Exercises/06-Inventory.py
1,311
4.1875
4
# 6. Inventory # Create a class Inventory. The __init__ method should accept only the capacity of the inventory. # The capacity should be a private attribute (__capacity). You can read more about private attributes here. # Each inventory should also have an attribute called items, where all the items will be stored. Th...
true
e2440695bc953bf52f81cdc173fd65332e977049
karolinanikolova/SoftUni-Software-Engineering
/2-Python-Fundamentals (Jan 2021)/Course-Exercises-and-Exams/01-Basic-Syntax-Conditional-Statements-and-Loops/02_Exercises/04_Double-Char.py
269
4.25
4
# 4. Double Char # Given a string, you have to print a string in which each character (case-sensitive) is repeated. text = input() # for char in text: # print(char * 2, end='') result_text = '' for char in text: result_text += 2 * char print(result_text)
true
07163e679661baceb76c37114044834ae6399e59
karolinanikolova/SoftUni-Software-Engineering
/2-Python-Fundamentals (Jan 2021)/Course-Exercises-and-Exams/09-Regular-Expressions/02_Exercises/01-Capture-the-Numbers.py
470
4.34375
4
# 1. Capture the Numbers # Write a program that finds all numbers in a sequence of strings. # The output is all the numbers, extracted and printed on a single line – each separated by a single space. import re text_line = input() pattern = r"\d+" all_numbers = [] # while not text_line == "": while text_line: nu...
true
1f38f6f6c5589bb6af149a195593be239f59de2d
karolinanikolova/SoftUni-Software-Engineering
/3-Python-Advanced (May 2021)/04-Comprehensions/01_Lab/01-ASCII-Values.py
298
4.28125
4
# 1. ASCII Values # Write program that receives a list of characters separated by ", " and creates a dictionary with each character # as a key and its ASCII value as a value. Try solving that problem using comprehensions. dictionary = {ch: ord(ch) for ch in input().split(', ')} print(dictionary)
true