blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
18ed0b8e3d5bd288109e1241525f079e569f65aa
my-nguyen/projecteuler.net
/euler_030.py
1,150
4.125
4
fifth_powers = [] # Lower bound: since no single-digit number is a sum (per problem description), # the lower bound is 10 # Upper bound: Suppose we have a 9-digit number. The highest 9-digit number is # 999999999. 9^5 + 9^5 + 9^5 + 9^5 + 9^5 + 9^5 + 9^5 + 9^5 + 9^5 + 9^5, or # (9^5)*9 is 531441, which is only 6 digits...
true
5317a151d0c597a63bb9838007f366a022466230
samruddhiselukar/python-projects
/library_management_system.py
2,762
4.15625
4
# Create a library class # display book # lend book - (who owns the book if not present) # add book # return book # Sam_Library = Library(list_of_books, library_name) # dictionary (books-name_of_person) # create a main function and run an infinite while loop asking # users for their input class Library: def _...
true
c340211b797049e8070ed1579ddc3c8b9702c309
Shresthwalia/CS384_1801EE51
/Assignments/Assignment_1/tutorial01.py
1,851
4.21875
4
# Function to add two numbers def add(num1, num2): addition = num1 + num2 return addition # Function to subtract two numbers def subtract(num1, num2): subtraction = num1 - num2 return subtraction # Function to multiply two numbers def multiply(num1, num2): #Multiplication Logic multiplication =num1*num2 ...
true
6664668a6e9119bc6387950e6385a3ab6fb3f12d
PriyankaDeshpande9/File_Handling
/Python_ASG-9.5.py
623
4.15625
4
'''5. Accept file name and one string from user and return the frequency of that string from file. Input : Demo.txt Marvellous Search “Marvellous” in Demo.txt''' from os import path import os def main(): file = input("Enter the file name : ") Str = input("Enter the string to be searched : ") cnt...
true
5c28b76138d27f99108b7090de1642a9185f9628
DamianAlexanderek/first_steps_in_python
/Codewars/anagram_detection.py
648
4.28125
4
# An anagram is the result of rearranging the letters of a word to produce a new word (see wikipedia). # Note: anagrams are case insensitive # Complete the function to return true if the two arguments given are anagrams of each other; return false otherwise. # Examples # "foefet" is an anagram of "toffee" def is_anagr...
true
30751bd3b7181d998164eb5278fbe8fbe1ade40b
CanisMinor/sortiri
/sortiri/sorting_algorithms/bubble_sort.py
377
4.3125
4
def bubble_sort(sequence): """Perform bubble sort on a sequence of numbers.""" num_entries = len(sequence) for stop_index in reversed(range(num_entries)): for index in range(stop_index): if sequence[index] > sequence[index + 1]: sequence[index], sequence[index + 1] = sequ...
true
4b81acdf9c24171be82187562fe24478cda3c255
paulrodriguez/daily-coding-problem
/problem_44.py
1,752
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
2c2f097ae55f564a90c25e3570e86f246ba9c4b8
paulrodriguez/daily-coding-problem
/problem_36.py
743
4.21875
4
''' Given the root to a binary search tree, find the second largest node in the tree. ''' def find_largest(root): largest = root while largest != None and largest.right != None: largest = largest.right return largest def find_second_largest(root): if root == None: return None if r...
true
50d51a5b401b2d447b7b52a3d7f2b8465628ea13
nseetim/sololearn
/Popsicles.py
970
4.15625
4
''' Popsicles You have a box of popsicles and you want to give them all away to a group of brothers and sisters. If you have enough left in the box to give them each an even amount you should go for it! If not, they will fight over them, and you should eat them yourself later. Task Given the number of siblings that y...
true
7c9fedd48f8301fffc98f7b300d2be3f91a09d62
mantoshkumar1/interview_preparation
/tree/Vertical_order_traversal_Binary_Tree.py
2,836
4.125
4
""" Vertical Order traversal of Binary Tree ------------------------------------------ Given a binary tree, return a 2-D array with vertical order traversal of it. Go through the example and image for more details. Example : Given binary tree: 6 / \ 3 7 / \ \ 2 5 9 returns [ [2], ...
true
0024cf8718621b4b80d30eb0bb7fe4ef19951871
mantoshkumar1/interview_preparation
/tree/zigzag_tree_traversal.py
2,134
4.1875
4
""" https://www.geeksforgeeks.org/zigzag-tree-traversal/ Write a function to print ZigZag order traversal of a binary tree. For the below binary tree the zigzag order traversal will be 1 3 2 7 6 5 4 1 2 3 7 6 5 4 """ class Node: def...
true
6bce7f433fe5ecd9e3b8d2b2d1085bac965fb782
mantoshkumar1/interview_preparation
/arr_str/valid_palindrome.py
1,309
4.15625
4
""" Valid Palindrome: Given a arr_str, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty arr_str as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Out...
true
a2efcd3e4c57b1f414841f751adc1d35cf61942a
Aman020/PythonForEverybody
/Chapter 3/3.1.py
796
4.3125
4
#m 3.1 Write a program to prompt the user for hours and #rate per hour using input to compute gross pay. #Pay the hourly rate for the hours up to 40 and 1.5 times the hourly #rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 #per hour to test the program (the pay should be 498.75). You should #...
true
0b54b12c432c291874e59ec8efd0beaec4e9d3e2
anton-dovnar/HackerRank
/StacksAndQueues/01.py
851
4.25
4
""" Balanced Brackets A bracket is considered to be any one of the following characters: (, ), {, }, [, or ]. Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or }) of the exact same type. There are three types of matche...
true
f428ee9b45db1a585639eb553d78e3194f85445e
nikcbg/Begin-to-Code-with-Python
/8. Storing collections of data/EG8-05 Functions and Menu.py
2,396
4.34375
4
# EG8-05 Functions and Menu #fetch the input functions from BTCInput import * #create an empty sales list sales=[] def read_sales(no_of_sales): ''' Reads in the sales values and stores them in the sales list. no_of_sales gives the number of sales values to store ''' # remove all the previou...
true
0eff0f2e04c3dc724daf4c98f22200f9696985cf
pablobae/Complete-Python-3-Bootcamp-Exercises
/02 - Collatz Conjecture/collatz_conjecture.py
867
4.1875
4
def ask_number(): while True: try: num = int(input("Please, enter a number greater than 1: ")) except ValueError: print("You must enter a number") continue else: if num <= 1: print("You must enter a number greater than 1") ...
true
83159e0c42553b59c8fe5684f23b8cc0de7909e0
chiantansaha/mydevops
/circle_and_lattice_points.py
879
4.3125
4
# Python3 program to find # countLattice podefs on a circle import math # Function to count Lattice # podefs on a circle def countLattice(r): if (r <= 0): return 0 # Initialize result as 4 for (r, 0), (-r. 0), # (0, r) and (0, -r) result = 4 # Check every value tha...
true
4ceea5a08e774a82647d13f3e7509a8f8e9d1036
HV-training/ADS---Basics-Of-Python
/01_datatypes.py
1,248
4.40625
4
# printing in python """ Execute the below code in a cell by cell and see the output. There are Assignments to do it by your own, so complete that as well Use the Spyder to run and execute these .py files """ # String 'Hello World' "Hello World" print("Hello World") # Variables A = "Hello" # Data type - String...
true
cf8aa5bb0cd01ffefcfd8accd1e31c28f7a706e8
HV-training/ADS---Basics-Of-Python
/07_functions.py
1,613
4.25
4
""" Execute the below code in a cell by cell and see the output. There are Assignments to do it by your own, so complete that as well Use Spyder to run and execute these .py files """ def function_name(parameters): statement(s) def say_hi(): print('Hi to Everyone') def greet_everyone(greet): print(gre...
true
ffa98c1984431c2737d7317b88efef88176a4ba7
junekim00/ITP115
/Lab/ITP115_L5_Kim_June.py
2,490
4.15625
4
# June Kim # ITP 115, Fall 2019 # Lab 5 # junek@usc.edu def main(): # default words articles = ["a", "the"] nouns = ["person", "place", "thing"] verbs = ["danced", "ate", "frolicked"] # default enter program keepgoing = True # menu options printed print("\nWelcome to ...
true
7591472ea7a401e4a4c2ec8d85f1979dca434cf6
nyirock/plasmid_2015
/frequent_patterns.py
1,684
4.21875
4
# ^ Matches the beginning of a line # $ Matches the end of a line # . Matches any character # \s Matches whitespace # \S Matches any non-whitespace character # * Repeats a character zero or more times # *? Repeats a character zero or more times (non-greedy) # + Repeats a characater one or more times # +? Repea...
true
7de689ad87f19037542fd9eb0e06f81e56201866
sethshardy/mandelbrot
/Mandelbrot BW zoom 0.py
1,291
4.34375
4
"This code refers to picture #1 in the pdf" import itertools "itertool was used for the product function, allowing us to quickly go through" "many real and imaginary values. This was faster and more efficient than using" "for loops" def f(d,c): a = (d**2) + c return a "I used this function to define the...
true
82f1927c1011a651516ac97b1549208c4ee23fbe
visualne/Python
/exercises/exercise38.py
1,200
4.25
4
cube = lambda x: x**3# complete the lambda function class Fibonacci(): def __init__(self, howMany): self.counter = howMany self.curFib = 0 self.nextFib = 1 def __iter__(self): # # Return an object that exposes an __next__ method. # self (whose type is Fibona...
true
ad72e07e38720de29698a7e41178a9b2421c7657
UWICompSociety/calculator
/main.py
1,405
4.3125
4
__author__ = 'javon' def start(): message = """\nCalculator menu:\n \t1 - Add\n \t2 - Divide\n Chose an option: """ choice = input(message) if choice == 1: #accept numbers and add them here num1 = input("Enter the first number\n") num2 = input("Enter the second number\n") print ("Sum:"+str(num1+num2))...
true
8bf6a8e9d8a4da871db34d743770ee7c46521682
redbassett/CS112-Spring2012
/hw04/sect1_if.py
1,252
4.25
4
#!/usr/bin/env python from hwtools import * print "Section 1: If Statements" print "-----------------------------" # 1. Is n even or odd? n = int(raw_input("Enter a number: ")) if n%2 == 0: nType = "Even" else: nType = "Odd" print "1.",nType # 2. If n is odd, double it # If n is supposed to be changed b...
true
7322738d40625707465d2ff552f61978b768f2d5
redbassett/CS112-Spring2012
/hw12/shapes.py
2,708
4.28125
4
import math import points # Shapes # ========================================================= # # Define a shape object. This object has abstract (empty) # methods for calculating the area and perimeter of the # shape. # # After that, create classes for Rectangles, Squares, # and Circles. # # When done, the cod...
true
47e4285690ab45bebac2e92105d462443e423444
felixs8696/acs_felixs8696
/hw2/hw2.py
773
4.46875
4
import doctest # HailStone Sequence # If n is 1 then the sequence ends. # If n is even then the next n of the sequence = n/2 # If n is odd then the next n of the sequence = (3 * n) + 1 # Create a routine to generate the hailstone sequence for a number. # Use the routine to show that the hailstone sequence for the numb...
true
6841190237b4d443d9e80e2d05dd74089b980682
VinuthnaGummadi/Python
/PhytonProject/Assignment4/Source/OrderedDictionary.py
463
4.15625
4
import collections #Dictionaries doesn't maintain order. print ('Normal dictionary:') dict = {} dict['1'] = 'A' dict['2'] = 'B' dict['3'] = 'C' dict['4'] = 'D' dict['5'] = 'E' for key, value in dict.items(): print (key, value) # Make dictionaries ordered print ('\nOrdered Dictionary:') dict = collections.Ordere...
true
16ac6e5969d58e267ffc2815b787e12a86d10f74
VinuthnaGummadi/Python
/PhytonProject/Assignment1/Source/Lab1/Assignment1/RectanglePerimeter.py
1,007
4.53125
5
# This program displays the perimeter of a rectangle #Take input from user length = input("Enter Length:") breadth = input("Enter Breadth:") perimeter = 0 # Check if entered values are not null if(length!="" and breadth!=""): # Exception if entered value if not int. # This block is executed when the entered num...
true
2bdcd1155b23d5019d8934d2e932f305176f0f7b
Davindza/kilometersintomiles
/km&m.py
451
4.28125
4
print ("Hello!!! This is a program that converts units. More specifically, kilometers into miles") while True: print("Enter a number of kilometers.") km = input("Kilometers: ") km = float(km.replace(",", ".")) miles = km * 0.621371 print("{0} kilometers is {1} miles.".format(km, miles)) ch...
true
2876ef76a59c913ad62f6ef880dccf6048f2a9e8
kendall1978/kendall1978.github.io
/CIS-120/backwards.py
2,088
4.15625
4
#Word Jumble #Kendall Roberts import random words = ('python', 'jumble', 'easy', 'difficult', 'answer', 'xylophone') word = random.choice(words) correct = word jumble = "" jumWord = "" for i in range(10): position = random.randrange(len(word)) jumble += word[position] jumWord = word[:position] + word[(p...
true
3e68f64c93cab3436f7e744680453e8041a21ac1
mmgrayy/python-challenge
/PyBank/main.py
2,925
4.125
4
#importing os and csv in order to read the files import os import csv #create empty lists to store data Month_Total=[] Profit_Total=[] Monthly_Profit_Change=[] #translate path taken in terminal to python csvpath= os.path.join('..','PyBank','Resources','budget_data.csv') #Read the csv file with open(csvpath, 'r') as bud...
true
a84662bab96bb4f81d99c5b9e468018b039a3c8a
J-Cook-jr/python-105-small
/groceries-app.py
1,824
4.53125
5
#This program will create a groceries app that will allow the user to add, update,and remove items. groceries = [] # Create a while loop that will prompt the user until they hit Enter. while True: item = input("What do you need from the store? ") if item == '': break groceries.append(item) # Aft...
true
9e9f3d26a2d8fd9ff48a31e13dcd4dd56e1b0f83
pageza/dojo_Python
/Python_Fundamentals/find_characters.py
716
4.1875
4
#### Find Characters #### # Write a program thats takes a list of strings, a string with a single character to check for # Print a new list with all the words containing the character def findCharacters(list,string): newList = [] # Intializes an empty list for word in list: # Loops through the list we are giv...
true
d346ce67dc276e82c4e3b24dc71909961c6fdc12
VinodhkumarBaskaran/Oops-for-beginner
/inheritance.py
1,105
4.5
4
""" Do you see __init__ method of both class cat and Dog takes similar arguments so instead of writing is twice we can create a class with only __init__ method and argument and reuse it whereever we want it. """ class Pet: # generalised class def __init__(self,name,age): self.na...
true
061d72f2cf7887d22430ccce1ea641361d9d79b0
JyotiSathe/Python
/Assignments/Addition.py
236
4.15625
4
#WAP to accept 2 numbers from user and display their addition num1=input("Enter number 1 to add") num2=input("Enter number 2 to add") num3=num1+num2 print("Addition is ", num3) #print(num3) #print("Addition is {0}".format(num3))
true
a48ad49f664704fb40f8455506f2286a2b62b432
JyotiSathe/Python
/Assignments/getCountOfWordIString.py
857
4.28125
4
#WAP to accept a string and a character or another string #and without using count method count the occurences of second string in first # #Enter String"This is python program, it is getCountIfWordInString Assignment" #Enter String to be checked if present in input string"is" #'is' is present in 'This is python pr...
true
423a46a80ec59697bab132684b56e71823708158
JyotiSathe/Python
/Assignments/Practice Assignments/Script_exercise4.py
833
4.28125
4
class Script: def __init__(self): self.n1=0 self.n2=1 self.n3=0 def factorial_recursion(self,num): if(num==0): return 1 else: fact=num*self.factorial_recursion(num-1) return fact def fibonacci_recursion(self,num): if(num>0): self.n3=self.n2+se...
true
6fea4b7f52e8fc438f019435a5d0be4ec80b2fa7
JyotiSathe/Python
/Assignments/Class Assignments/right_rotation.py
1,001
4.3125
4
#WAP to accept 2 substring from user and check if second string is right rotate of first #eg.str1=India #eg.str2=iaInd def main(): input_str1=input("Enter first string") input_str2=input("Enter second string") new_str=input_str1+input_str1 if(len(input_str2)!=len(input_str1)): print("not...
true
ed3c85afc75d8784cc9083ed823379b68cf576ec
JyotiSathe/Python
/Assignments/removeTypicalFilesFromDirectory.py
714
4.28125
4
#WAP to accpet directory path from user and type of files to be deleted #recursively from the given directory import os def removeFiles(arg,directory,files): count=0 print("In directory "+directory) for file1 in files: if file1.endswith(arg): count+=1 print ("remov...
true
992a420aed1400c06be97327340fa09c641b2564
JyotiSathe/Python
/Assignments/alternate_letter_in_string.py
321
4.25
4
#WAP to accpet a string from user and print alternate characters in it starting with first character def alternate_letter(input_str): return input_str[0::2] def main(): input_str=input("Enter String") output_str=alternate_letter(input_str) print(output_str) if __name__=='__main__': main() ...
true
d818a6b8b3650e9a1a9b5f60bf665ba9742f10f6
manojakumarpanda/This-is-first
/fundamental/float foramat .py
810
4.21875
4
r=float(input("Enter the radious of the circle :")) pi=3.147 area=pi*r**2 print('The result of the area of the circle is up to two precession:{:08.2f}'.format(area)) #we cant give any other value then space and 0 to the fill character #this is to give the alignment to the result or the area print('the result of the ar...
true
1698b0f5c240d30205419294ae8c028a02afb7f7
manojakumarpanda/This-is-first
/functions/simple global local nonlocal.py
1,333
4.25
4
#simple program to the local global and nonlocal glob=100#these ara the global variable gl=200 def function(): print('The global variable in this function is:',glob,gl) def outer_function(): glob=10#This is local to the outer function but act as the globl to the inner functions gl=20 pr...
true
9627bddf456111b6619c6ab7351dfb3e103f1371
manojakumarpanda/This-is-first
/sequence/reversing the content of the word.py
721
4.375
4
#program for the the reversal of the order of the word string='pyhton is a programming language' st=string.split(' ') inter=[] for ch in st: inter.append(ch[::-1]) output=' '.join(inter) print('the output of the string "{}" and after the conversion of the string is ::'.format(string),output) print("*"*50) #p...
true
82e27be213130a5d8dad7baa65fb781bd896f3cd
amos1994/python_games
/guessthenumber.py
2,897
4.28125
4
# "Guess the number" mini-project # Angel Inokon # 10.26.12 # input will come from buttons and an input field # all output for the game will be printed in the console # initialize global variables used in your code import math import random import simplegui secret_number = 0 user_guess = 0 low = 0 ...
true
c93e0d0d3c2cedfa18aae578b2ae3fdc42585304
huynhkGW/POTD
/Python/logic-1/date_fashion.py
1,653
4.1875
4
''' CodingBat Python Activity "date_fashion" from logic-1. codingbat.com ''' failures = 0 def date_fashion(you, date): ''' You and your date are trying to get a table at a restaurant. The parameter "you" is the stylishness of your clothes, in the range 0..10, and "date" is the stylishness of your date's clothes. ...
true
524fc83f1d5c329197716f6011291083e2648331
jocate/Intro-Python-I
/src/14_cal.py
1,986
4.5625
5
""" The Python standard library's 'calendar' module allows you to render a calendar to your terminal. https://docs.python.org/3.6/library/calendar.html Write a program that accepts user input of the form `14_cal.py month [year]` and does the following: - If the user doesn't specify any input, your program should ...
true
77b0fb3c1eae6f276d0395a9843771773b9e7a11
datasci-csm/pythonpractice
/reversed_string.py
490
4.59375
5
# create a function to reverse the word order of a string my_string = "Today is a sunny day and wonderfully blue sky" def reverse_word_order(my_string): reversed_string = "" list_of_words = my_string.split() list_of_words.reverse() reversed_string = " ".join(list_of_words) return reversed_string...
true
e2dd8830e6535757c11a0bb7adf549640fc5955c
mahfoudha091/python_lab1
/4.py
313
4.40625
4
""" Write a Python program which accepts the radius of a circle from the user and compute the area. Sample Output : r = 1.1 Area = 3.8013271108436504 """ from math import pi radius = float(input(" input radius of the circle > ")) area = pi * radius**2 print(f"area of circle with radius {radius} is = {area}")
true
d8125d49d199a49e7baeadaf63ca1d93410584f7
deepbsd/OST_Python
/ostPython1/input_counter.py
1,367
4.1875
4
#!/usr/bin/env python3 # # # input_counter.py # # Lesson 6: Sets and Dicts # # by David S. Jackson # 11/29/2014 # # OST Python1: Beginning Python # for Pat Barton, Instructor # """ This program gets user input (a sentence of some kind) and parses the words into a list of words, and then l...
true
a2da06f433b835b4fb53bd0de38b00adb4dd0ad6
deepbsd/OST_Python
/ostPython4/generatorspeed.py
1,017
4.5
4
#!/usr/bin/env python3 # # # arr.py # # Lesson 8: Advanced Generators # # by David S. Jackson # 8/3/2015 # # OST Python4: Advanced Python # for Pat Barton, Instructor # """ Project: Write a program that uses timeit() to show the difference between a list comprehension and the...
true
60ae895293a4bb0a9502ebfb74f1c79fbb14aa09
deepbsd/OST_Python
/ostPython3/test_adder.py
1,387
4.21875
4
#!/usr/bin/env python3 # # # test_adder.py # # Lesson 1: User Input # # by David S. Jackson # 4/21/15 # # OST Python3: The Python Environment # for Kirby Urner, Instructor # """ test_adder.py checks to see whether adder.add2() both rejects bad user input and accepts good user input, and th...
true
e0de8da9b4d0e665fb5da01e607585280b609e5f
deepbsd/OST_Python
/ostPython1/backups/greeting.py~
524
4.15625
4
#!/usr/bin/env python3 # # # greeting.py # # Lesson 2: Entering and Storing Data # # by David S. Jackson 11/25/2014 # # OST Python1: Beginning Python for Pat Barton, Instructor # """ greeting.py: Takes a first and last name and spits out a string concatenating both inputs. """ first = input("W...
true
604faf61fa856c0e5552a28110c68bffb4bcff3d
deepbsd/OST_Python
/ostPython1/caser.py
2,288
4.46875
4
#!/usr/bin/env python3 # # # caser.py # # Lesson 13: More About # Functions # # by David S. Jackson # 12/6/2014 # # OST Python1: Beginning Python # for Pat Barton, Instructor # """ Modifies the case of inputted text. User selects from a menu capitalize: accepts string...
true
569be5c02fb84050497f02f89c97bd8a6380a439
deepbsd/OST_Python
/ostPython1/backups/check_string.py~
1,201
4.3125
4
#!/usr/bin/env python3 # # # check_string.py # # Lesson 3: Making Decisions: # The if Statement # # by David S. Jackson # 11/25/2014 # # OST Python1: Beginning Python # for Pat Barton, Instructor # """ Program asks for user input in UPPER CASE STRING ending with a "." Then t...
true
70e7643a41dc051a8414156605e81bf71d73a25b
cesartorresr/day-3-3-exercise
/main.py
402
4.3125
4
# 🚨 Don't change the code below 👇 year = int(input("Which year do you want to check? ")) # 🚨 Don't change the code above 👆 #Write your code below this line 👇 leap = "The year is leap" not_leap = "The year is not leap" if year % 4 == 0: if year % 100 != 0: print(leap) else: print(not_leap) if year % 100 ==...
true
7b2acff01a739a84495a1d28c2cc1cdc023a9c6f
amjayy/Customer_SQLite_versions
/version_1.py
941
4.28125
4
import sqlite3 db_conn = sqlite3.connect('customer.db') c = db_conn.cursor() db_conn.execute("CREATE TABLE IF NOT EXISTS Customer2 (Fname VARCHAR(15),Lname VARCHAR(15), Email ,Points INT(2));") db_conn.commit() #def enter_store(): #print("Welcome to KSE mart.") #answer = input("Are you a return...
true
ed8c8ab47590d5e90fc92e8ac0efeeba5d52b696
mingrui/codinginterview
/InterviewCake/3_highest_product_of_three.py
2,250
4.4375
4
# special cases: # 0 is one of the 3 numbers # even number of negative numbers # can't simply find the highest 3 numbers # 2 negative numbers product can be higher than 2 positive numbers # find highest 3 positive numbers, including 0 # find lowest 2 negative numbers, take the product # if lower 2 of 3 positive number...
true
0ecab6f75ba5acc2a425b14cb018937233a24c82
Vixus/LeetCode
/PythonCode/Monthly_Coding_Challenge/Aug2020/Non_Overlapping_Intervals.py
1,403
4.3125
4
from typing import List import sys """ Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Example 1: Input: [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation: [1,3] can be removed and the rest of intervals are non-overlapping. Exam...
true
88095a95e4b02ab82509c06be92fd833fdaed09c
Tubesocrates/LPHW
/21-30/ex_24.py
1,178
4.125
4
print("Let's practice everything.") print('You\'d need to know \'bout escapes with \\ that do:') print('\n newlines and \t tabs.') poem = """ \tThe lovely worls with logic so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires an explanation \n\t where there is none. "...
true
cf76f5734c0d50964047f6c7e2e78782f3846fca
Tubesocrates/LPHW
/11-20/ex_14.py
1,323
4.53125
5
# Excercise 14: Prompting and Passing # Lets use argv and input together to ask the user something specific. # you will need this for the next exercise where you learn to read and # write files. # were going to use input to print a simple prompt. from sys import argv script, user_name, adjective = argv...
true
d815195defc74fe3f0a8f576459143a3286ef3da
SamuelGYX/leetcode_records
/souce/264 Ugly Number II.py
1,155
4.125
4
''' Overview: Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Solution: > An ugly number must be multiplied by either 2, 3, or 5 from a smaller ugly number. Starting from the first ugly number 1, every ugly number U could be...
true
d4e20ef8226b0793bf862be962caab4b2054ff9c
SamuelGYX/leetcode_records
/souce/451 Sort Characters By Frequency.py
293
4.125
4
''' Overview: Given a string, sort it in decreasing order based on the frequency of characters. Solution: Use Counter function in Python. ''' class Solution: def frequencySort(self, s: str) -> str: return ''.join(key * val for key,val in collections.Counter(s).most_common())
true
02caacfcba3cb9f6f394888cc54ab95ac7eb77d4
iamrobinhood12345/extra_katas2
/src/flight_paths/flight_paths.py
2,561
4.21875
4
"""Return the shortest flight path between two cities.""" from weighted_graph import Graph import json import sys AIRPORTS = "cities_with_airports.json" def calculate_distance(point1, point2): """ Calculate distance between two points. Calculate the distance (in miles) between point1 and point2. p...
true
87483d838d7508d0ac1720205dbd81bb78ce4e12
Prince-linux/python_for_everyone
/ch04/P4.22/draw.py
817
4.1875
4
#Question: P4.22: Write a program that reads an integer and displays, #using asterisks, a filled diamond of the given side length. # For example, if the side length is 4, the program should display # * # *** # ***** # ******* # ***** # *** # * #Author: Prince Oppong Boamah<regiot...
true
c3b4574333ecf3d77bde473f52c3a8b5dbdd8902
Prince-linux/python_for_everyone
/ch02/P2.4/calc.py
1,302
4.21875
4
#Qusetion: P2.4: Write a program that prompts the user for two integers and then prints # • The sum # • The difference # • The product # • The average # • The distance (absolute value of the difference) # • The maximum (the larger of the two) # • The minimum (the smaller of the two) # Hint: Pyth...
true
acb63fc7f3a26ab0eac4627367a952be83b6211b
Prince-linux/python_for_everyone
/ch02/P2.11/car_mile.py
813
4.3125
4
#Question: P2.11: Write a program that asks the user to input # •The number of gallons of gas in the tank # •The fuel efficiency in miles per gallon # •The price of gas per gallon # Then print the cost per 100 miles and how far the car can go with the gas in the tank. #Author: Prince Oppong Boamah<regioths...
true
61e1fe075a330dad748eced5018d6b7ffb4641a8
ksjpswaroop/python_primer
/ch_1/formulas_shapes.py
605
4.1875
4
# Exercise 1.8 from math import pi h = 5.0 # height b = 2.0 # base r = 1.5 # radius area_parallelogram = h * b print 'The area of the parallelogram is %.3f' % area_parallelogram area_square = b ** 2 print 'The area of the square is %g' % area_square area_circle = pi * r ** 2 print 'The area of the circle is %.f'...
true
1272bfd1e7b6f1d7a4938da94948f63648e5fa2e
bhoomi2611/basic-python
/22_find duplicate in array.py
345
4.28125
4
# Program to find duplicate elements in an String array. arr=[] count=0 n=int(input("length of array:")) for j in range(0,n): m=input() arr.append(m) for i in range(0,n): for j in range(i+1,n/2): if(arr[j]==arr[i]): print("duplicate term",arr[i]) count=count+1 print(count) ...
true
9da093453d072946069338fb3272dbf516ea4051
bhoomi2611/basic-python
/49_anagrams.py
437
4.28125
4
# Check if two String is an anagram of each other. # (Ananagram of a string is another string that contains the same characters, # only the order of characters can be different. For example, “abcd” and “dabc” are ananagram of each other. def check(s1, s2): if(sorted(s1)== sorted(s2)): print("Yes") else...
true
1cd20c1ac48b0ad7763d3584a3e5edfa0a77caad
vogtdale/python
/python-exercises/reversewWordOreder.py
302
4.25
4
# Exercise 14 # Write a function that asks the user for a string containing multiple words. Print # back to the user the same string, except with the words in backwards order. a = str(input("Enter a sentence: ")) def split_word(x): y = x.split() return " ".join(y[::-1]) print(split_word(a))
true
b41f642dd6118142c8936c4c1b480e08d5d83fed
vogtdale/python
/learnpython/collections/binary/preOrderTree.py
1,851
4.28125
4
''' Pre-Order Traversal 1. check if the current node is empty 2. Diplay the data part of the root or current node 3. Traverse the left subtree by recursively calling the pre-order function 4. Traverse the right subtree by recursively calling the pre-order function A / \ ...
true
33238585716da38fcb9ba8b7c5be8fa17625318a
vogtdale/python
/learnpython/collections/matrix.py
566
4.1875
4
''' Matrix is a special case of two dimensional array where each data element is of strictly same size. So every matrix is also a two dimensional array but not vice versa. ''' from numpy import * a = array([['Mon',18,20,22,17],['Tue',11,18,21,18], ['Wed',15,21,20,19],['Thu',11,20,22,21], ['Fri',18,17,23,2...
true
1349e5330773753e61eba127362015d9ca462292
vogtdale/python
/learnpython/variables/strings.py
427
4.125
4
# Looping Through a String for x in "banana": print(x) # Get the String Length a = "coconut" print (len(a)) # Check String if character is present txt = "The best things in life are free!" print("free" in txt) # slicing b = "Hello, World ! " print(b[2:]) # uppercase print(b.upper()) #lowercase print(b.lowe...
true
e5cc1e51318c4b49640595dacf9824d0144b9058
piyushabharambe/undochanges
/primewhile.py
383
4.25
4
# prime or not with while loop while(True): num=int(input("Enter the number which you want to check=")) f=0 i=2 if(num>1): while i<=num/2: if(num%i==0): print("{} is not a prime number!".format(num)) break i=i+1 else: print("{} is a prime number!".format(...
true
b61196fae7f5e102a33e46d5717f6b99fedb6dc5
NallaLokeshReddy/Python_DataStructures
/Week 1/Asign1.py
729
4.34375
4
#6.5 Write code using find() and string slicing (see section 6.10) to extract the number at the end of the line below. Convert the extracted value to a floating point number and print it out. # text = "X-DSPAM-Confidence: 0.8475"; text = "X-DSPAM-Confidence: 0.8475" Colpos = text.find(':') # Colon Po...
true
bea8715aeecada98581d050e1f080f34249472a4
green-fox-academy/FarkasLaszlo
/week-02/day-04/05 substring in list.py
587
4.25
4
#Create a function that takes a string and a list of string as a parameter #Returns the index of the string in the list where the first string is part of #Returns -1 if the string is not part any of the strings in the list #Example #input: 'ching', ['this', 'is', 'what', 'I'm', 'searching', 'in'] #output: 4 input_stri...
true
0c4627cd45406ea3ca49eb6001d7c43d17be2b2c
green-fox-academy/FarkasLaszlo
/week-02/day-01/Exercise16.py
333
4.25
4
# Write a program that asks for two integers # The first represents the number of chickens the farmer has # The seconf represents the number of pigs the farmer has # It should print how many legs all the animals have a = input('Chicken: ') b = input('Pigs: ') legs = int(a) * 2 + int(b) * 4 print('The number of legs: ' ...
true
4c452918795f4c70da9d1f0f163eb49ab9a07b6a
green-fox-academy/FarkasLaszlo
/week-02/day-02/06 Print Arguments.py
216
4.125
4
# - Create a function called `printer` # which prints the input parameters # (can have multiple number of arguments) def printer(*argv): for arg in argv: print(arg) a = 100 printer(a, 'b', 2.5, 'd')
true
01ff115dd493bf8b0b4345cc6d900ad20ddc0ec1
code-in-the-schools/pong_contract_Jayla
/main.py
1,142
4.15625
4
import pygame import random # Define colors PINK = (0, 0, 0) BLUE = (255, 255, 255) SCREEN_WIDTH = 700 SCREEN_HEIGHT = 500 BALL_SIZE = 25 class Ball: """ Class to keep track of a ball's location and vector. """ def __init__(self): self.x = 0 self.y = 0 self.change_x = 0 ...
true
99fa6e0f8c1dd787d15147175b6cb778923abba1
andrewghaddad/OOP
/OOP/Notes/Week5/number_guessing_game.py
894
4.28125
4
# Generate a random integer in the range [1,10] # Ask the user to guess the number until they guess correctly import random play = "" while play != "no": lower_bound = 1 upper_bound = 10 secret_number = random.randint(lower_bound, upper_bound) guess = 0 while True: guess = int(input("Please...
true
c91b02890b212e055b0aec9b42bff03af693a0a0
andrewghaddad/OOP
/OOP/Notes/Week12/oop.py
1,963
4.375
4
# Introduction to Object Oriented Programming (OOP) # Classes, Properties, Instances # Constructors # Instance Methods # OOP is a design paradigm that lets us "tightly couple" data elements together # in order to better organize our code to solve more complicated problems class Student(): # description of o...
true
4d9c420f7cbe3db9c02a29d78899f7ed4e07dfe3
andrewghaddad/OOP
/OOP/Notes/Week11/invert.py
1,133
4.46875
4
""" Write a function that takes in a dictionary of strings to integers invert the dictionary you should return a new dictionary, where the old values are now keys and the old keys are now values in the new dictionary Be careful, the keys in a dictionary are unique, but the values may not be, so we use a list of value...
true
91160f060b32bd06b579f0885880ec93fe7c041b
andrewghaddad/OOP
/OOP/Notes/Week8/pig_latin_translator.py
707
4.40625
4
# PC: Pig Latin Translator """ Write a program that asks the user for a word Translate the word into Pig Latin Pig Latin can be generated using the following rules: - remove the first letter of the word - place the first letter at the end of the word - add the string "ay" to the end of the word pig_latin_t...
true
2753d977b6c3691a0bc2842e283b5d0f4b9206fb
andrewghaddad/OOP
/OOP/Notes/Week4/number_guessing_game.py
640
4.125
4
""" Pick a secret number between 1 and 10 (hard code to be 7) Input: ask the user to enter a number between 1 and 10 Processing: if the user is correct: print congratulations if the user's guess is too low: print appropriate message if the user's guess is too high: print appropri...
true
194826c18187113ef1ef1250bd5296d8dacea218
andrewghaddad/OOP
/OOP/Final_Review/q2.py
942
4.25
4
def stocks(stockPrices): # method to print highest and lowest stock prices prices = stockPrices.split(',') # convert each price to an integer prices = list(map(int, prices)) # initialize the max and min prices max_price = 0 min_price = 100000000000000 ind_min, ind_max = 0, 0 # iter...
true
259710a4a2284d14b950f8fceff99d94fe0f00fc
hiranyakudva/Python-Practice
/Palindrome.py
290
4.375
4
# An example of using recursion to check whether a word is a palindrome. def isPal(x): ''' x: string with no spaces and puncuation marks returns whether x is a palindrome ''' x=x.lower() if len(x)<=1: return True else: return (x[0]==x[-1]) and (isPal(x[1:-1]))
true
60e4c80fbbfb082ce5cced38f98d6181703c4e42
Nomi-Sheslow/cp1404practicals
/prac_02/files.py
1,789
4.21875
4
""" 1) Write code that asks the user for their name, then opens a file called "name.txt" and writes that name to it. """ name = "name.txt" out_file = open(name, 'w') name = input("What is your name? ") out_file.write(name) out_file.close() """ 2) Write code that opens "name.txt" and reads the name (as above) then prin...
true
967c0bfacf163b21e0ce1e2d5d6a2c8e1c424572
minhvu0405/practice
/hash/colorful.py
728
4.15625
4
# For Given Number N find if its COLORFUL number or not # Return 0/1 # A number can be broken into different contiguous sub-subsequence parts. # Suppose, a number 3245 can be broken into parts like 3 2 4 5 32 24 45 324 245. # And this number is a COLORFUL number, since product of every digit of a contiguous subsequen...
true
454c98684d5ddbbcfd3741d8ee4a6ffd03858771
AmanChaudhary1998/python_training
/Module_4/flatten_matrix_nested_list_comprehension.py
362
4.15625
4
# Suppose I want to flatten a given 2-D list: matrix = [[1,2,3],[4,5,6],[7,8,9]] flatten_matrix = [] for sublist in matrix: for val in sublist: flatten_matrix.append(val) print(flatten_matrix) # Nested List Comprehensive to flatten a given 2-D matrix flatten_matrix = [val for sublist in matrix fo...
true
fb9b77357415e4f3c18c42d49543bb5de26571b9
ishanisri/Competitive_Programming
/Python/largest_element.py
530
4.15625
4
""" Given an array, find the largest element in it. Input: The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n , the no of elements in the array. Then next line contains n integers of the array. Output: Print the maximum eleme...
true
d69749908ba2c707039bc5d6590b7f195197b59b
jianchengwang/todo-python
/pyworkshop/1_intro_python/chapter4/mutability_exercise.py
468
4.1875
4
# Lists are mutable my_list = [1, 2, 3] my_list[0] = 'a' my_list # Dictionaries are also mutable my_dict = {"hello": "world"} my_dict["foo"] = "bar" my_dict # Sets are mutable, but don't support # indexing or item assignment, # so you have to use add() and remove() my_set = {1, 2, 3} my_set[0] = 'a' # T...
true
9779165f61ae30497fdbf98ecdf2615ab580d3ac
leslem/learning
/books/intro-ml-with-python/ch01.py
2,607
4.25
4
# # Chapter 1 exercises from *Introduction to Machine Learning with Python* by Müller and Guido # Exploring the basics of how scikit-learn works. # + import matplotlib.pyplot as plt import mglearn import numpy as np import pandas as pd from sklearn.datasets import load_iris from sklearn import model_selection from sk...
true
5dfe35b24424efbf8517d9d56789a6e4f7e800f3
abdulrafikal-hassan/completePythonCourse_ZTM
/dic.py
891
4.28125
4
#Dictionary can be called object,map or array #dict is a way to organise your data, is an ordered key value pair dictionary = { 'a': 1, 'b': 2, 'c': 3, 'd': [1,2,3,4,5] } my_list = [ { 'a': [1,2,3], 'b': 'hello', 'x': True }, { 'a': [4,5,6],...
true
da240909484723f55bf47392ba9ece22ce44853c
MoraaS/BMI
/Bmi.py
741
4.5
4
#BMI Calculator name1 = "Brian" height_m1 = 2 weight_kg1 = 80 name2 = "Moo" height_m2 = 1.5 weight_kg2 = 70 name3 = "Kevo" height_m3 = 1.8 weight_kg3 = 150 #to calculate the BMI of the three people a function is created def bmi_calculator (name, height_m, weight_kg): bmi = weight_kg / (height_m ** 2) print("...
true
976b169465bd5b61fe240b99e1d99794e6dc9c2d
kennyjijet/Python_Practice
/Binary_Search.py
2,408
4.1875
4
from bisect import bisect_left def binarySearchRecursive (arr, l, r, x): # Check base case if r >= l: mid = l + (r - l)/2 # If element is present at the middle itself if arr[mid] == x: return mid # If element is smaller ...
true
d7d2b0561be0121e325f721ee401e1e5ac170e94
StRobertCHSCS/fabroa-Ian132496
/Working/LiveHacks/LiveHack1/Practice1.py
496
4.25
4
''' ------------------------------------------------------------------------------- Name: Practice1.py Purpose: Finding Celsius from Fahrenheit Author: Cho.S Created: date in 01/10/2019 ------------------------------------------------------------------------------ # get fahrenheit from user fahrenheit = float(in...
true
664a47fdb17439430d7c7cf15c68a990fd6d18da
Ermin26/SmartNinja_HomeWork_Py
/fizzBuzz.py
721
4.21875
4
import time print(" Hello there.") time.sleep(1) print("Please enter the number and program will count to that number. Numbers divisible by 3 will write fizz, for numbers divisible by 5 will write buzz.") time.sleep(5) print("What will write for numbers divisible by 3 and 5?? Try an...
true
0b2540650e66c820d0f25884c85ea3d510960326
jmschp/mosh-complete-python-course
/09 Python Standard Library/08 Working with a SQLite Database.py
1,834
4.53125
5
# 08 Working with a SQLite Database import sqlite3 import json from pathlib import Path # We are going to read all the movies from the JSON file from the last leson and store then in a data base movies = json.loads(Path(r"09 Python Standard Library\movies.json").read_text()) #with sqlite3.connect(r"09 Python Standa...
true
62cb834273f57836748e9c368a875f2fe9a4fb89
jmschp/mosh-complete-python-course
/05 Data Structures/04 Looping over Lists.py
365
4.40625
4
# 04 Looping over Lists letters = ["a", "b", "c", "d"] for letter in letters: print(letter) # to get the index of each item use the built in function enumerate() for letter in enumerate(letters): print(letter) # we get a Tuple with two item the first the index , second the item it self for index, letter in ...
true