blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
903f9d4a703e3f625da5f13f6fe084e8894d723b
SymmetricChaos/NumberTheory
/Polynomials/PolynomialIntegerTypeUtils.py
1,843
4.28125
4
def poly_print_simple(poly,pretty=False): """Show the polynomial in descending form as it would be written""" # Get the degree of the polynomial in case it is in non-normal form d = poly.degree() if d == -1: return f"0" out = "" # Step through the ascending list of co...
true
083dcb1dfcad83b453ed7bc8b7fc9eb4f3d61b4d
SymmetricChaos/NumberTheory
/Sequences/Representations.py
1,839
4.125
4
# For alternate representations, generally as strings from Sequences.Simple import naturals from Sequences.MathUtils import int_to_roman, int_to_name def roman_numerals_str(): """ The positive integers as standard Roman Numerals, returns strings """ for n in naturals(1): yield int_to_roma...
true
3007394485bc0fb025ce002bb5a20fff99ebbfa5
SymmetricChaos/NumberTheory
/Examples/FermatFactorizationExample.py
935
4.375
4
from Computation.RootFinding import int_root, is_square print("Fermat's method for factorization relies on the difference squares.") print("\na^2 - b^2 = (a+b)(a-b)") print("\nThis means that any number which can be written as the difference of two squares must have a+b and a-b as factors.") a = 17 b = 6 p = (a+b)*(a...
true
872833bd837287b5c36a446ae1029f0244a383d0
miloszfoksinski/EXERCISES_PRACTISEPYTHON
/EXERCISE_11.py
320
4.21875
4
"""Ask the user for a number and determine whether the number is prime or not.""" x = int(input('Write Your number to check whether it is prime or not: ')) count = 0 for a in range (1,x+1): if x%a == 0: count +=1 if count > 2 : print('Your number ',x,' is not prime') else: print('Your number ',x,' is prime')
true
fc3b8a2eee36062324c6f0bf7176a9425c69bf4e
sforrester23/SlitherIntoPython
/chapter7/Question3.py
930
4.15625
4
# Write a program that takes a string as input from the user. # The string will consist of digits and your program should print out the first repdigit. # A repdigit is a number where all digits in the number are the same. # Examples of repdigits are 22, 77, 2222, 99999, 444444 # Building upon the previous exercise, # ...
true
7b3c25989bd57a5f918b5d8fed972f6ff28bc1ec
DevXerxes/Python-Projects
/InheritanceAssignment.py
931
4.40625
4
# Here im defining a parent class with its properties and using a printname method. class Bikes: #function to give structure to objects in the class Bikes def __init__(self, type_of, color): self.type_of = type_of self.color = color #function for defining structure of the printname m...
true
1124a57ea03b0131c2704274666f39061e05eff7
Deepakvm18/luminardeepak
/language fundamentals/highestof3.py
466
4.25
4
num1=int(input("enter the first number")) num2=int(input("enter the second number")) num3=int(input("enter the third number")) if(num1>num2): print("first number is greater than second") if(num1>num2): print("num1 is greatest of three numbers") else: print("num3 is greatest of three numbers"...
true
e997e5aba7d5a5f546b4a6d94fa9e3336edc0a65
CodevilJumper/CodeWars
/YourOrder Code Wars.py
1,241
4.15625
4
# Your order, please # # INSTRUCTIONS # # Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result. # # Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). # # If the input string is empty, return...
true
4987c269bbe20c3b6b273adba26055ecfdbd1ce5
peazybabz/Python-Tutorials-for-beginners
/prg10.py
254
4.125
4
#10. Python Program to Check if a Number is Positive, Negative or 0 num = float(input("Input a number: ")) if num > 0: print("The number ",num,"is a positve number") elif num == 0: print(num,"is Zero") else: print("It is a negative number")
true
552e867ddb90a4311b7336b879bd83581bae359a
peazybabz/Python-Tutorials-for-beginners
/prg8.py
329
4.5
4
#8. Python Program to Convert Kilometres to Miles #input provided by program # kilometers = 5.3 #input from user kilometers = float(input("Enter value in kilometers:")) #conversion factor conv_fac = 0.621371 #calculate miles miles = kilometers * conv_fac print("%0.2f kilometers is equal to %0.2f miles"%(kilometers...
true
e8c56deedf0d6f71ac46b26e9952ed8f49228cbb
titus-ong/chordparser
/src/chordparser/music/roman.py
2,533
4.25
4
class Roman: """A class representing Roman numeral notation. The `Roman` is composed of its `root`, `quality` and `inversion`. When printed, the standard Roman numeral notation is displayed. Parameters ---------- root : str The scale degree of the `Roman`. Uppercase if major/augmented and ...
true
c69ad85e21e632dbecfaaeb0aad6e6a04b43c47c
noodlexpoodle/PY
/Maps.py
684
4.15625
4
from random import shuffle def jumble(word): #anagram is a list of the characters anagram = list(word) shuffle(anagram) #shuffle the list return ''.join(anagram) #words = ['apple','pear','melon'] words = [] i = 1 while i == 1: word = input('Enter word. Type "Done" to stop ') if word.lower() != ...
true
87b0708072b055a340b48c4588199b94512f333b
mbrown2330/tip_calculator2
/tip_calculator2.py
1,302
4.46875
4
# Make a python script tip_calculator.py that takes a user's input at the command line for: # Cost of the food # Number of people splitting the bill # Percentage of the tip # Hint: you might want to use the input() function for taking user input # Then, the script should output: # The total bill (including tip) # ...
true
93c810befaea331717e552e66a366ccdb4dfdf22
steveSuave/practicing-problem-solving
/code-wars/expanded-form.py
566
4.34375
4
##Write Number in Expanded Form ## ##You will be given a number and you will need to return ##it as a string in Expanded Form. For example: ## ##expanded_form(12) # Should return '10 + 2' ##expanded_form(42) # Should return '40 + 2' ##expanded_form(70304) # Should return '70000 + 300 + 4' ## ##NOTE: All numbers will be...
true
07320850bf2c94779f0ce375fbc78a0f1022d09f
Aegis-Liang/Python3_Mac
/Data Structures & Algorithms/Part01/L03_PythonFunctions.py
247
4.125
4
# Example function 1: return the sum of two numbers. def sum(a, b): return a+b # Example function 2: return the size of list, and modify the list to now be sorted. def list_sort(my_list): my_list.sort() return len(my_list), my_list
true
5ce751ddd79daaa9a22728fab5c2ac64411158a8
colioportfolio/final491edited
/main.py
1,630
4.125
4
from bike import Bike from fordPinto import Car from parts import Vehicle checker = 0 checker2 = 0 checker3 = 0 def wrong_bike(): print("Sorry! That currently is not a bike option") while checker == 0: user = input("Hi there! is this Wayne or Garth? ") if user in ["Garth", "garth", "GARTH"]: bik...
true
c51630f8c80dd17412816ad617555820a3ad498e
bogataurus/Temperature-Select
/temperature_select.py
1,118
4.15625
4
radiators_list = ["kitchen","livingRoom","diningRoom","bathroom","bedroom1","bedroom2", "bedroom3"] temperatur_list = [15, 18, 22, 26, 30, 35, 40, 45] heating_radiator = "" temperature = "" while True: radiator_select = input ( "Select radiator at list: kitchen, livingRoom , diningRoom , bathroom , bedroom1 , b...
true
7982ede29a971bf120c1cf2557348d34e30fb8e6
ShelMX/gb_algorithm_hw
/lesson_7/hw_07.py
1,858
4.40625
4
__author__ = 'Шелест Леонид Викторович' """ Module with the functions that are used in each homework. """ import random as rnd def generate_int_array(low: int = -100, up: int = 99, size: int = 100) -> list: """ function generate list of random numbers (int type). :param low: type int, lower bound of rando...
true
a14cf45fffea00d2e3309b9851c4e84bad081006
NathanDDarmawan/AP-programming-exercises-session-10
/4.py
313
4.15625
4
def calc_new_height(): m = int(input("Enter the current width: ")) n = int(input("Enter the current height: ")) z = int(input("Enter the desired width: ")) ratio = n/m new_height = z*ratio print("The corresponding height is:", new_height) return new_height calc_new_height()
true
cc14e6627e6e867e30021c0dfe9bb1c2b6e01ca0
Darrenrodricks/PythonProgrammingExercises
/GitProjects/sepIteams.py
427
4.40625
4
# Question: Write a program that accepts a comma separated sequence of words as input and prints the words in a # comma-separated sequence after sorting them alphabetically. Suppose the following input is supplied to the program: # without,hello,bag,world Then, the output should be: bag,hello,without,world items = [x f...
true
1f319726aebea1d6d18ef3a9dfd69293025be6f6
Darrenrodricks/PythonProgrammingExercises
/GitProjects/factorial.py
423
4.1875
4
# Question: Write a program which can compute the factorial of a given numbers. The results should be printed in a comma-separated # sequence on a single line. Suppose the following input is supplied to the program: 8 Then, the output should be: 40320 def factorial(x): if x == 0: return 1 return x * fac...
true
f6c7e0042cd3a6a82751ceeda0a7360c095153e2
wy7318/Python
/basic/whileProgramming.py
833
4.21875
4
available_exit=["east", "west", "north", "south"] #creating list choosen_exit="" while choosen_exit not in available_exit: choosen_exit=input("please choose direction:") if choosen_exit == "exit": print("game over") break else: print("glad you got out") #####################################...
true
c6ebcc4d45a499061f33c72c4e0d8548ebbdca1d
wy7318/Python
/basic/List.py
1,744
4.125
4
ipAddress = input("please enter an IP address") print(ipAddress.count(".")) #counting specific character #===============================================================================# word_list=["wow", "this", "that", "more"] #===============================================================================# word_list...
true
3250e52a4c73bb240705e1412ffda922c8694ef5
yqxd/LEETCODE
/44WildcardMatching.py
2,329
4.1875
4
''' Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). Note: s could be empty and conta...
true
ada055efcc03e73f8d40d6c045925997f0bdb453
greshan/python_assignments
/28.py
410
4.28125
4
#28. Implement a progam to convert the input string to inverse case(upper->lower, lower->upper) ( without using standard library) str_data = 'Greshan' result = '' for char in str_data: if ord(char) >= 65 and ord(char) <= 90: result += chr(ord(char) - 32) print(result) elif ord(char)<=97 and or...
true
e0c509792b018be0c9c6b68ad28b8e9271f3dc08
greshan/python_assignments
/23.py
212
4.34375
4
#23. Implement a program to write a line from the console to a file. inp = input("Enter text to print in file : \n") file = open("23.txt","w") if(file.write(inp)): print("written to 23.txt") file.close()
true
2fc21a984fd786cef73fbf20698492d822f87fc8
kellibudd/code-challenges
/get_century.py
712
4.1875
4
import math def centuryFromYear(year): """ Source: Codesignal Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc. Test case: >>> centuryFromYear(1905) ...
true
a5f501cc47fc3130f0a1672bd64b6a45e1df35a0
rhit-catapult/2021-session1
/individual_tutorials/pygamestartercode-gdhill-master/00-IntroToPython/07_mutation.py
1,727
4.28125
4
""" This module demonstrates MUTATION and RE-ASSIGNMENT. Authors: David Mutchler, Vibha Alangar, Matt Boutell, Dave Fisher, Mark Hays, Derek Whitley, their colleagues. """ ############################################################################## # TODO: 2. Read the code, then run it. # Make sure you u...
true
88b6094a8fff4e796496c08edfe152e557bf31cf
emildekeyser/tutoring
/fh/opl/Solutions-session5/Solutions-new/ex2b_fibindex.py
715
4.21875
4
def index_of_fib(s): # The number 1 is the value of fib_1 and fib_2 so we choose to return fib_1 if s == 1: return 1 s1 = 1 s2 = 1 s3 = s1 + s2 n = 3 # Same calculation as in ex2a but now we keep calculating new fib values until we reach our limit s while s3 < s: s1 = s2 ...
true
d0dd68ae68aa8d92162e2ce76116a08131eb8a6f
emildekeyser/tutoring
/fh/opl/oefenzitting_3_opl(1)/E2 Celsius to Fahrenheit.py
399
4.40625
4
input_string = input('Enter the temperature in Celsius: ') while input_string != 'q': celsius = float(input_string) fahrenheit = celsius * 9/5 + 32 print('The temperature in Fahrenheit is:', fahrenheit) input_string = input('Enter the temperature in Celsius: ') # for this exercise you cannot use a for...
true
74dbd77b513f89ef069d3fda4f67557bb72ed693
alekssro/CompThinkBioinf
/Week02/src/sort.py
1,268
4.34375
4
def insertion_sort(lst): """Sort a list of numbers. Input: lst -- a list of numbers Output: a list of the elements from lst in sorted order. """ s = [] for x in lst: # s contains contains all the element we have # seen so far, in sorted order smaller = [y for y in s if y <= x] larger = [y for y in s if y ...
true
87e673cc2faf46fd5d33335586782acbd31fd6bb
candyer/Daily-Coding-Problem
/dcp_12.py
1,384
4.375
4
# Daily Coding Problem: Problem #12 # There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, # write a function that returns the number of unique ways you can climb the staircase. # The order of the steps matters. # For example, if N is 4, then there are 5 unique ways: #...
true
88080fdc0a346368f15042dff08bf4fedc446219
ganesh1729ganesh/Algos_task_3
/problem_1_task3.py
1,058
4.125
4
n = input("Enter the number: ") #Taking input in the form of string sumTemp = 0 count = 0 while (len(n) > 1): #only we need to find sum of digits only when it is a non-single digit number sumTemp = 0 for i in range(len(n)): sumTemp += int(n[i])# simply to con...
true
b7bf1e1da7246b4d32a3ee82ee44d9e173e18bad
nandha-batzzy/Python-Projects-and-Learning
/Code forces Simple probs/ep11_Healpful maths.py
1,327
4.1875
4
'''Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation. The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough f...
true
a661836d6a717301fc81f6704de27873d9e9f419
hasanthex/fun-with-python
/python_basic/python_iterators.py
2,515
4.46875
4
# ****************************************************** # ITERATOR IN PYTHON # ****************************************************** # Iterators are everywhere in Python. # They are elegantly implemented within for loops, comprehensions, generators etc. but hidden in plain sight. # Iterator in Python is simply ...
true
e1b1bb12f984925d4a015d04637bac7caab33cf4
YS-Avinash/Python-programming
/functionUsingString.py
387
4.59375
5
#Python function to add 'ing' at the end of a given string and return the new string. #If the given string already ends with 'ing' then add 'ly'. #If the length of the given string is less than 3, leave it unchanged. def add_string(str1): return str1 if len(str1)<3 else str1+"ly" if str1.endswith("ing") else str1+...
true
973522d56fd1a6083522a66ec6f8873683ef2840
shariqueking/pyscripts
/battleship.py
1,770
4.1875
4
from random import randint board = [] for x in range(5): board.append(["O"] * 5) # creats 5x5 matrics def print_board(board): for row in board: print(" ".join(row)) #use to replace , with " " print("Let's play Battleship!") print_board(board) def random_row(board): retu...
true
813d3c89c6140ae700ba169f3357e048feee465e
Satyam-Bhalla/Python-Scripts
/Python Course/MultiThreading/multiThreading.py
793
4.1875
4
# Python program to illustrate the concept # of threading # importing the threading module import threading def print_cube(num): """ function to print cube of given num """ print("Cube: {}".format(num * num * num)) def print_square(num): """ function to print square of given num """ ...
true
392b8537797cdc5e23af55f4a31169c9c6081c75
Athenian-ComputerScience-Fall2020/greatest-common-factor-ryanabar
/my_code.py
1,102
4.25
4
# Collaborators (including web sites where you got help: (enter none if you didn't need help) # https://www.w3schools.com/python/python_operators.asp # I used the one above to learn what the % operator does (This assingment became a lot easier after I learned that this exists :) # https://www.mathsisfun.com/definitions...
true
bba53f762bd066a9afcb9aaf0ef848a9158b8480
programelu/python-demo
/fundamentals/tuples/simple-tuples.py
1,354
4.5
4
"""tuples may have paranthesys or not""" #tuple with paranthesys, recommanded for redability reasons plane1 = ("Airbus", "319", 200) print(plane1) #tuple without paranthesys - recognized as tuples because comma has been encountered plane2 = "Airbus", "A380", 500 print(plane2) print(plane2[0]) #Tuples with only o...
true
4ef1f456cf46e7106d53f8ee80f0cac364482a6b
marnovo/lpthw
/exercises/ex07_sd.py
1,470
4.53125
5
# Learn Python the Hard Way # https://learnpythonthehardway.org/python3/ex7.html # Study Drills # 1. Go back through and write a comment on what each line does. # 2. Read each one backward or out loud to find your errors. # 3. From now on, when you make mistakes, write down on a piece of paper what # kind of mista...
true
5a73e4c50f77dcdda03dc5765f96e9a8173ed643
AlbertMukarsel/Pico-y-Placa
/restrictions.py
1,566
4.1875
4
from datetime import datetime import utilities def restrictionDays(date, licensePlate): """ Each day is represented by a number, Monday=0...Sunday-6 during weekdays, according to each day, if a license plate has one of those digits as its last one, is subject to the Pico y Placa restrictions I.E: o...
true
d7267185a20504fb7f42e68f71753c8d8b274208
pekasus/randomMusicPlayer
/file_renamer.py
724
4.15625
4
// File Renamer // By: pekasus // CC by 3.0 // This program will rename all files that end in .mp3 within a folder. import os songlist = "songlist.txt" i = 1 with open(songlist, 'w') as fout: fout.write("Legend of Songs\n\n"); fout.close() for filename in os.listdir('/Volumes/musbox'): if filename.lowe...
true
32cf9ccecb1f2027e2bb47903a27831b1ebbf653
I7RANK/holbertonschool-low_level_programming
/0x1C-makefiles/5-island_perimeter.py
1,468
4.21875
4
#!/usr/bin/python3 """contains the island_perimeter function """ def island_perimeter(grid): """returns the perimeter of the island described in grid: ♪ 0 represents a water zone ♪ 1 represents a land zone Args: grid (list of lists): the grid Returns: int: the perimeter o...
true
dad3c543d9682d90203cf189bdfad552d1b46a4a
idcrypt3/camp_2019_07_28
/Caelan/Loops.py
736
4.1875
4
number_of_leaves = 14 for x in range(0, number_of_leaves): print("A leaf fell to the ground " + str(x) + " leaves have fallen.") print("All the leaves fell. For loop complete.") on_roller_coaster = True while on_roller_coaster: print("Ahhh!") on_roller_coaster = False times_to_repeat = 5 for x in ...
true
c722a50ea46cfcf03b2011373f7371361528d632
skhatri/pylearn
/week1/2_temp_conv.py
830
4.1875
4
""" Convert the given temparature in Celcius to Farenheit """ #your friend came from America. you find temperature for him #37.5 Celcius is 99.5% Farenheit C = 37.5 #F = ? #we know F = 9/5 * C + 32 F = 9 / 5 * C + 32 print F #89.6 F = 9 * 1.0 / 5 * C + 32 print F #types of names/variables print type(5) print ty...
true
4dd1d72ede3982aea33d067324950c8345cdee6e
wenqitoh/Recipe-Moderniser
/03_find_scale_factor_v2.py
915
4.34375
4
"""Ask user for number of servings in recipe and number of servings desired and then calculate the scale factor Version 2 - uses number checking function to ensure input is a number Created by Wen-Qi Toh 28/6/21""" # number checking function # gets the sale factor - which must be a number def num_check(question): ...
true
297445e1a3b6886fcb21b73431e723aff27d7efc
unshah/amazon_sales
/sales.py
1,608
4.125
4
# Script to calculate Demand #sold => total products sold (approx.) #rev => total reviews of the product # taking corelation as 1 review per 100 products (ex. rev = 5 || sold = 500) # This is the feature branch !! #----------------------------------------------------------------------------------------------------...
true
35813bb247e0ee95679723b7cd07a8fe3a1e518b
zhangshv123/superjump
/interview/facebook/mid/LC494_Target Sum.py
1,269
4.1875
4
#!/usr/bin/python """ You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol. Find out how many ways to assign symbols to make sum of integers equal to target S. Example 1: Input: nums is [...
true
0e9fb15850ffdefc0b94074e8694a2888a85cc0c
zhangshv123/superjump
/interview/google/mid/LC417. Pacific Atlantic Water Flow.py
2,026
4.15625
4
""" Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touches the right and bottom edges. Water can only flow in four directions (up, down, left, or right) from a cell to ano...
true
ceb685395799009e79f74f6bd2d7f6977d5a3395
zhangshv123/superjump
/interview/others/easy/LintCode Insert Node in a Binary Search Tree.py
1,056
4.15625
4
""" Given binary search tree as follow, after Insert node 6, the tree should be: 2 2 / \ / \ 1 4 --> 1 4 / / \ 3 3 6 """ """ Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None...
true
22784fc51726e32b5c14739dda4195063824e0d5
zhangshv123/superjump
/interview/facebook/easy/LC461_477_Hamming Distance.py
2,199
4.53125
5
#!/usr/bin/python """ The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note: 0 ≤ x, y < 231. Example: Input: x = 1, y = 4 Output: 2 Explanation: 1 (0 0 0 1) 4 (0 1 0 0) ↑ ↑ ...
true
9f08f217111cb664d37b42416a496c61a09b85b4
itsHuShihang/PythonBeginner
/data_type/tuple.py
307
4.40625
4
t=(1,2,3,4,5,6) ''' the methods of tuple are the same as the methods of list, but the elements in a tuple cannot be changed you cannot delete the elements of a tuple but you can use del to delete the whole tuple ''' # convert list to tuple l = [1, 2, 3, 4, 5] print(type(l)) l2t = tuple(l) print(type(l2t))
true
282cc5a7d9243d2fd1a1a429ec296f0b224d1c89
JamesWJohnson/TruckCapeProjects
/02_Better_Hello_World/better_hello_world.py
731
4.375
4
#!/usr/bin/env python3 # OK, now we're going to do a slightly more complicated Hello World # First, declare two variables. # Here, declare one called print1 with the value "Hello, world!" # Now here, declare another one called print2 with the value "Nice to see you!" # This bit here is called a loop. It executes...
true
9f9150ce977b08fed005a19539ab2862699879c2
nickfuentes/Python-Practice
/python/car_dealer.py
605
4.125
4
cars = [] # creating the Car class class Car: # constructor or initializer def __init__(self, make, model, color): self.make = make # set property make to the arguement make self.model = model self.color = color # Passing self makes the the drive function availble to thte Car Objects...
true
06b03068025264b0598e9b5b4dd7ad081fd2b983
akashrajput25/Python
/tkintler_gui/positioning_app.py
262
4.15625
4
#using GRID System , positioning from tkinter import * root =Tk() myLabel1 = Label(root , text="Hello World").grid(row=0 ,column = 0) # positioning on screen and creating a label widget myLabel2 = Label(root , text="Its Akash").grid(row=2 ,column = 1) root.mainloop()
true
13efaaf294755f28b21cb1592e8299127eb7d34d
ishantk/GW2019B
/venv/Session3B.py
367
4.25
4
# Read Data from User and store it in a container data = input("Enter some data: ") print("You Entered:",data) print("Type of data is:",type(data)) num1 = int(input("Enter Number 1: ")) num2 = int(input("Enter Number 2: ")) num3 = num1 + num2 # print("num3 is: ",num3) print("sum of",num1,"and",num2,"is:",num3) print("...
true
47d67710dd4a6ca5587fae426aaeda209bebbd79
Bakley/effective-journey
/Chapter 7/Exercise7_3.py
556
4.21875
4
""" Write a function named test_square_root that prints a table. The first column is a number, a; the second column is the square root of a computed with the function from Exercise 7.2; the third column is the square root computed by math.sqrt; the fourth column is the absolute value of the difference between the two e...
true
d6051b1eb58bf7a4699a30b1be035b828ea2d5d4
nanakiksc/algorithms
/merge_sort.py
1,204
4.15625
4
#!/usr/bin/env python #-*- coding:utf-8 -*- # Sort and count the number of inversions in an array. def sort_count(array): # Return the inversion count and the sorted subarray. n = len(array) if n <= 1: return array, 0 else: mid = n / 2 l_array, left = sort_count(array[:mid]) ...
true
8cd1442a3b9767de97724463ca2272a706061da8
arvakagdi/GrokkingTheCodingInterviews
/GTCI_2Pointers_1/DutchFlag.py
1,203
4.3125
4
''' Problem Statement # Given an array containing 0s, 1s and 2s, sort the array in-place. You should treat numbers of the array as objects, hence, we can’t count 0s, 1s, and 2s to recreate the array. The flag of the Netherlands consists of three colors: red, white and blue; and since our input array also consists ...
true
4866640c3c406ca213973d4d38bbc62f9e6255d5
arvakagdi/GrokkingTheCodingInterviews
/GTCI_BitwiseXOR/1/SingleNumber.py
927
4.15625
4
''' Problem Statement # In a non-empty array of integers, every number appears twice except for one, find that single number. Example 1: Input: 1, 4, 2, 1, 3, 2, 3 Output: 4 Example 2: Input: 7, 9, 7 Output: 9 Solution with XOR # following are the two properties of XOR: It returns zero if we take X...
true
e4f28e42bdcc8911c83dce45f55f203553772a00
arvakagdi/GrokkingTheCodingInterviews
/SlidingWindow/NoRepeatSubstring.py
1,490
4.4375
4
''' Given a string, find the length of the longest substring which has no repeating characters. Example 1: Input: String="aabccbb" Output: 3 Explanation: The longest substring without any repeating characters is "abc". Example 2: Input: String="abbbb" Output: 2 Explanation: The longest substring without ...
true
8de4537d4df3a92ecd86ab32f1584d0af5b165f2
arvakagdi/GrokkingTheCodingInterviews
/GTCI_2Pointers_1/3SumCloseToTarget.py
1,583
4.21875
4
''' Problem Statement # Given an array of unsorted numbers and a target number, find a triplet in the array whose sum is as close to the target number as possible, return the sum of the triplet. If there are more than one such triplet, return the sum of the triplet with the smallest sum. Example 1: Input: [-2, ...
true
724e0b4c178b08a32c7cfe2a1c3fb332062048b2
rsamhollyer/Week-1-Algo-Challenge
/earlierPyAlgos/indicesums.py
1,328
4.125
4
#3. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. # You may assume that each input would have exactly one solution, and you may not use the same element twice. # You can return the answer in any order. # Examples and clarification here: https:/...
true
0ac0b0cc92209e998a6d1ba8210ffbcf4cb2700a
soumikchaki/coursera-py4e
/p2-python-data-structure/week4/a1-string-order.py
632
4.34375
4
# Open the file romeo.txt and read it line by line. For each line, # split the line into a list of words using the split() method. # The program should build a list of words. For each word on each line check to see if the word is already in the list # and if not append it to the list. When the program completes, sort a...
true
97d1d59e3fb09d918d6d9dc5510fb876d3fc0822
abhishekjee2411/python_repos_novice
/2_odd_even_div.py
1,165
4.25
4
#-------------------------------------------------------------# print ("------------------------------------------------------------") #-------------------------------------------------------------# nbr = int(input("Enter a number: ")) if (nbr%2 == 0): print ("The number is even!") if (nbr%4 == 0): print ("It is a...
true
a607c7b2ea1f032032c96e8e4e17067a3741bd72
isrdoc/snit-hr-wd1-python-basics
/08_Introduction_to_Python_and_variables.py
309
4.1875
4
message = "Hello" user_name = input("Please enter your name: ") user_age = int(input("Please enter your age: ")) is_user_logged_in = False if message == "Hello": print(message + " " + user_name) print("Your age is: " + str(user_age - 10)) print("User is logged in.") print("After conditional")
true
ae8b14f07eff5b367d74c440e58b64bce4fc4899
ManassaVarshni/ProjectEuler
/Problem9.py
747
4.375
4
""" A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ def pythagoreanTriplet(n): # If the triplets are in sorted order. # The ...
true
09248cd9bc40e1cfcb6ddad885b28c8ca41c9f9f
lingler412/UDEMY_PYTHON
/factorial_for_loop.py
516
4.53125
5
my_num1 = int(input("Give me a number so I can give you it's factorial! ")) # give me a whole integer def calc_factorial(my_num): # here is a function to caluate the factorial of the provided integer for num in range(my_num - 1, 1, -1): my_num *= num return my_num my_factorial = calc_factorial(my_nu...
true
66ced30141bf401a6446557ad4f066d0fb69d2ec
James-Ashley/python-challenge
/PyBank/main.py
2,812
4.375
4
# * In this challenge, you are tasked with creating a Python script for analyzing the financial records of your company. You will give a set of financial data called [budget_data.csv](PyBank/Resources/budget_data.csv). The dataset is composed of two columns: `Date` and `Profit/Losses`. (Thankfully, your company has rat...
true
282454d642780f4441398a592aed122eaff363a2
ronmarian7/TAU-HW-Python
/EX7/ex7_316593839.py
2,876
4.4375
4
""" Exercise #7. Python for Engineers.""" ######################################### # Question 1 - do not delete this comment ######################################### class Beverage: def __init__(self, name, price, is_diet): self.name = name self.price = price self.is_diet = is_diet ...
true
15f3739d21506bd03f1edb911a7ebf3ddf921f03
kangli-bionic/coding-challenges-and-review
/random/random_odd.py
2,048
4.5625
5
""" Input: interval a, b Output: a random odd integer in the range of a to b with equal probability Range is inclusive. Given a random function random(a, b) that returns a random integer in the range of a to b, implement a randomOdd(a, b) function that returns a random odd integer in the range of a to b ran...
true
40455235cf6903ce53d012a8236cde45a90d447e
s2097382/Testing
/Assessment2.py
2,661
4.25
4
#Q1 def student_pass(score1, score2, score3): # Insert your code here passed = False avg = (score1 + score2 + score3)/3 if score1 >= 40 and score2>= 40 and score3 >= 40: passed = True elif avg > 50: if score1>=40 and score2>=40: passed = True elif score1>=40 and...
true
596fa4fbbe7968c0423d042994723b1f7ea104c0
gazelleazadi/INF200-2019-Exersices
/src/ghazal_azadi_ex/ex01/letter_counts.py
418
4.125
4
def letter_freq(txt): txt = txt.lower() letter_new = {} for i in txt: letter_new[i] = txt.count(i) return letter_new # Using Dictionary that holds unique "Key Values" pair. if __name__ == '__main__': text = input('Please enter text to analyse: ') frequencies = letter_freq(text) f...
true
659d64a63c101f2fe07e79dd81410bbdc56206a7
lanchunyuan/Python
/PythonCrashCourse/chapter-4/4-10.py
297
4.3125
4
favorite_pizzas = ['pepperoni', 'hawaiian', 'veggie','sausage'] print(r'The first three items in the list are:') print(favorite_pizzas[:3]) print(r'Three items from the middle of the list are:') print(favorite_pizzas[1:4]) print('The last three items in the list are:') print(favorite_pizzas[-3:])
true
1d9c06fd8df38fdba89467496a77666f71fef83a
Sohaib76/Python-Certified-Cisco
/Assignments/Assignment # 1.py
1,914
4.5625
5
'''1. Write a Python program to print the following string in a specific format (see the output). 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''' print('''Twinkle, twinkle, little star, \n\tHow...
true
77263cee411732ef87a4357e9e6e8f6b14e88fa1
TimTheFiend/Python-Tricks
/pyFiles/2.1_assert.py
1,082
4.375
4
def apply_discount(product, discount): price = int(product['price'] * (1.0 - discount)) """Assert: If this isn't true, throw an exception Assertions are meant to be internal self-checks for you program. They work by declaring some conditions as impossible in your code. I...
true
59b11140614aee7f6deece88357000b4118ba2e0
TimTheFiend/Python-Tricks
/pyFiles/5.4_sets_and_multisets.py
2,084
4.40625
4
"""A set is an unordered collection of objects that does not allow duplicate elements. """ # set - your go-to set vowels = {'a', 'e', 'i', 'o', 'u',} print('e' in vowels) # True letters = set('alice') print(letters.intersection(vowels)) # {'i', 'e', 'a'} vowels.add('x') print(vowels) # {'i', 'x', 'u', 'e', 'o', 'a'}...
true
208171031745565970746e7c7c9ae56bb07d826e
mjmandelah07/assignment1
/assignment_2/question_3.py
458
4.25
4
# Given a list slice it into 3 equal chunks and reverse each chunk sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89] chunk_1 = sampleList[:3] chunk_2 = sampleList[3:6] chunk_3 = sampleList[6:9] print("Original list:", sampleList) print("Chunk 1:", chunk_1) print("After reversing chunk 1:", chunk_1[::-1]) print("chunk ...
true
462be16865837a4a3d365fe1b524f86a6d706c78
mjmandelah07/assignment1
/question2.py
472
4.15625
4
# Given a range of first 10 numbers, Iterate from start number to the end number and # print the sum of the current number and previous number: # HINT : Python range() function def number(num): previous_num = 0 for a in range(num): sum_num = previous_num + a print("Current Number", a, "Previous ...
true
e351e024fefa1cd4c15d8495eef7beaecdf2be58
zaiyangliu/theo-code-of-python
/sum_of_even_factorial_numbers_less_than_inputed.py
694
4.125
4
#python 3.6 def fib(num): sum = 0 p1 = 1 p2 = 1 i = 1 result = 0 while result < num: if i >= 1: if result % 2 == 0: sum += result result = p1 + p2 p1,p2 = p2, p1 + p2 print(sum) num = int(input("please input an positive integer\n"))...
true
b4711eeca831fa811438a36dc1f1cd1dbb1c4c6e
Vaishanavi13/Customer-Segregation-ML
/CustomerSegregation.py
2,272
4.15625
4
#!/usr/bin/env python # coding: utf-8 # In[2]: import numpy as np import pandas as pd import matplotlib.pyplot as plt #Data Visualization import seaborn as sns #Python library for Visualization # In[3]: #importing dataset dataset = pd.read_csv(r'C:\Users\HP\Downloads\customer-segmentation-dataset\customer-se...
true
21753658f0d6f829974d6b7bd3f7684061e8effb
MaxwellMensah/Data-Structures-and-Algorithms
/Arrays/11. Slice and Delete from a List.py
1,961
4.46875
4
myList = ['a', 'b', 'c', 'd', 'e', 'f'] print(myList[0:2]) # same as: myList = ['a', 'b', 'c', 'd', 'e', 'f'] print(myList[:2]) # omitting the second elements myList = ['a', 'b', 'c', 'd', 'e', 'f'] print(myList[1:]) # omitting both elements myList = ['a', 'b', 'c', 'd', 'e', 'f'] print(myList[:]) # updating first...
true
867a8f1048850aea8c88748e8b783a0a680b4373
MaxwellMensah/Data-Structures-and-Algorithms
/Dictionary/2. Inserting into a dictionary.py
299
4.34375
4
# Update or Add an element to the dictionary myDict = {'name': 'Edy', 'age': 26} myDict['age'] = 27 # overwrite/changed from 26 to 27. Time Complexity : O(1) print(myDict) # Adding new pairs myDict['address'] = 'London' # Time Complexity : O(1) print(myDict)
true
b6928db4afcdcdb5b2fe405d5033122635a51973
loide/hackerrank
/python/staircase.py
1,055
4.6875
5
""" Consider a staircase of size n = 4: # ## ### #### Observe that its base and height are both equal to n, and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces. Write a program that prints a staircase of size n. Input Format A single integer,n, denoting the size of t...
true
d8181599f70a0eb546c9073177bfdbd67c042763
EvanJamesMG/Leetcode
/python/Array/268. Missing Number.py
759
4.125
4
# coding=utf-8 __author__ = 'EvanJames' ''' Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra...
true
e98bb4522cd61870e4027eb01c8033388c9ecb3d
SUREYAPRAGAASH09/Unsorted-Array-Exercises
/32.shiftrightleft/shiftrightleft.py
750
4.3125
4
Question : ========== Shift Right Left the element of the array Input : ======= Unsorted Integer Array Output : ======== Unsorted Integer Array but, after shifting right left the element of the array Code : ====== def swapRight(array,shiftValue): temp = 0 iterator = 0 while (iterator2!=shiftValu...
true
e00985f648f9c2e443c89141dd5cf4d1e41eee64
SUREYAPRAGAASH09/Unsorted-Array-Exercises
/39.getIndexafterrotationright/getindexRight.py
491
4.40625
4
#37. Given an unsorted integer array A, # find the value that will be in 3rd position or index after 2 rotations to the right. import Rotateright def getIndexAfterrotationRight(array,index,rotation_value): afterRotation = Rotateright.swapRight(array,rotation_value) return afterRotation[index] #array = [5,7,6...
true
91b2938a08664a245836b94af2410b8a84725f21
SUREYAPRAGAASH09/Unsorted-Array-Exercises
/25.2ndLargestNumber/2ndLagestNumbers.py
397
4.21875
4
Question : ========== Get Second largest number form the list Input : ======= Unsorted Integer Array Output : ======== Integer - Get second largest integer Code : ====== import Max def secondLargestNumber(array): Maximum = Max.Max(array) for iterator in array: if Maximum == iterator: ...
true
ebf880df76a00a981c9d0430a0da732cae36fc05
mserevko/sorting-algorithms
/algorithms/bubble_sort.py
757
4.3125
4
""" Bubble sort 1. Looping through list 2. Compares elements of list (list[n] > list[n+1]), swaps them if they are in the wrong order. 3. The pass through the list is repeated until the list is sorted. """ import random import copy randomlist = [random.randint(0,100) for i in range(0, 7)] def bubble_sort(some_lis...
true
6455740e9b80d0ad3327998842788cd6284ea8c3
EOppenrieder/HW070172
/Homework5/Exercise7_5.py
520
4.25
4
# A program to tell you whether your weight is appropriate def main(): weight = float(input("Please enter your weight in pounds: ")) height = float(input("Please enter your height in inches: ")) BMI = (weight * 720) / (height**2) if BMI > 25: print("You're above the healthy range") elif 19 ...
true
08690352d335dee2c78fb17f9e4be53434a1177f
EOppenrieder/HW070172
/Homework4/Exercise3_17.py
359
4.21875
4
# A program to guess the square root of numbers def main(): x = float(input("Enter the number of which you want to know the square root: ")) n = int(input("Enter the number of times to improve the guess: ")) g = x / 2 for i in range (n): g = (g + x / g) / 2 print(g) import math prin...
true
6fa21435c58ab7dd564676c274660f01c7236b5f
EOppenrieder/HW070172
/Homework4/Exercise3_3.py
489
4.25
4
# A program to calculate the molecular weight # of a carbohydrate (in grams per mole) def main(): H = int(input("Enter the number of hydrogen atoms: ")) C = int(input("Enter the number of carbon atoms: ")) O = int(input("Enter the number of oxygen atoms: ")) Hweight = 1.00794 Cweight = 12.0107 ...
true
7db330f7c85ba02facdaa1c36786e7cdcffde435
EOppenrieder/HW070172
/Homework4/Exercise3_13.py
282
4.125
4
# A program to sum a series of numbers def main(): n = int(input("Enter the amount of numbers that are to be summed: ")) x = float(input("Enter a number: ")) for factor in range(2, n+1): y = float(input("Enter a number: ")) x = x + y print(x) main()
true
6ccc66d54d210e84dfa88b25df787a2035eb6d42
Lakssh/PythonLearning
/basic_learning/exception_handling.py
1,128
4.1875
4
""" Exception Handling Exceptions are errors and should be handled in the code link to python built in exceptions https://docs.python.org/3/library/exceptions.html try: <Function to be written here> except: <Exception block, same as catch in java> else: <executed when there is no exception> finally: <always executed de...
true
c996e11bbea73af2ee242abe4ee4fb70f5bee606
PnFTech/CodingInterview
/ch10/python/sorted_merge.py
1,212
4.21875
4
#!/usr/bin/env python ''' Author: Ping Guo Email: pingg104@gmail.com Problem Statement: You are given two sorted arrays, A and B, where A has a large enough buffer at the end to hold B. Write a method to merge B into A in sorted order. Example: A = [1, 5, 9] B = [2, 4, 7] C = [6, 9, 22, 34, 87, 98,101]...
true
fe407ecfd67c5ca3131c83f28114b644b17ddd11
gakkistyle/comp9021
/Practice_1 solution/span.py
1,566
4.125
4
""" prompts the user for a seed for the random number generator, and for a strictly positive number, nb_of_elements, generates a list of nb_of_elements random integers between 0 and 99, prints out the list, computes the difference between the largest and smallest values in the list without using the builtins min() ...
true
3872ae39b4f089816c8110aad6ab6a188bd765a7
yoonju-baek/Learn-Python-Programming
/1.basics/dictionaries.py
1,953
4.5
4
# Dictionaries - a collection of key-value pairs {key:value} fruit_0 = {'color': 'red', 'shape': 'circle'} print(fruit_0) print(fruit_0['color']) print(fruit_0['shape']) # Adding new key-value fruit_0['price'] = 3 print(fruit_0) # Modifying values fruit_0['color'] = 'yellow' fruit_0['shape'] = 'rectangle' print(fruit...
true
2cb8c1f3f5fee45e1e7dbde9b44e5a3e9795df8a
yoonju-baek/Learn-Python-Programming
/1.basics/ending_while_loops.py
487
4.4375
4
# User enter 'quit' to end the program prompt = "Tell me something. If you want to end the program, enter 'quit': " message = "" while message != 'quit': message = input(prompt) if message != 'quit': print(message) # Using a flag to end the program prompt = "(Using a flag)Tell me something. If you wa...
true
c393006cc9139f859d46d62873d29e3532f51de7
yoonju-baek/Learn-Python-Programming
/1.basics/conditional operations.py
926
4.3125
4
# Checking the condition of case is case sensitive # Equality: == # Inequality: != # Mathematical comparisons: <, > <=, >= # Multiple conditions: and, or # Strings Comparisons coffees = ['moca', 'espresso', 'americano', 'latte'] for coffee in coffees: if coffee == 'americano': print(coffee.title()) el...
true