blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
acdda0fa4bceeaf72b4b94836f606591b7141a6c
joook1710-cmis/joook1710-cmis-cs2
/assignment1.py
2,319
4.3125
4
#Created a variable and defined my name. myName = "Joo Ok Kim" print myName #Created a variable and defined my age. myAge = 16.4 print myAge #Created a variable and defined my height. myHeight = 1.65 print myHeight #Created a variable and defined the length of a sqaure. lengthOfSquare = 4 print lengthOfSquare #Cre...
true
95e1b9576d1227e9bbe48ad5045c65f55605fb8e
indykiss/DataStructures-Algos
/Leetcode/Python Easies/Anagram_mappings.py
878
4.15625
4
# Find Anagram Mappings # You are given two integer arrays nums1 and nums2 where nums2 is # an anagram of nums1. Both arrays may contain duplicates. # Return an index mapping array mapping from nums1 to nums2 where # mapping[i] = j means the ith element in nums1 appears in nums2 at index j. # If there are multiple...
true
efaabae63cbd556d6e1a3d52a1bb39d61a163fab
Zahidsqldba07/codingbat-programming-problems-python
/Solutions/string-2/end_other.py
579
4.1875
4
# Given two strings, return True if either of the strings appears at # the very end of the other string, ignoring upper/lower case differences # (in other words, the computation should not be "case sensitive"). # Note: s.lower() returns the lowercase version of a string. # end_other('Hiabc', 'abc') → True # end_other(...
true
55ea429df48b2ae917a8239f40e1a12acad1179d
yasu094/learning-python
/10-calendars.py
1,139
4.15625
4
import calendar # print a text calendar (week start day is Sunday) c = calendar.TextCalendar(calendar.SUNDAY) str = c.formatmonth(2020, 1, 0, 0) print (str) # create an HTML formatted calendar hc = calendar.HTMLCalendar(calendar.SUNDAY) str = hc.formatmonth(2020, 1) print (str) # loop over the days of a month # zero...
true
fc74fe344919966935cef5b6eb206e92564af881
nseetim/Hackerrank_challenges
/String_Validators.py
2,562
4.34375
4
''' Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc. str.isalnum() This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9). >>> print 'ab123'.isalnum() True >>> print ...
true
819f06ff47d9843a78fb41d30b6960ab7c77c710
PapaGateau/Python_practicals
/089-Safe_list_get/safe_list_get.py
629
4.15625
4
def recuperer_item(liste, index): """function to get and element form a list using its index incorrect indexes are protected and will return an error string Args: liste ([list]): [list searched] index ([int]): [index of searched element] Returns: [str]: [list element or error s...
true
dcf82c1d994f980388094411e11da0c36af8b939
BhagyashreeKarale/function
/output2.py
1,629
4.28125
4
# def primeorNot(num): # if num > 1:#it will only take numbers more then 1,not even 1 # for i in range(2,num):#all the numbers from 2 to the given number.i.e in this case 406 # if (num % i) == 0: # print(num,"is not a prime number") # print(i,"times",num//i,"...
true
ab111b6810f7652e3f3b52e2eb1934971f8484c9
BhagyashreeKarale/function
/palindrome.py
622
4.375
4
# Write a Python function that checks whether a passed string is palindrome or not. def palindromecheck(string): rlist=(string[::-1]) if rlist == string: print("It is a palidrome") else: print("It isn't a palidrome") # another one for palidrome: def palidromecheck2(string): left_pos = 0 ...
true
72871b67dd71410aedb185651c2764a1397aa5f0
DorotaNowak/machine-learning
/simple-linear-regression/simple_linear_regression.py
1,057
4.15625
4
# Simple linear regression import numpy as np import pandas as pd import matplotlib.pyplot as plt dataset = pd.read_csv('Salary_Data.csv') # print(dataset.head()) X = dataset.iloc[:,:-1].values y = dataset.iloc[:,1].values from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_t...
true
b10395a36be87b043ed18ad3973f2ae4eeb955ca
tdominic1186/ATBS
/Chapter 2/question13while.py
214
4.28125
4
""" 13. Write a short program that prints the numbers 1 to 10 using a for loop. Then write an equivalent program that prints the numbers 1 to 10 using a while loop. """ i = 1 while i < 11: print(i) i += 1
true
e168e246982a5e6861163b33e13510592705ae44
adivis/PythonProg
/prob_5.py
1,233
4.1875
4
""" Problem Statement:- You are given few sentences as a list (Python list of sentences). Take a query string as an input from the user. You have to pull out the sentences matching this query inputted by the user in decreasing order of relevance after converting every word in the query and the sentence to lowercase. Mo...
true
764a3d777da00681901ef7251ac5c2925d57576c
kazamari/Stepik
/course_568/2.245_repetition coding.py
687
4.375
4
''' Encoding of repeats is carried as the following: s = 'aaaabbсaa' is converted into 'a4b2с1a2', that is, the groups of the same characters of the input string are replaced by the symbol and the number of its repetitions in this string. Write a program that reads a line from the file corresponding to the string, com...
true
16b4c66261f6057635577382f87f38df85f3c289
kazamari/Stepik
/course_568/2.316_re-occurrence-of-a-symbol.py
2,386
4.625
5
''' In this problem, we will look how to implement re-occurrence of a symbol using regular expressions. We may use the three various constructions to implement the repeat: 1. Wildcards { }, inside which we can place the minimum/maximum number of repeats that we are satisfied with, or the exact number of repeats tha...
true
6afb4c76020ade8c19294dbd36574926ed37223f
kazamari/Stepik
/course_568/2.325_message-encoding.py
578
4.46875
4
''' We will be dealing with a trivial example of message encoding, where the mapping of original symbols to the "code" is simply taking the ASCII value of the symbol. For example, the "code" version of the letter 'A' would be 65. You will be given as input a string of any length consisting of any possible ASCII charac...
true
7a09b5c4a6616f296b64ef2f9797799193fdc167
ZacharyLasky/Algorithms
/recipe_batches/recipe_batches.py
956
4.125
4
#!/usr/bin/python import math def recipe_batches(recipe, ingredients): min_batch = None for ingredient in recipe: if ingredient in ingredients: batches = ingredients[ingredient] // recipe[ingredient] if min_batch is None: min_batch = batches else: ...
true
29a00d5c563dc100b8e3e07fd813b23838961cff
Nyajur/python-pill
/18 exponent_again.py
572
4.125
4
base = float(input("Please enter a number: ")) exponential = float(input("Pleae enter a power to raise to: ")) def raiser(): return base**exponential print(raiser()) def raiser(): base = float(input("Please enter a number: ")) exponential = float(input("Pleae enter a power to raise to: ")) return base*...
true
eaa3e22cabb29391f6aaf4531f8b76e7d465c321
xlaw-ash/VSLearn-Python
/PythonBasics/comprehensions.py
1,624
4.90625
5
# for loops have some special uses with List Comprehensions # Make a list of letters in greeting string. greeting = 'Hello World!' letters = [] for letter in greeting: letters.append(letter) print(letters) letters = [] # Above 3 statements can be combined in a single line. letters = [letter for letter in greeting]...
true
8aac407392e79b9f910e117562de31c5dd678d7a
xlaw-ash/VSLearn-Python
/PythonBasics/booleans.py
2,490
4.625
5
# Booleans have only two values. Either True or False. # Booleans are used for conditions. yes = True no = False print(yes) print(type(yes)) # Booleans are mostly used with logical operators. There are three main logical operators. # 'and' operator between two conditions returns True only when both conditions are True...
true
d4701afadc306985d744bdc1b613fd1a5330fd4b
kehillah-coding-2020/ppic04-ForresterAlex
/set_d.py
1,748
4.5625
5
#!/usr/bin/env python3 # # pp. 148, 151 # """ 4.36 Modify the frequency chart function to draw wide bars instead of lines. """ """ 4.37* Modify the frequency chart function so that the range of the x axis is not tightly bound to the number of data items in the list but rather uses some minimum and maximum values. "...
true
679e5e6734b9f3fa577e914c7b6ca3655dfc3884
StefanoskiZoran/Python-Learning
/Practise provided by Ben/Clock Calculator by Me.py
1,210
4.125
4
""" Request the amount of seconds via keyboard, turn the seconds into months/days/years/decades etc. """ def main(): seconds_request = int(input(f'Please input your desired seconds: ')) minute_result = 0 hour_result = 0 day_result = 0 month_result = 0 year_result = 0 decade_result = 0 ...
true
254aa0ded80bba9f1cefcf1bee130276579604a6
KitsuneNoctus/makeschool
/site/public/courses/CS-1.2/src/PlaylistLinkedList-StarterCode/main.py
1,584
4.5
4
from Playlist import Playlist playlist = Playlist() while True: # Prints welcome message and options menu print(''' Welcome to Playlist Maker 🎶 ===================================== Options: 1: View playlist 2: To add a new song to playlist 3: To remove a song from playlist 4: ...
true
f3c543fb60d13114cd3e3b1b80176cae8c1f4d6b
KitsuneNoctus/makeschool
/site/public/courses/CS-2.2/Challenges/Solutions/challenge_1/src/vertex.py
1,155
4.25
4
class Vertex(object): """ Vertex Class A helper class for the Graph class that defines vertices and vertex neighbors. """ def __init__(self, vertex_id): """Initialize a vertex and its neighbors. neighbors: set of vertices adjacent to self, stored in a dictionary with k...
true
54433cda9ab97c3b60023dd046cc7aafc1f06908
KitsuneNoctus/makeschool
/site/public/courses/CS-2.1/Code/prefixtreenode.py
2,797
4.40625
4
#!python3 class PrefixTreeNode: """PrefixTreeNode: A node for use in a prefix tree that stores a single character from a string and a structure of children nodes below it, which associates the next character in a string to the next node along its path from the tree's root node to a terminal nod...
true
6e332a122b6c6a83a49e2bdcc66aaba3bfb8a191
MayankMaheshwar/DS-and-Algo-solving
/hypersonic2.py
585
4.125
4
""" 1) Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not a...
true
a1fcaf556a09f43581122e608c1995ec37bbc260
nrkavya/python-training
/1.py
308
4.375
4
#Create a program to compare three numbers and find the bigger numbers no1 = int(input("Enter no1")) no2= int(input ("Enter no2")) no3 = int(input("enter no3")) if(no1>no2 and no1>no3): print("no1 is greatest") elif(no2>no1 and no2>no3): print("no2 is greatest") else: print("no3 is greatest")
true
60308a1f2aa94fa65c89ca7461b1ec664a7beba5
riceh3/210CT-CW
/binary_search.py
1,358
4.15625
4
def binary_search(entry): # Divide and Conquer """ Search through input for values within the given high & low parameters """ length = len(entry) middle = length/2 # Find the middle value in the list middle = int(middle) if entry[middle] == low or entry[mid...
true
cf981cdb74758f85e6e9801b94a2394911268a0a
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 21. Object-Oriented Design/demos/point.py
1,932
4.21875
4
""" A module with a simple Point3 class. This module has a simpler version of the Point class. The primary purpose of this module is to show off the built-in methods __str__ and __repr___ Author: Walker White (wmw2) Date: October 20, 2019 """ import math class Point3(object): """ A class to represent a p...
true
d52820228570073946ec653e69322c7d30a2d315
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/Lesson 28. Generators/demos/filterer.py
1,139
4.1875
4
""" Module to demonstrate the idea behind filter This module implements the filter function. It also has several support functions to show how you can leverage it to process data. You may want to run this one in the Python Tutor for full effect. Author: Walker M. White (wmw2) Date: May 24, 2019 """ def filter(f,...
true
c1478e4316bf8c3c4c764d4192dcb54b7d1140fa
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 17. Recursion/demos/com.py
1,950
4.53125
5
""" A recursive function adding commas to integers. These functions show the why the choice of division at the recursive step matters. Author: Walker M. White (wmw2) Date: October 10, 2018 """ import sys # Allow us to go really deep #sys.setrecursionlimit(999999999) # COMMAFY FUNCTIONS def commafy(s): """ ...
true
0ff7c36732279dd198f5034931b84041c0ac45d4
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 16. For-Loops/demos/mut.py
906
4.40625
4
""" Module to demonstrate how to modify a list in a for-loop. This function does not use the accumulator pattern, because we are not trying to make a new list. Instead, we wish to modify the original list. Note that you should never modify the list you are looping over (this is bad practice). So we loop over the ran...
true
e633be9b864b2ae81f2275718708f73f9aff44e6
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 26. While-Loops/demos/newton.py
1,256
4.40625
4
""" A module to show while-loops and numerical computations. This is one of the most powerful uses of a while loop: using it to run a computation until it converges. There are a lot of algorithms from Calculus and Numerical Analysis that work this way. Author: Walker M. White Date: April 15, 2019 """ def sqrt(c,...
true
cb35550231866abfbadca029a1c91a125a2e9e2f
gunishj/python_async_multiprocessing
/AsyncIO/implementing_asyncio.py
1,157
4.5625
5
import asyncio import time def sync_f(): print('one', end=' ') time.sleep(1) # I'm simulating an expensive task like working with an external resource. I want it to wait for 1 sec print('two', end=' ') # ASYNCHRONOUS async def async_f(): print('one', end=' ') await asyncio.sleep(1) print('two',...
true
0fcd16dcfa157c95f8ff55b16fb8e8f687a96e62
Regenyi/python
/Thonny_continue.py
729
4.15625
4
menu = """-- Calculator Menu -- 0. Quit 1. Add two numbers 2. Subtract two numbers 3. Multiply two numbers 4. Divide two numbers""" selection = None while selection != 0: print(menu) selection = int(input("Select an option: ")) if selection not in range(5): print("Invalid option: %d" % selection)...
true
fa669ab56fb32241a23d3f9d00857001571cb2b2
Regenyi/python
/sorting.py
1,608
4.1875
4
#Sorting algo - RA CC Python SI1 A3 import re #getting the number from the user: input_numbers = [] input_numbers = input("\nTell me positive integers that you want to sort, by separting them with a coma (so for example: 10,2,45):\n\n") #exception handler for wrong format: while True: if (len(input_numbers)<6 or...
true
a3c4170dbc8d48142cf7f8319ba45775e1956886
Tij99/compsci-jmss-2016
/triangleXs.py
384
4.28125
4
# Write a program to print out an isosceles triangle of Xs # rewrite the program to work for an arbitrary number of rows (ie the user can # enter the required number of rows) def triangle(height): for i in range(height): spaces = height - i - 1 xs = 2 * i + 1 print("-" * spaces + "|" * xs ...
true
f8ac9454b1333d1fce5f4f43c2d3b54731b979b7
ArthurkaX/W3SCHOOL-learning
/Python basic P1/Ex_3.py
286
4.40625
4
# Write a Python program to display the current date and time import datetime print('first variant:') print('current date & time is:') print(datetime.datetime.now()) now = datetime.datetime.now print('second variant:') print('{0:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
true
d5fac45dfae4e162546dd53c4a2b3bd154bcc4a3
ArthurkaX/W3SCHOOL-learning
/Python basic P1/Ex_1.py
514
4.25
4
# Write a Python program to print the following string in a specific format some_txt = 'Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are' x = 0 for a in some_txt: if a.isupper() == True and a ...
true
50426db78b533ce033a059f1157c9f0d44123146
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_9_Classes/Dog.py
800
4.21875
4
class Dog(object): """A simple attempt to model a dog.""" def __init__(self,name,age): """Initialize name and age attribute""" self.name=name self.age=age def sit(self): """Simulate a dog sitting in response to a command""" print(self.name.title()+" is now sitting.")...
true
91b3c0eace34899e1e0f2c1e40853ace87382362
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_3_Intoducing_Lists/bicyclesIntroToLists.py
1,152
4.625
5
#In Python, square brackets indicate a list, and individual elements in the list are separated by commas. bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(bicycles) #Because this isnt the output you want your users to see, lets learn how to access the individual items in a list. #To access an ele- ment...
true
0ba59210ae47c36fd6abeab0670ead59fef062f7
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_3_Intoducing_Lists/untitled folder/3-3.py
462
4.46875
4
# 3-3. Your Own List: Think of your favorite mode of # transportation, such as a motorcycle or a car, and # make a list that stores several examples. Use your # list to print a series of statements about these items, # such as “I would like to own a Honda motorcycle.” cars = ['audi' , 'bmw' , 'mercedes'] print("I wou...
true
d88e288cffdaf538374ae33bc2f91b3410b3b143
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_9_Classes/electric_car.py
2,219
4.46875
4
class Car(object): """A simple attempt to represent a car""" def __init__(self,make,model,year): """Initialize attributes to describe a car""" self.make=make self.model=model self.year=year self.odometer_reading=0 def get_descriptive_name(self): """Return a ...
true
d11e007939ad611f6f34dbf43ef9949442310658
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_7_User_Input_And_While_Loop/Practice2/4.rollercoaster.py
209
4.15625
4
height = raw_input("How tall are you , in inches? ") height = int(height) if height >= 36: print("\nYou're tall enought to ride!") else: print("You will be able to ride when you're a little older.")
true
68b3d1a63e3df0f1f75e4fc83af3a3dd2b29f093
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_3_Intoducing_Lists/untitled folder/3-2Greetings.py
477
4.25
4
# 3-2. Greetings: Start with the list you used in Exercise 3-1, but instead of just printing each persons name, # print a message to them. The text of each message should be the same, but each message should be personalized # with the persons name. friend_list=['manan','samarth','rohan','rishi'] print ("Hello, "+frien...
true
3389a5cd1051d2edcf6125b7adb4452d591f0726
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_9_Classes/practice2/9-6.IceCreamStand.py
1,332
4.21875
4
class Restaurant(): """An attempt to model a restaurant""" def __init__(self,restaurant_name,cuisine_type): """Initializing name and age attributes""" self.name = restaurant_name self.cuisine = cuisine_type def describe_restaurant(self): # Describes the restaurant name...
true
9a707f3c487622e2c8caa16d2d8ca8c4d7507911
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_8_Functions/practice2/16.profile.py
989
4.53125
5
# Sometimes you'll want to accept an arbitary number of # argument but you won't know ahead of time # what kind of information will be passed to the # function. # Write a function that accepts as many key-value pairs as the # calling statement provides. # Example : Building user profiles. # You're sure that you'll ge...
true
c9349dd22148f7f878bb1be59820cc8e1b6ddcd5
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_10_File_And_Exceptions/10-6.Addition.py
1,950
4.15625
4
while True: try: first_number = raw_input("Give me two numbers and i will add them." + "\nEnter 'quit' to quit program anytime."+ "\nFirst Number: ") if first_number == 'quit': break else: first_number = int(first_number) second_number ...
true
f2d74a5bea40e74454c884bfefb8ec99d9b9d276
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_5_If_Statements/banned_users_CheckWhetherAValueIsInAList.py
986
4.125
4
print "Checking whether a value is not in a list " # Other times, its important to know if a value does not appear in a list. # You can use the keyword not in this situation. For example, consider a # list of users who are banned from commenting in a forum. You can check whether # a user has been banned before allo...
true
7d900b9d8a49c9f3b4753b7c8effd72764ddbbf6
sweenejp/learning-and-practice
/treehouse/python-beginner/monty_python_tickets.py
1,349
4.15625
4
SERVICE_CHARGE = 2 TICKET_PRICE = 10 tickets_remaining = 100 def calculate_price(number_of_tickets): # $2 service charge per transaction return (number_of_tickets * TICKET_PRICE) + SERVICE_CHARGE while tickets_remaining > 0: print("There are only {} tickets remaining!\nBuy now to secure your spot for th...
true
8b69c22357ef25ddca9167989f2337674fe78784
sweenejp/learning-and-practice
/practicepythondotorg/exercise_14.py
692
4.1875
4
# Write a program (function!) that takes a list and returns a new list that contains all the # elements of the first list minus all the duplicates. # # Extras: # # Write two different functions to do this - one using a loop and constructing a list, # and another using sets. Go back and do Exercise 5 using sets, and wri...
true
cb066d54e563da61e1c97f7621ac4ac43c42e3e1
sweenejp/learning-and-practice
/treehouse/python-beginner/team.py
1,286
4.21875
4
# TODO Create an empty list to maintain the player names player_names = [] # TODO Ask the user if they'd like to add players to the list. wants_to_add = input("Would you like to add a player to the team?\nYes/no: ") # If the user answers "Yes", let them type in a name and add it to the list. while wants_to_add.lower...
true
28301a007b829871cd518834994588e9f088b53b
Kinosa777/Lits-Python
/convert_n_to_m.py
1,377
4.21875
4
def convert_n_to_m(x, n, m): """Converts a number in n-based system into a number in m-based system.""" def convert_n_to_dec(x): """Converts a n-based number into decimal. No int(num, base) function for number conversion is used.""" if n == 10: return x elif n == 1: ...
true
3aecd3afc0558b00aa683aeb245b1e2876f78706
hazim/Treehouse---Python-Basic
/check_please.py
519
4.21875
4
import math def split_check(total, number_of_people): # we want to round up the number in order to make sure that the person paying is not paying the extra out of their own pocket return math.ceil(total_due / split_among) try: total_due = float(input("What is the total? \n")) split_among = int(input("How many ...
true
7f4dd8521d12aa3d208fa4c51d507d84b304de6b
mtaziz/python_projects
/Basic Rock Paper Scissors Game (CLI).py
1,945
4.25
4
import random # Welcome text print("ROCK PAPER SCISSORS") # Game variables ties = 0 wins = 0 losses = 0 # Gameloop while True: # Displaying game data. print("%s Wins, %s Loses, %s Ties" % (wins, losses, ties)) # Loop for player choice. while True: print("Enter any one: (r)ock (p)aper (s)ciss...
true
5af7a4ac6b300fee0b1e86a4eb14378eb9243279
cgscreamer/UdemyProjects
/Python/dictionaries.py
671
4.1875
4
fruit = {"orange": "a sweet, orange, citrus fruit", "apple": "good for making cider", "lemon": "a sour, yellow citrus fruit", "grape": "a small, sweet fruit growing in bunches", "lime": "a sour, green citrus fruit"} #To add to a dictionary fruit["pear"] = "an odd shaped apple" #To ...
true
fa82962cae016363dee794c962553a62b8a4fdc8
andyhou2000/exercises
/chapter-6/ex_6_5.py
1,129
4.125
4
# Programming Exercise 6-5 # # Program to total the value of numbers in a text file. # The program takes no user input, but requires a text file with numbers, one per line, # which it opens, reads line by line, and totals the numbers in a variable, # then displays the total on the screen. # Define the main ...
true
5bd4a64c40de41eb21d95ec08c4ce5ba06d351b8
andyhou2000/exercises
/chapter-4/ex-4-5.py
2,173
4.46875
4
# Programming Exercise 4-5 # # Program to compute total and average monthly rainfall over a span of years. # This program gets a number of years from a user, # then uses nested loops to prompt for rainfall for each month in each year # and calculate the total and the average monthly rainfall, # then displays the ...
true
80c8bb6fa0068c40e7417af66c9230ec5945fcfc
andyhou2000/exercises
/chapter-2/ex-2-5.py
797
4.59375
5
# Programming Exercise 2-5 # # Program to calculate distances traveled over time at a speed. # This program uses no input. # It will calculate the distance traveled for 6, 10 and 15 hours at a constant speed, # then display all the results on the screen. # Variables to hold the three distances. # be sure to in...
true
ddc8b5c1c688595eb24cdebc4d594fa50faa04c6
impradeeparya/python-getting-started
/tree/SymetricTree.py
2,042
4.21875
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def is_child_symmetric(self, children): is_symmetric = True left_index = 0 right_ind...
true
a145bda0848c345599343ef6abee82d44a11ba41
chanchalkumawat/Learn-Python-Hardway
/ex4of46.py
351
4.15625
4
#Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise. def check(c): if c=='a'or c=='A' or c=='e' or c=='E' or c=='i' or c=='I' or c=='o' or c=='O' or c=='u' or c=='U': return True else: return False z=raw_input("Enter the charact...
true
7278e5b16a928c6764dde79d296d30e063352e93
taylorperkins/foobar
/test/test_solar_doomsday.py
1,916
4.125
4
import unittest from utils import print_time from logic.solar_doomsday import answer class TestSolarDoomsday(unittest.TestCase): """Challenge 1 Solar Doomsday ============== Who would've guessed? Doomsday devices take a LOT of power. Commander Lambda wants to supplement the LAMBCHOP's quantum an...
true
719d9d0e1b3548a2b791779d09693228e0824ab7
prof-paradox/project-euler
/7.py
520
4.125
4
''' Calculates the 10001st prime number ''' import math def isPrime(num): if num % 2 == 0: return False for i in range(3, round(math.sqrt(num)) + 1, 2): if num % i == 0: return False return True natural_no = 3 prime_count = 1 # initial count for 2 max_prime = 2...
true
db37990f15e0b9eaeab5dacf38b1adf87735b416
rawsashimi1604/Qns_Leetcode
/leetcode_py/valid-parentheses.py
834
4.125
4
class Solution: def isValid(self, s: str) -> bool: stack = [] lookup = { "}": "{", ")": "(", "]": "[" } for p in s: if p in lookup.values(): stack.append(p) # Must make sure that stack exists, so that there...
true
df38b1d404b01498a368916adb754a496f354c1e
callumr1/Programming_1_Pracs
/Prac 4/number_list.py
681
4.15625
4
def main(): numbers = [] print("Please input 5 numbers") for count in range(1, 6): num = int(input("Enter number {}: ".format(count))) numbers.append(num) average = calc_average(numbers) print_numbers(numbers, average) def calc_average(numbers): average = sum(numbers) / len(nu...
true
c543270a6ffa5c251551c3cc3eb2082e013a2e0e
CRUZEAAKASH/PyCharmProjects
/section3_StringsAndPrint/String Methods.py
1,469
4.5
4
""" len() and str() practice: 1.create a variable and assign it the string "Python" 2.create another variable and assign it the length of the string assigned to the variable in step 1 3.create a variable and use string slicing and len() to assign it the length of the slice "yth" from the string assigned to the variabl...
true
15d758afcd551443056c912accd5a639b0d150c2
CRUZEAAKASH/PyCharmProjects
/section4_ConditionalsAndFlowControl/BooleanOperatorProblems.py
1,605
4.625
5
""" and, or, and not: 1.create a variable and set it equal to True using a statement containing an "and" Boolean operator 2.create a variable and set it equal to False using a statement containing an "and" Boolean operator 3.create a variable and set it equal to True using a statement containing an "or" Boolean operato...
true
cafc90b922a9c73f77e2ff2d3020c8563e93d60b
CRUZEAAKASH/PyCharmProjects
/section14_RegularExpressions/findAll.py
215
4.15625
4
import re pattern = r"eggs" String = "We have eggs in our string. eggs just eggstoeggs count the presence of eggs in the string" print(re.findall(pattern, String)) print(re.findall(pattern, String).__len__())
true
f5b2f41977280c6920d18c3736071647b38f0786
CRUZEAAKASH/PyCharmProjects
/section5_Functions/FunctionsProblems.py
2,525
4.875
5
""" Single parameter and zero parameter functions: 1.define a function that takes no parameters and prints a string 2.create a variable and assign it the value 5 3.create a function that takes a single parameter and prints it 4.call the function you created in step 1 5.call the function you created in step 3 with the v...
true
1a07035dcb4f3909b26f5b0aa1d1b4af20192866
CRUZEAAKASH/PyCharmProjects
/section15_Tkinter/TkinterMessageBox.py
340
4.125
4
from tkinter import Tk from tkinter import messagebox window = Tk() messagebox.showinfo("title", "You are seeing message box") response = messagebox.askquestion("Question 1", "Do you love Coffee?") if (response == 'yes'): print("Here are your coffee loverrr!!!!!!!!!!!!!!!!!") else: print("What do you love???"...
true
ef26690eccdd553f9a81cd1b9daa6f5c9e02cb93
chithracmenon/AutomateBoringStuff
/ch7_date_detection.py
1,743
4.71875
5
"""Date Detection Write a regular expression that can detect dates in the DD/MM/YYYY format. Assume that the days range from 01 to 31, the months range from 01 to 12, and the years range from 1000 to 2999. Note that if the day or month is a single digit, it’ll have a leading zero. The regular expression doesn’t have t...
true
4a891d4030805ca7bab9a9b2538d3c2084cd3114
JaneNjeri/python_crash_course
/factorial.py
235
4.3125
4
def factorial(num): if num == 0: return 1 else: return num * factorial(num - 1) print("Please enter a number to recieve its factorial.") num = int(input() ) print (factorial(num)) # good recursion practice
true
ac74ba0fde939786aca05fff2648c368f46db4ef
miaha15/Programming-coursework
/Week 5 Question 1.py
974
4.34375
4
''' Premade list is given to the function A for loop is used to step through the list As it steps through each value of the list, it appends the list called TempList If the current element is GREATER than the next element of the list then it will check if everything stored in the TempList upto current element is longer...
true
9067db5d36f43f7d225c98628272ab067ac8dbd9
yerol89/100_Days_Of_Coding_With_Python
/1. Day_1_Working With Variables to Manage Data/Day1.py
861
4.1875
4
print("Day 1 - String Manipulation") print("String Concatenation is done with the '+' sign.") print("New lines can be created with a backslash.") print("Hello" + " " + "Everyone") print("Hello Python\nHello 100 Days of Coding") print("Hello" + " " + input("What is your name?\n")) name = input("What is your name? ") pri...
true
5e5d664cba8f82e045f025a763a3825d5342b0dd
msausville/ToolBox-Pickling
/counter.py
2,030
4.40625
4
""" A program that stores and updates a counter using a Python pickle file""" from os.path import exists import sys from pickle import dump, load def update_counter(file_name, reset=False): """ Updates a counter stored in the file 'file_name' A new counter will be created and initialized to 1 if none exists...
true
2b47b550001583c7a0f60d8b2022051796d39ad5
utkpython/utkpython.github.io
/session3/simulation.py
733
4.3125
4
# modeling the idea that "students getting ahead in life" # some start off in a higher spot # some have more skill, some less from random import randint import matplotlib.pyplot as plt def rand_walk(numSteps, position, skill): '''Returns a random walk list of size numSteps + 1. position is the starting pos...
true
1ae5d1eb7c5408cedc29486dbe1ee36a2a0df77c
joyvai/Python-
/stopwatch.py
1,615
4.28125
4
# stopwatch.py - A simple stopwatch program. # The stopwatch program will need to use the current time, so you will want to # import the time module. Your program should also print some brief instruc- # tions to the user before calling input() , so the timer can begin after the user # presses enter . Then the code will...
true
7412acf2022c4a9509ddd22859ba8f85422abf57
fobbytommy/Algorithm-Practice
/10_week_2/nth_largest.py
386
4.34375
4
# Given an array, return the Nth-largest element from python_modules import bubble_sort def nth_largest(arr, n): list_length = len(arr) if n <= 0 or list_length < n: return None sorted_arr = arr bubble_sort.bubble_sort(sorted_arr) return sorted_arr[list_length - n] arr = [23, 32, -2 , 6 ,2 ,7, 10, 3, 10, ...
true
8f4667338e761fca8b77a813d4f5ee957e0cbaa0
Akansha0211/Basics-of-try-except-revision
/Basics of try-except.py
1,461
4.1875
4
'''num1=input("Enter the first number \n") num2=input("Enter the second number \n") try: print("the sum of twoi numbers is", int(num1) + int(num2)) except Exception as e: print(e) print("This line is very important")''' #Will never come in except block '''a=[1,2,3] try: print("second element",...
true
8c4d57da1267b058b76250618f25893a4114949f
jonesy212/Sorting
/src/iterative_sorting/iterative_sorting.py
1,277
4.15625
4
# TO-DO: Complete the selection_sort() function below def selection_sort(arr): def selection_sort(arr): for i in range(0, len(arr)-1): cur__index = i smallest_index = cur_index #find the next smallest element q for x in range(cur_index, len(arr)): if arr[x] < arr[small...
true
be344fd136945a81eb038d99bbda7372fdba3c0b
anihakobyan98/group-2
/Exceptions/task4.py
274
4.5
4
''' Number that type is integer and it can be divided to 3 ''' try: a = int(input("Enter a number: ")) except ValueError: print("Entered value must be an integer type") else: if a % 3 != 0: raise TypeError("Number must be divisible to 3") else: print("Excellent")
true
b1119e6cb30d4b4a20dcc6a0f7065150fc080b32
ayushthesmarty/Simple-python-car-game
/main.py
1,336
4.25
4
help_ = """ The are the commands of the game help - show the commands start - start the car stop - stop the car exit - exit the game """ print(help_) running = True car_run = False while running: command = input("Your command: ").lower() if command == "help": print(help_) eli...
true
1ff020d024ad2dd9d2e238125f6ec7402acac880
chanzer/leetcode
/575_distributeCandies.py
1,205
4.625
5
""" Distribute Candies 题目描述: Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these candies equally in number to brother and sister. Return the maximum number of kinds of c...
true
25b3275a82d546d5f17f9232ec4c363e2e85c402
chanzer/leetcode
/867_transpose.py
862
4.21875
4
""" Transpose Matrix 题目描述: Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix. Example 1: Input: [[1,2,3],[4,5,6],[7,8,9]] Output: [[1,4,7],[2,5,8],[3,6,9]] Example 2: Input: [[1,2,3],[4,5,6]]...
true
6d801ce1b4951d9b4b7fa1c7e39aa2d1dd69a1b4
chanzer/leetcode
/697_findShortestSubArray.py
1,269
4.21875
4
""" Degree of an Array 题目描述: Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible length of a (contiguous) subarray of nums, that has the same degree as nums. Example 1: Input: [1, ...
true
4eef3b2411dd7eaa18cd6ceb5224098379d4672c
chanzer/leetcode
/628_maximumProduct.py
669
4.5
4
""" Maximum Product of Three Numbers 题目描述: Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output:6 Example 2: Input: [1,2,3,4] Output:24 Note: 1.The length of the given array will be in range [3,104] and all elements are in the range...
true
0f8c88f4a60a4c9f26553c9903e7d6d111ca8ed1
chanzer/leetcode
/453_minMoves.py
842
4.15625
4
""" Minimum Moves to Equal Array Elements 题目描述: Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1. Example: Input:[1,2,3] Output:3 Explanation:Only three moves are needed (remember each move increm...
true
6947cc6a019c3b232b432788a8ce9ed5729e8551
MichelGeorgesNajarian/randomscripts
/Python/recursive_rename.py
907
4.28125
4
# Python3 code to rename multiple # files in a directory or folder #give root directory as argument when executing program and all the file in root directory and subsequent folders will be renamed #renaming parameter are to remove any '[xyz123]', '(xyz123)' and to replace '_' by ' ' # importing os module import os...
true
0d1564abb38b41d58ce025ee1353e90e62d084be
wrgsRay/playground
/amz_label.py
2,181
4.21875
4
""" Python 3.6 @Author: wrgsRay """ import time class Shipment: def __init__(self, last_page, total_pallet, pallet_list=[], current_pallet): self.last_page = last_page self.total_pallet = total_pallet self.pallet_list = pallet_list self.current_pallet = current_pallet def get_...
true
d603602255347b138dfb7b6685222b2b03501986
SaraKenig/codewars-solutions
/python/7kyu/Unique string characters.py
598
4.34375
4
# In this Kata, you will be given two strings a and b and your task will be to return the characters that are not common in the two strings. # For example: # solve("xyab","xzca") = "ybzc" # --The first string has 'yb' which is not in the second string. # --The second string has 'zc' which is not in the first string. ...
true
acbf417955c0e14618b09ab10a0952fc6e63d79a
SaraKenig/codewars-solutions
/python/7kyu/sort array by last character.py
539
4.34375
4
# Sort array by last character # Write a function sortMe or sort_me to sort a given array or list by last character of elements. # Element can be an integer or a string. # Example: # sortMe(['acvd','bcc']) => ['bcc','acvd'] # The last characters of the strings are d and c. As c comes before d, sorting by last chara...
true
77637b2eaef358ad308de773a915caddab871f12
begogineni/cs-guided-project-python-basics
/src/demonstration_03.py
566
4.40625
4
""" Challenge #3: Create a function that takes a string and returns it as an integer. Examples: - string_int("6") ➞ 6 - string_int("1000") ➞ 1000 - string_int("12") ➞ 12 """ import re def string_int(txt): ''' input: str output: int ''' # Your code here #what to do if there is a letter in the...
true
2bea7f84ca43f1bfde89b3590f7212edf469a5d9
tarushsinha/WireframePrograms
/3fizz5buzz.py
452
4.125
4
## program that returns multiples of 3 as fizz, multiples of 5 as buzz, and multiples of both as fizzbuzz within a range def fizzBuzz(rng): retList = [] for i in range(rng): if i % 3 == 0 and i % 5 == 0: retList.append("fizzbuzz") elif i%3 == 0: retList.append("fizz") ...
true
52f36317552e8eb0e533b61c0f4947b653e7d52d
saikirandulla/HW06
/HW06_ex09_04.py
1,337
4.40625
4
#!/usr/bin/env python # HW06_ex09_04.py # (1) # Write a function named uses_only that takes a word and a string of letters, # and that returns True if the word contains only letters in the list. # - write uses_only # (2) # Can you make a sentence using only the letters acefhlo? Other than "Hoe # alfalfa?" # - writ...
true
31f3c7d5da418e3abbf4c44fced349ab7aac1fab
yotroz/white-blue-belt-modules
/17-exceptions/blue_belt.py
488
4.53125
5
#%% #Create a function that reads through a file #and prints all the lines in uppercase. # # # #be sure to control exceptions that may occur here, #such as the file not existing def print_file_uppercase(filename): try: file = open(filename) for line in file: print(line...
true
147ebca997008e894bd6b5f6f74d63c658643188
Umesh8Joshi/My-Python-Programs
/numbers/PItoNth.py
274
4.21875
4
''' Enter a number to find the value of PI till that digit ''' def nthPI(num): ''' function to return nth digit value of PU :param num: number provided by user :return : PI value till that digit ''' num = input('Enter the digit') return "%.{num}f"(22/7).format(num)
true
d05ea438611f9a1af279a4935c1c966047ae41d5
Chener-Zhang/HighSchoolProject
/Assembly/hw6pr5.py
2,447
4.15625
4
# hw6 problem 5 # # date: # # Hmmm... # # # For cs5gold, this is the Ex. Cr. recursive "Power" (Problem4) # and recursive Fibonacci" (Problem5) program # Here is the starter for gold's Problem4 (recursive power): # This is the recursive factorial from class, to be changed to a recursive _po...
true
f8c33c98dc671fd597a5b40848d72e42f504fbc5
tsakallioglu/Random-Python-Challenges
/Weak_numbers.py
1,324
4.25
4
#We define the weakness of number x as the number of positive integers smaller than x that have more divisors than x. #It follows that the weaker the number, the greater overall weakness it has. For the given integer n, you need to answer two questions: #what is the weakness of the weakest numbers in the range [1, n]? ...
true
71417cb49cb8704d54aa0f6f923e92bd37da5bd9
Niteshyadav0331/Zip-File-Extractor
/main.py
248
4.15625
4
from zipfile import ZipFile file_name = input("Enter the name of file you want to file in .zip: ") with ZipFile(file_name, 'r') as zip: zip.printdir() print('Extracting all the files...') zip.extractall() print("Done!")
true
74d174d8878c2604daf720d755e6b156a6ec4881
netor27/codefights-solutions
/arcade/python/arcade-theCore/07_BookMarket/053_IsTandemRepeat.py
643
4.3125
4
def isTandemRepeat(inputString): ''' Determine whether the given string can be obtained by one concatenation of some string to itself. Example For inputString = "tandemtandem", the output should be isTandemRepeat(inputString) = true; For inputString = "qqq", the output should b...
true
e082ba713c0a0001a3c47dfb5b1e31719534600d
netor27/codefights-solutions
/arcade/python/arcade-theCore/07_BookMarket/054_IsCaseInsensitivePalindrome.py
339
4.1875
4
def isCaseInsensitivePalindrome(inputString): ''' Given a string, check if it can become a palindrome through a case change of some (possibly, none) letters. ''' lowerCase = inputString.lower() return lowerCase == lowerCase[::-1] print(isCaseInsensitivePalindrome("AaBaa")) print(isCaseInsensitiveP...
true
c32f3501b32a4141e575abe2f57b9b8eb712b6e1
netor27/codefights-solutions
/arcade/python/arcade-intro/02_Edge of the Ocean/004_adjacentElementsProduct.py
522
4.15625
4
def adjacentElementsProduct(inputArray): '''Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. ''' n = len(inputArray) if n < 2: raise "inputArray must have at least 2 elements" maxValue = inputArray[0] * inputArray[1] ...
true