blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
2be6e85839802e5365e65ee47d09f914d388f198
rajdharmkar/Python2.7
/methodoverloading1.py
606
4.25
4
class Human: def sayHello(self, name=None): if name is not None: print 'Hello ' + name else: print 'Hello ' # Create instance obj = Human() # Call the method obj.sayHello() # Call the method with a parameter obj.sayHello('Rambo') #obj.sayHello('Run', 'Lola')...
true
825180decbe595ad5ec6b84511f97661ae28a121
NANGSENGKHAN/cp1404practicals
/prac02/exceptions_demo.py
1,046
4.53125
5
try: numerator = int(input("Enter the numerator: ")) denominator = int(input("Enter the denominator: ")) while denominator == 0: print("Denominator cannot be zero") denominator = int(input("Enter the denominator: ")) fraction = numerator / denominator print(fraction) except ValueErro...
true
9ac5ec423256abc74722ccf876114310e87aad6b
emanchas/Python
/Python/exam1IST140_Ed Manchas.py
1,160
4.21875
4
print ('This program converts fahrenheit to celsius \n') user_temp = int(input('Please input a temperature in Fahrenheit:')) while user_temp < 0: print ('Error! Temperature must be greater than 0 degrees!') user_temp = int(input('Please input a temperature in Fahrenheit:')) print ('') print ('Fahrenheit...
true
fb80c96b9ea3a455cc9e5fe3daac41c59e64672b
EQ4/amplify
/src/amplify/utils.py
643
4.46875
4
import re def natural_sort(string): ''' This function is meant to be used as a value for the key-argument in sorting functions like sorted(). It makes sure that strings like '2 foo' gets sorted before '11 foo', by treating the digits as the value they represent. ''' # Split the string int...
true
599ff97346be71193c24c5818e5f2daf99cd6e04
cfascina/python-learning
/exercices/built-in-functions/lambda-expression/main.py
764
4.5625
5
# Lambda expressions are anonymous functions that you will use only once. # The following square() function will be converted into a lambda expression, # step by step. # Step 1: # def square(number): # result = number ** 2 # return result # Step 2: # def square(number): # return number ** 2 # Step 3: # d...
true
ee4f50efcfb983282db6c7a1bedf8116508ebf55
MDCGP105-1718/portfolio-Ellemelmarta
/Python/ex11.py
780
4.1875
4
from random import randint x = int(randint (1,100)) #make user guess a number with input guess = int(input("Guess a number between 1 - 100: ")) num_guesses = 1 #tell them higher or lower while guess != x: if guess > x and guess != x: print ("wrong, too high") guess = int(input("Guess again: ")) ...
true
b59bf1444ea96d25bb3aa233600e298f41df21e9
ssavann/Python-Hangman-game
/Hangman.py
1,754
4.34375
4
#Build a hangman game import random import HangmanArt import HangmanWords #print ASCII art from "stages" print(HangmanArt.logo) end_of_game = False #List of words word_list = HangmanWords.word_list #Let the computer generate random word chosen_word = random.choice(word_list) #to count the number of letter in th...
true
77f22ce39b1fee400eaf29861a4a5eca82ebf9a4
LuiSteinkrug/Python-Design
/wheel.py
1,400
4.21875
4
import turtle turtle.penup() def drawCircle(tcolor, pen_color, scolor, radius, mv): turtle.pencolor(pen_color) # not filling but makes body of turtle this colo turtle.fillcolor(tcolor) # not filling but makes body of turtle this colo turtle.begin_fill() turtle.right(90) # Face South ...
true
325f52227fcdd352295be2352731b33cedaf2ba4
urantialife/AI-Crash-Course
/Chapter 2/Functions/homework.py
715
4.1875
4
#Exercise for Functions: Homework Solution def distance(x1, y1, x2, y2): # we create a new function "distance" that takes coordinates of both points as arguments d = pow(pow(x1 - x2, 2) + pow(y1 - y2, 2), 0.5) # we calculate the distance between two points using the formula provided in the...
true
6993f804ebd81a8fac2c2c2dcc7ba5a96d37e62d
saifsafsf/Semester-1-Assignments
/Lab 11/Modules2.py
1,894
4.4375
4
def strength(password): '''Takes a password. Returns its strength out of 10.''' pass_strength = 0 # If length of password is Good. if 16 >= len(password) >= 8: pass_strength += 2 # If password has a special character if ('$' in password) or...
true
ce44b33c8e5d4c26ec7f67d09fff55e8d4623d9c
saifsafsf/Semester-1-Assignments
/Lab 08/task 1.py
419
4.21875
4
math_exp = input('Enter a mathematical expression: ') # Taking Input while math_exp != 'Quit': math_exp = eval(math_exp) # Evaluating Input print(f'Result of the expression: {math_exp:.3}\n') print('Enter Quit to exit the program OR') # Taking input for next iteration math_exp = input('Ent...
true
7196fac0553a675a33fe3cc7816876f40fa2966e
saifsafsf/Semester-1-Assignments
/Lab 08/AscendSort.py
533
4.15625
4
def ascend_sort(input_list): '''ascend_sort([x]) Returns list sorted in ascending order.''' for i in range(1, len(input_list)): # To iterate len(list)-1 times for j in range((len(input_list))-i): if input_list[j] > input_list[j+1]: # Comparing two consecutive values ...
true
bdf165162078678430c7db868bb38f2894b27f63
saifsafsf/Semester-1-Assignments
/Assignment 3/Task 1.py
780
4.1875
4
import Maxim import Remove # Importing modules import Reverse nums = input('Enter a natural number: ') # Taking input if int(nums) > 0: largest_num = str() # Defining variable before using in line 9 while nums != '': max_num = Maxim.maxim(nums) # Using Maxim module large...
true
ba2c1f8c3440bbcc652276ea22c025fdc6fae4d6
ridinhome/Python_Fundamentals
/07_classes_objects_methods/07_01_car.py
862
4.4375
4
''' Write a class to model a car. The class should: 1. Set the attributes model, year, and max_speed in the __init__() method. 2. Have a method that increases the max_speed of the car by 5 when called. 3. Have a method that prints the details of the car. Create at least two different objects of this Car class and dem...
true
3ca0df53a0db382f61549d00923829d0dc3b00be
ridinhome/Python_Fundamentals
/08_file_io/08_01_words_analysis.py
1,565
4.4375
4
''' Write a script that reads in the words from the words.txt file and finds and prints: 1. The shortest word (if there is a tie, print all) 2. The longest word (if there is a tie, print all) 3. The total number of words in the file. ''' my_dict = {} shortest_list = [] longest_list = [] def shortestword(input_dic...
true
b644aa4a1d7e9d74a773a5e2b4dc095fac236ee2
ridinhome/Python_Fundamentals
/03_more_datatypes/3_tuples/03_16_pairing_tuples.py
970
4.375
4
''' Write a script that takes in a list of numbers and: - sorts the numbers - stores the numbers in tuples of two in a list - prints each tuple If the user enters an odd numbered list, add the last item to a tuple with the number 0. Note: This lab might be challenging! Make sure to discuss it with your me...
true
916c20052c18261dd5ef30d421b0e17b0e92d443
ridinhome/Python_Fundamentals
/02_basic_datatypes/1_numbers/02_05_convert.py
568
4.375
4
''' Demonstrate how to: 1) Convert an int to a float 2) Convert a float to an int 3) Perform floor division using a float and an int. 4) Use two user inputted values to perform multiplication. Take note of what information is lost when some conversions take place. ''' value_a = 90 value_b = 11....
true
d4c0dbee1de20b3fae2f2ae80f74d105463d4c07
akhilkrishna57/misc
/python/cap.py
1,727
4.21875
4
# cap.py - Capitalize an English passage # This example illustrates the simplest application of state machine. # Scene: We want to make the first word capitalized of every sentence # in a passage. class State (object): def setMappedChar(self, c): self.c = c def getMappedChar(self): return self.c def se...
true
21ca29ba7a6e2a124a20291d11490a4eefabe4d3
jhanse9522/toolkitten
/Python_Hard_Way_W2/ex8.py
1,364
4.53125
5
formatter = "{} {} {} {} " # this is the equivalent of taking a data of type str and creating positions (and blueprints?) for different arguments that will later be passed in and storing it in a variable called #formatter print(formatter.format(1, 2, 3, 4)) #The first argument being passed in and printed is of dat...
true
06efc287d6c51abc7851cbccbece718179a9e4a0
jhanse9522/toolkitten
/Python_Hard_Way_W2/ex16.py
1,368
4.3125
4
from sys import argv script, filename = argv print(f"We're going to erase {filename}.") print("If you don't want that, hit CTRL-C (>C).") print("If you do want that, hit RETURN.") #print statement doesn't ask for input. Only to hit the return key, which is what you would normally hit after entering user input. (or qu...
true
0ba974b7a198bea2c267cb0a1d87c719c6bef25e
jhanse9522/toolkitten
/Python_Hard_Way_W2/ex15a.py
1,171
4.65625
5
filename = input("What's the name of the file you want to open?") txt = open(filename) #the open command takes a parameter, in this case we passed in filename, and it can be set to our own variable. Here, our own variable stores an open text file. Note to self: (filename) and not {filename} because filename is alread...
true
63043be9d8b39e5caf053a06bd8129a27f0c4ffe
BSR-AMR-RIVM/blaOXA-48-plasmids-Microbial-Genomics
/scripts/printLine.py
273
4.1875
4
# quick code to print the lines that starts with > import sys FILE = sys.argv[1] with open(FILE, 'r') as f: count = 0 for line in f: count =+ 1 if line.startswith(">"): newLine = line.split(' ') if len(newLine) < 3: print(newLine) print(count)
true
b48bbe647eedb43c9e4adaa726842cfed8c38fd0
Rythnyx/py_practice
/basics/reverseArray.py
1,125
4.46875
4
# The purpose of this excercise is to reverse a given list exList = [1,2,3,4,5,6,7,8,9,10,'a','b','c','d','e','f','g'] # The idea here is to simply return the list that we had but step through it backward before doing so. # This however will create a new list, what if we want to return it without creating a new one? ...
true
787bb5e6c13463126b80c1144ae7a19274aab61b
ebonnecab/CS-2-Tweet-Generator
/regular-challenges/dictionary_words.py
1,176
4.125
4
#an algorithm that generates random sentences from words in a file #TO DO: refactor code to use randint import random import sys # number = sys.argv[:1] number = input('Enter number of words: ') #takes user input ''' removes line breaks, and appends the words from the file to the list, takes five words from the list...
true
151172bdb8289efb3e3494a7c96db79c0d07de4c
kushrami/PythonProgramms
/LoanCalculator.py
439
4.125
4
CostOfLoan = float(input("Please enter your cost of loan = ")) InterestRate = float(input("Please enter your loan interst rate = ")) NumberOfYears = float(input("Please enter Number of years you want a loan = ")) InterestRate = InterestRate / 100.0 MonthlyPayment = CostOfLoan * (InterestRate * (InterestRate + 1.0) * N...
true
d5c46b1068f3fa7d34ef2ef5151c1c0a825c88f5
derpmagician/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
253
4.3125
4
#!/usr/bin/python3 """ Reads an utf-8 formated file line by line""" def read_file(filename=""): """Reads an UTF8 formated file line by line """ with open(filename, encoding='utf-8') as f: for line in f: print(line, end='')
true
8fc8ff320c25de0b3b15537fbbee03749721a9c1
Aliena28898/Programming_exercises
/CodeWars_exercises/Roman Numerals Decoder.py
1,816
4.28125
4
''' https://www.codewars.com/kata/roman-numerals-decoder Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral. Modern Roman numerals are written by expressing each decimal digit of the number to be enc...
true
24540c992ec687bd43c3b38674e1acef2f43dcb8
Aliena28898/Programming_exercises
/CodeWars_exercises/Reversed Sequence.py
298
4.25
4
''' Get the number n to return the reversed sequence from n to 1. Example : n=5 >> [5,4,3,2,1] ''' #SOLUTION: def reverse_seq(n): solution = [ ] for num in range(n, 0, -1): solution.append(num) return solution #TESTS: test.assert_equals(reverse_seq(5),[5,4,3,2,1])
true
51bff2c710aa809cc0cf3162502a7acae518bf60
AnaLuizaMendes/Unscramble-Computer-Science-Problems
/Task1.py
1,011
4.25
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 1: How many different telephone nu...
true
18ad26f5f5613336ece2a9affadceb7282ab0a75
aaishikasb/Hacktoberfest-2020
/cryptography system/Crypto_system.py
729
4.3125
4
def machine(): keys = "abcdefghijklmnopqrstuvwxyz !" values = keys[-1] + keys[0:-1] encrypt = dict(zip(keys, values)) decrypt = dict(zip(values, keys)) option = input( "Do you want to encrypt or decrypt, press e for encrypt and d for decrypt?") message = input("what is the message you ...
true
c0f8180687415dbc703433d7642329baedf9212f
MLHafizur/Unscramble-Computer-Science-Problems
/Task4.py
1,528
4.1875
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 4: The telephone company want to i...
true
99abf35d29cc6488acc5a7d230abd99688ca45ea
JKinsler/Sorting_Algorithms_Test
/merge_sort3.py
1,508
4.15625
4
""" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Merge sort Sorting array practice 6/9/20 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Sort an unsorted array in O(nlogn) time complexity Developer notes: this is my favorite way to organize the merge sort algorithm because I think ...
true
e0c5fc3a55327871f16b450def694a6dd97a8e5f
JKinsler/Sorting_Algorithms_Test
/merge_sort2.py
1,353
4.15625
4
""" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Merge sort Sorting array practice +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Sort an unsorted array in O(nlogn) time complexity """ def merge_sort(arr): """ decompose the array into arrays of length 1 recombine the a...
true
5a5c10e83e60d200ed4a722f8a018e43014d628d
Benedict-1/mypackage
/mypackage/sorting.py
1,561
4.34375
4
def bubble_sort(items): '''Return array of items, sorted in ascending order''' count = 0 for idx in range(len(items)-1): if items[idx] > items[idx + 1]: items[idx],items[idx + 1] = items[idx + 1],items[idx] count += 1 if count == 0: return items else: ...
true
8242e2eb55ad59d6c17497e56df4cc150fc78a33
jpchato/data-structures-algorithms-portfolio
/python/array_shift.py
766
4.3125
4
''' Feature Tasks Write a function called insertShiftArray which takes in an array and the value to be added. Without utilizing any of the built-in methods available to your language, return an array with the new value added at the middle index. Example Input Output [2,4,6,8], 5 [2,4,5,6,8] [4,8,15,23,42], 16 [4,8,1...
true
82f361fc9231541a923a2c071e14c9b8e6780f88
cnagadya/bc_16_codelab
/Day_three/wordcount.py
599
4.1875
4
""" words function to determine the number of times a word occurs in a string""" def words(input_string): #dictionary template to display words as keys and occurances as values words_dict = {} #splitting string into list to enable iteration words_list = input_string.split() #iterate through the list to...
true
3ba5adf3dfceea19a2d84aa3e983951341f10e92
elvisasante323/code-katas
/python_code/regex.py
515
4.4375
4
# Learning about regex import re # Search the string to see if it starts with 'The' and ends with 'Spain' text = 'The rain in Spain' expression = re.search('^The.*Spain$', text) if expression: print('We have a match!\n') else: print('There is no match!\n') # Find all lower case characters alphabetically betw...
true
215950378bbcd2f020be5ebfb49cd5c7b5a9aa07
cgisala/Capstone-Intro
/Lab1/Part2:_list_of_classes.py
432
4.21875
4
#Variable choice = 'y' #Initializes choice to y classes = [] #Declares an empty array #Loops until the user enters 'n' for no while(choice == 'y'): semesterClass = input("Enter a class you are taking this semester: ") classes.append(semesterClass) choice = input("Do you want to add more y or n: ") pri...
true
9e3b8d7aac17d3b5cef01341cc8452f9ac52cab6
zrjaa1/Berkeley-CS9H-Projects
/Project2A_Power Unit Converter/source_to_base.py
1,260
4.34375
4
# Function Name: source_to_base # Function Description: transfer the source unit into base unit. # Function Input # - source_unit: the unit of source, such as mile, cm. # - source_value: the value in source unit. # Function Output # - base_unit: the unit of base, such as m, kg, L # - base_value: the value in b...
true
3191972f08fb2d8e4a6292c5bdd59aabdcb51688
alfonso-torres/data_types-operators
/strings&casting.py
1,937
4.65625
5
# Strings and Casting # Let's have a look at some industry practices # single and double quotes examples greetings = 'hello world' single_quotes = 'single quotes \'WoW\'' double_quotes = "double quotes 'WoW'" # It is more easier to use print(greetings) print(single_quotes) print(double_quotes) # String slicing gree...
true
38322c01d2c410b06440fae9ce02faf2c8e045c4
JamesPiggott/Python-Software-Engineering-Interview
/Sort/Insertionsort.py
880
4.1875
4
''' Insertionsort. This is the Python implementation of the Insertionsort sorting algorithm as it applies to an array of Integer values. Running time: ? Data movement: ? @author James Piggott. ''' import sys import timeit class Insertionsort(object): def __init__(self): print() def ins...
true
0c54a30b5564cf4fce07a4a22d90f2fee61fd27c
Caelifield/calculator-2
/calculator.py
1,170
4.21875
4
"""CLI application for a prefix-notation calculator.""" from arithmetic import (add, subtract, multiply, divide, square, cube, power, mod, ) # Replace this with your code def calculator(): while True: input_string = input('Enter string:') token = input_string.split(' ') ...
true
204462c7d2e433cbb38fd5d0d1942cda5303b939
VIPULKAM/python-scripts-windows
/count_lines.py
759
4.21875
4
file_path='c:\\Python\\pledge.txt' def count_lines(handle): ''' This function returns the line count in the file. ''' offset = 0 for line in handle: if line: offset += 1 continue return offset def count_occurnace(handle, word): ''' This function returns...
true
854838cba4d9a2f2abddfb86bccd1237e9140a4c
jofro9/algorithms
/assignment1/question3.py
2,458
4.1875
4
# Joe Froelicher # CSCI 3412 - Algorithms # Dr. Mazen al Borno # 9/8/2020 # Assignment 1 import math # Question 3 class UnitCircle: def __init__(self): self.TARGET_AREA_ = 3.14 self.RADIUS_ = 1. self.triangles_ = 4. self.iter = 0 ### member functions for use throughout code ##...
true
731beff49555f623448ce5cb13188586fa850201
tabish606/python
/comp_list.py
665
4.53125
5
#list comprehension #simple list example #creat a list of squares squares = [] for i in range(1,11): squares.append(i**2) print(squares) #using list comprehension squares1 = [] squares1 = [i**2 for i in range(1,11)] print(squares1) #NOTE : in list comprehension method the data is to be...
true
0384000aaaedfd61cf915234cc419e4d9deff281
kadamsagar039/pythonPrograms
/pythonProgramming/bridgelabzNewProject/calender.py
653
4.15625
4
"""Calender Program This program is used to take month and year from user and print corresponding Calender Author: Sagar<kadamsagar039@gmail.com> Since: 31 DEC,2018 """ from ds_utilities.data_structure_util import Logic def calender_runner(): """ This method act as runner for calender_queue(month, y...
true
d389e3a7ad0bd05f8ec5f50d0c9b3d192859f41a
StudentDevs/examples
/week1/2.py
1,958
4.8125
5
""" Tutorials on sqlite (quickly grabbed off google, there may be better ones): https://stackabuse.com/a-sqlite-tutorial-with-python/ https://pynative.com/python-sqlite/ """ import sqlite3 def main(): print('Connecting') conn = sqlite3.connect(':memory:') # Configure the connection so we can use the res...
true
a268b45504f17b58cdf3e5537a47f68ec6e9faa3
3NCRY9T3R/H4CKT0B3RF3ST
/Programs/Python/bellman_ford.py
1,438
4.1875
4
#This function utilizes Bellman-Ford's algorithm to find the shortest path from the chosen vertex to the others. def bellman_ford(matrix, nRows, nVertex): vertex = nVertex - 1 listDist = [] estimation = float("inf") for i in range(nRows): if (i == vertex): listDist.append(0) ...
true
8b8177c2acb317808a8e4808293cdc8b690f230f
NirajPatel07/Algorithms-Python
/insertionSort.py
376
4.125
4
def insertionSort(list1): for i in range(1,len(list1)): curr=list1[i] pos=i while curr<=list1[pos-1] and pos>0: list1[pos]=list1[pos-1] pos-=1 list1[pos]=curr list1=list(map(int, input("Enter Elements:\n").split())) print("Before Sorting:\n",list1) ...
true
2a575b03af1d4347b73917510fd275583fa674c3
GrandPa300/Coursera-RiceU-Python
/01_Rock-paper-scissors-lizard-Spock/Rock-paper-scissors-lizard-Spock.py
2,074
4.15625
4
# Mini Project 1 # Rock-paper-scissors-lizard-Spock # The key idea of this program is to equate the strings # "rock", "paper", "scissors", "lizard", "Spock" to numbers # as follows: # # 0 - rock # 1 - Spock # 2 - paper # 3 - lizard # 4 - scissors # helper functions import random def number_to_name(number): # fil...
true
66dca308dded21abc0509cd24802891564c63c0d
Taylorsuk/Game-of-Hangman
/hangman.py
2,950
4.125
4
import random import re # import the wordlist txtfile = open('word_list.txt', 'r') wordsToGuess = txtfile.readlines() allowedGuesses = 7 incorrectGuesses = [] correctGuesses = [] randomWord = random.choice(wordsToGuess).strip() guessWord = [] maskCharacter = '*' # we have a random word so we can now start the game pr...
true
78182f8b7eeed49d51da5ad194732dbee021ddf4
aiqingr/python-lesson
/pythonProject/python1/inputExample.py
319
4.21875
4
# num_input = input("Input a number") # print(num_input ** 2) # First two line will popup an error because the input function always return a string # This will be Method One # num_input_1 = input("input a number: ") # print(int(num_input_1) ** 2) num_input_2 = int(input("input a number: ")) print(num_input_2 ** 2)
true
41aed98b579dcc9e7621c9356685aacc33fcf7e9
fivaladez/Learning-Python
/EJ10_P2_Classes.py
981
4.28125
4
# EJ10_P2 Object Oriented - Classes # Create a class class exampleClass: eyes = "Blue" age = 22 # The first parameter MUST be self to refers to the object using this class def thisMethod(self): return "Hey this method worked" # This is called an Object # Assign the class to an a variabl...
true
ebbdc407c8e93e02618d8aec68213b2229de61ec
fivaladez/Learning-Python
/EJ21_P2_Lambda.py
1,006
4.375
4
# EJ21_P2 Lambda expression - Anonymous functions # Write function to compute 3x+1 def f(x): return 3*x + 1 print f(2) # lambda input1, input2, ..., inputx: return expression in one line print lambda x: 3*x + 1 # With the above declaration we still can not use the function, # we need a name, so, we can do the...
true
99002d0f430011ee9f40ac32feac98b84b435544
fivaladez/Learning-Python
/EJ11_P2_SubClasses_SuperClasses.py
1,065
4.40625
4
# EJ11_P2 Object Oriented - subClasses and superClasses # SuperClass class parentClasss: var1 = "This is var1" var2 = "This is var2 in parentClass" # SubClass class childClass(parentClasss): # Overwrite this var in this class var2 = "This is var2 in childClass" myObject1 = parentClasss() prin...
true
3194e6d5a08128b1eb943b29f579bf3bf72b1d68
tanish522/python-coding-prac
/stack/stack_1.py
415
4.15625
4
# stack using deque from collections import deque stack = deque() # append() function to push element in the stack stack.append("1") stack.append("2") stack.append("3") print('Initial stack:') print(stack) # pop() fucntion to pop element print('\nElements poped from stack:') print(stack.pop()) print...
true
2e1f82907b455f15ddaa77b4a3841c2dd61f6de5
ArsenArsen/claw
/claw/interpreter/commands/cmd_sass.py
1,764
4.125
4
""" Takes the given input and output directories and compiles all SASS files in the input into the output directory The command takes three parameters, namely target, directory, and glob: sass <source> <target> [style] The source parameter is relative to the claw resource directory The target parameter is where th...
true
649df4c7b9f19ab38d3924cd2dc68f956b70f90b
iEuler/leetcode_learn
/q0282.py
1,461
4.28125
4
""" 282. Expression Add Operators https://leetcode.com/problems/expression-add-operators/ Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value. Example 1: Input: num = "123", ta...
true
444ef66071c458cf92cfff248f813ab29608c91e
Prashant1099/Simple-Python-Programs
/Count the Number of Digits in a Number.py
318
4.15625
4
# The program takes the number and prints the number of digits in the number. n = int(input("\nEnter any Number = ")) count = 0 temp = n while (n>0): n //= 10 count += 1 print("-----------------------------------") print("Number of Digits in ",temp, " = ",count) print("-----------------------------------")
true
b8da10fe0d52d9d8ff08344c4bc8d3465b8f3e6d
atifahsan/project_euler
/p1.py
275
4.21875
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. numbers = [i for i in range(1, 1000) if not i % 3 or not i % 5] print(sum(numbers))
true
1179247685bb98e5de3d5de793ba677670d18e55
ananth-duggirala/Data-Structures-and-Algorithms
/Arrays and Strings/reverse_string.py
338
4.28125
4
""" Problem statement: Reverse a string. """ def reverseString(string): newString = "" n = len(string) for i in range(n): newString += string[n-1-i] return newString def main(): string = input("This program will reverse the entered string. \n\nEnter string: ") print(reverseString(string)) if __name__ == "_...
true
8af2e44e30d2e180e9b16f63c69d2d53d6a1594b
Suman196pokhrel/TkinterPractice
/more_examples/m7e_canvas_and_mouse_events.py
2,551
4.3125
4
""" Example showing for tkinter and ttk how to: -- Capture mouse clicks, releases and motion. -- Draw on a Canvas. Authors: David Mutchler and his colleagues at Rose-Hulman Institute of Technology. """ import tkinter from tkinter import ttk class PenData(object): def __init__(self): self.co...
true
d6577d3cba76440597da1653413a156453e16514
maainul/Python
/pay_using_try_catch.py
244
4.125
4
try: Hours=input('Enter Hours:') Rates=input('Enter Rates:') if int(Hours)>40: pay=40*int(Rates)+(int(Hours)-40)*(int(Rates)*1.5) print(pay) else: pay=int(Hours)*int(Rates) print(pay) except: print('Error,Please enter numeric input.')
true
dc54502a549f56b66637befa2cbf522f744357c0
maainul/Python
/Centimeter_to_feet_and_inch.py
265
4.125
4
cm=int(input("Enter the height in centimeters:")) inches=0.394*cm feet=0.0328*cm print("The length in inches",round(inches,2)) print("The length in feet",round(feet,2)) OUTPUT: Enter the height in centimeters:50 The length in inches 19.7 The length in feet 1.64
true
4719c9d94b43e37e25802ebdb2f92a8eaeb735a8
sudheer-sanagala/intro-python-coursera
/WK-03-Loops/while_loops.py
2,178
4.3125
4
# while loops x = 0 while x < 5: print("Not there yet, x =" + str(x)) x = x + 1 print("x = "+str(x)) #current = 1 def count_down(start_number): current = start_number while (current > 0): print(current) current -= 1 #current = current -1 print("Zero!") count_down(3) """ Print prime numbers A...
true
dd0c19ae77a22d440a86212bb03966d240c56b91
Robbot/ibPython
/src/IbYL/Classes/Polymorphism.py
1,050
4.1875
4
''' Created on 16 Apr 2018 @author: Robert ''' class network: def cable(self): print('I am the cable') def router(self): print('I am the router') def switch(self): print('I am the switch') def wifi(self): print('I am wireless router, cable does not matter') class tokenRing(network): de...
true
7999ace79084e36c7190d8a1bd42eca5daad30f6
leon-sleepinglion/daily-interview-pro
/014 Number of Ways to Climb Stairs/main.py
413
4.15625
4
''' If we look at the solution as a function f(n) where n = number of steps f(1) = 1 f(2) = 2 f(3) = 3 f(4) = 5 f(5) = 8 f(6) = 13 This is in fact a fibonacci sequence! Hence the solution can be implemented as a function that calculates the (n+2)th fibonacci number ''' def staircase(n): x = [0,1] for i in range(n):...
true
0493b5cd7e50e3b1acd3487d7f0db5c13e9c6e15
AT1924/Homework
/hw10/functional.py
1,772
4.15625
4
class InvalidInputException(Exception): def __str__(self): return "Invalid Input Given." def apply_all(f_list, n): """apply_all: [function], number -> [number] Purpose: applies each function in a list to a single number Consumes: a list of functions and a number Produces: a list of numbers ...
true
33655816cfafa233b306d61f4534338cebeced0a
Lord-Gusarov/holbertonschool-higher_level_programming
/0x06-python-classes/1-square.py
514
4.21875
4
#!/usr/bin/python3 """ Task 1 Write a class Square that defines a square by >Private instance attribute: size >Instantiation with size (no type/value verification) >You are not allowed to import any module """ class Square: """ A class that defines a Square """ def __init__(self, size): """I...
true
3f48b004bfa01617330bbcc06c11751187786c86
Lord-Gusarov/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-write_file.py
319
4.1875
4
#!/usr/bin/python3 """Task: Write to a file """ def write_file(filename="", text=""): """writes to a file, overtwiting it if it exist Args: filename (str): desire name of the output file text (str): what is to be written """ with open(filename, 'w') as f: return f.write(text)
true
f636dc47edfa679588c09af316acb7a9fc07db5e
Lord-Gusarov/holbertonschool-higher_level_programming
/0x06-python-classes/2-square.py
960
4.46875
4
#!/usr/bin/python3 """Task2 Write a class Square that defines a square by Private instance attribute: size Instantiation with optional size: def __init__(self, size=0): Size must be an integer, otherwise raise a TypeError exception with the message size must be an integer If size is less than 0, raise a V...
true
e38e998dba656061bb5af65d2cd338e0bd30de8b
xinyifuyun/-Python-Programming-Entry-Classic
/chapter_three/02.py
310
4.21875
4
a = ("first", "second", "third") print("The first element of the tuple is %s" % a[0]) print("The second element of the tuple is %s" % a[1]) print("The third element of the tuple is %s" % a[2]) print("%d" % len(a)) print(a[len(a) - 1]) b = (a, "b's second element") print(b[1]) print(b[0][0]) print(b[0][2])
true
b050f7dcbcc0a529ec03ac638af6c04cac4e6026
Aneeka-A/Basic-Python-Projects
/addition_problems.py
1,561
4.5625
5
""" File: addition_problems.py ------------------------- This piece of code will create addition problems (with 2 digit numbers). New problems will continue to be displayed until the user gets 3 correct answes in a row. """ import random # Declaring the minimum and the maximum numbers that can appear in the question. ...
true
d001674dd6a054da8536bdfb8565cb423a5e49e2
Onselius/mixed_projects
/factors.py
741
4.34375
4
#! /usr/bin/python3 # factors.py # Finding out all the factors for a number. import sys def check_args(): if len(sys.argv) != 2: print("Must enter a number") sys.exit() elif not sys.argv[1].isdigit(): print("Must enter a number") sys.exit() else: return True check...
true
882145ab3ef396f1cf082b5a6e912dad48597167
chnandu/practice-problems
/string-problems/unique_chars.py
644
4.25
4
#!/usr/bin/python # Check if given string has all unique characters or not def check_uniqueness(str_): """Check if given string has all unique characters and return True :param str_: Given string :returns: True, if all characters are unique. Else, False. """ char_dict = {} for c in str_: ...
true
4327f65151e2054c6ece88b694faa02ec3449d09
Shaaban5/Hard-way-exercises-
/py files/ex9+10.py
897
4.15625
4
days = "Mon Tue Wed Thu Fri Sat Sun" months = "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\tso on" # \n print in new line & \t print tap print "Here are the days: ", days print "Here are the months: ", months print """ There's something going on here. With the three double- quotes. We'll be able to type as...
true
44f95e83ddebe7cf08f73ca9c9e66e4307b1ae58
Shaaban5/Hard-way-exercises-
/py files/ex27+28.py
1,613
4.1875
4
print True and True # T print False and True # F print 1 == 1 and 2 == 1 # F print "test" == "test" # T print '\n' print 1 == 1 or 2 != 1 # T print True and 1 == 1 # T print False and 0 != 0 # F print True or 1 == 1 # T print '\n' print "test" == "testing" # F print 1 != 0 and 2 == 1 # F print "test" != "te...
true
9fd35de9093f9f05025455b55fb72eb32d2f698d
AsmitaKhaitan/Coding_Challenge_2048
/2048_game.py
1,920
4.40625
4
#importing the Algorithm.py file where all the fuctions for the operatins are written import Algorithm import numpy as np #Driver code if __name__=='__main__': #calling start() function to initialize the board board= Algorithm.start() while(True): t = input("Enter the number (move) of your cho...
true
1978e3ac3665e1c5b096ee01da1da17a967873cd
ckitay/practice
/MissingNumber.py
998
4.3125
4
# All numbers from 1 to n are present except one number x. Find x # https://www.educative.io/blog/crack-amazon-coding-interview-questions # n = expected_length # Test Case 1 , Expect = 6 from typing import List from unittest import TestCase class Test(TestCase): def test1(self): self.assertEqual(find_mi...
true
452b696d838bfd7d77b0c02ea9129f168d6b1786
SuproCodes/DSA_PYTHON_COURSE
/OOP.py
1,994
4.125
4
class Employee: def __init__(self, name): self.name = name def __repr__(self): return self.name john = Employee('John') print(john) # John #---------------------------- # Dog class class Dog: # Method of the class def bark(self): print("Ham-Ham") # Create a new instance charlie = Dog() # C...
true
f6e13f9d47f8524f63c175d086f49de917c678d4
vipin-s0106/DataStructureAndAlgorithm
/Linkedlist/reverse_linked_list.py
1,465
4.125
4
class Node: def __init__(self, data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def add(self, data): new_node = Node(data) if self.head is None: self.head = new_node else: temp = self.h...
true
fd879e688bc00a100698b5f53fcf5731c22ebcd4
AlanAloha/Learning_MCB185
/Programs/completed/at_seq_done.py
694
4.1875
4
#!/usr/bin/env python3 import random #random.seed(1) # comment-out this line to change sequence each time # Write a program that stores random DNA sequence in a string # The sequence should be 30 nt long # On average, the sequence should be 60% AT # Calculate the actual AT fraction while generating the sequence # Rep...
true
01d632d6197fb44a76eadc59fba2ea73f48d3c70
jptheepic/Sudoku_Solver
/main.py
2,359
4.21875
4
#The goal of this project is to create a working sudoku solver #This solution will implement recustion to solve the board #This function takes in a 2D array and will print is as a sudoku board def print_board(board): for row in range(0,len(board)): for col in range(0,len(board)): #prints the boarder for ...
true
959f6649dcedb7c3521a54fcf325126b3a5cc4b9
Lamchungkei/Unit6-02
/yesterdays.py
830
4.3125
4
# Created by: Kay Lin # Created on: 28th-Nov-2017 # Created for: ICS3U # This program displays entering the day of the week then showing the order from enum import Enum # an enumerated type of the days of the week week = Enum('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') # inp...
true
854300cb49d11a58f9b72f1f3a59d4a12012cd9c
jb3/aoc-2019
/day-3/python/wire.py
1,486
4.15625
4
"""Structures relating to the wire and points on it.""" import typing from dataclasses import dataclass @dataclass class Point: """Class representing a point in 2D space.""" x: int y: int def right(self: "Point") -> "Point": """Return a new point 1 unit right of the point.""" return ...
true
647d1d36759511e86ef6434c8a59daf7b345e888
AnushSomasundaram/Anush_Python_projects
/Anush_assignments/1st_sem/python/first assignment/area_of_triangle.py
221
4.15625
4
#Write a program to find the area of triangle given # base and height. def area_of_triangle(height,base): area = 0.5*height*base print("The area of the given trianle is ",area,"units.") area_of_triangle(1,6)
true
1c527311d782ceeec6e04e27d6f4b70e0532f9e4
AnushSomasundaram/Anush_Python_projects
/chap4_fuctions/lambda.py
458
4.25
4
#lambda functions are just inline functions but specified with the keyword lambda def function_1(x):return x**2 def function_2(x):return x**3 def function_3(x):return x**4 callbacks=[function_1,function_2,function_3] print("\n Named Functions") for function in callbacks: print("Result:",function(3)) callbacks=\ ...
true
3b9a3df013329cc99b8ac392ca6d1f2c1bbcbcde
AnushSomasundaram/Anush_Python_projects
/compsci_with_python/chap2/largestword.py
310
4.125
4
length= int(input("Enter the number of elements in the list")) words=[] for i in range (0,length): print("Word no.",i,":-") words.append(str(input())) longest=0 for i in range (1,length): if len(words[i])>len(words[longest]): longest=i print("longest word is :-",words[longest])
true
cb7875e93bb7619218691f2beba46a87f691d96c
AnushSomasundaram/Anush_Python_projects
/Anush_assignments/1st_sem/python/first assignment/operations.py
598
4.125
4
"""Write a Python program that allows the user to enter two integer values, and displays the results when each of the following arithmetic operators are applied. For example, if the user enters the values 7 and 5, the output would be, 7+5=12 7-5=2 and so on.""" number1=int(input("Please enter the first integer:-")) ...
true
76d43d9bc8db00125fde1eb88ffb25d7546b43c8
MithilRocks/python-homeworks
/bitwise_homework/divisible_by_number.py
399
4.3125
4
# hw: wtp to check if a number is multiple of 64 def divisible_by_number(num): if num & 63 == 0: return True else: return False def main(): number = 128 if divisible_by_number(number): print("The number {} is divisble by 64".format(number)) else: print("The number {}...
true
0880f00fcc0cda49c2cbd4de54e5ed0969156f3b
MYadnyesh/Aatmanirbhar_program
/Week 1/add.py
512
4.15625
4
#Program 1:- Addition of 2 numbers def add(x,y): print("The addition is : ") return x+y while True: print(add(int(input("Enter 1st number: ")),int(input("Enter 2nd number: ")))) a=input("Do you want to continue (Press Y to continue)") if(a=='y' or a=='Y') is True: continue else: ...
true
b45735562a84f066be681ba592a610118e6da06c
MYadnyesh/Aatmanirbhar_program
/Week 1/primeIntr.py
633
4.1875
4
#Program 2 :- To print all the Prime numbers in an given interval lower = int(input("Enter a starting number")) upper = int(input("Enter a ending number ")) print("Prime numbers between", lower, "and", upper, "are:") for num in range(lower, upper + 1): if num > 1: for i in range(2, num): if (num ...
true
a177115cde3a19cf9e2397aa844610b5a62ffb0c
CIS123Sp2020A/extendedpopupproceed-tricheli
/main.py
614
4.21875
4
#Tenisce Richelieu from tkinter import import tkinter.messagebox as box #The first step after imports is crate a window window = Tk() #This shows up at the top of the frame window.title('Message Box Example') #create the dialog for the window def dialog(): var = box. askyesno('Message Box', 'Proceed?') if ...
true
7ec6c5f2363d20cdd567aff4f9cc48718e77f895
silastsui/pyjunior
/strloops/backwards.py
551
4.15625
4
#!/usr/bin/python #backwards text = str(raw_input("Enter a phrase: ")) #solution1 (wat) print text[::-1] #solution2 (for x in range) reverse = "" a = len(text) for x in range(len(text)-1, -1,-1): reverse += text[x] print reverse #solution3 (for let in text) backwards = "" for let in text: backwards = let + backw...
true
1802b34d83cbfb6b9026a99c6e30da00d950fa5c
strikingraghu/Python_Exercises
/Ex - 04 - Loops.py
2,676
4.125
4
""" In general, statements are executed sequentially. The first statement in a function is executed first, followed by the second, and so on. There may be a situation when you need to execute a block of code several number of times. Programming languages provide various control structures that allow...
true
d5d43273000fb4a88b57e33c5fa7377264f2a707
strikingraghu/Python_Exercises
/Ex - 14 - File Handling.py
1,925
4.53125
5
""" In this article, you'll learn about Python file operations. More specifically, opening a file, reading from it, writing into it, closing it and various file methods. """ import os # Opening File file_open = open("c:/python_file.txt") print(file_open) # We can see the path of file, mode of oper...
true
5fa07f44836ffb22fcd8a237bc1cf8e572c154ac
strikingraghu/Python_Exercises
/Ex - 08 - Tuples.py
2,146
4.28125
4
""" A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. Differences between tuples and lists are, the tuples cannot be changed unlike lists! Also, tuples use parentheses, whereas lists use square brackets. """ sample_tuple_01 = ('Ram', 3492, 'Suresh') sample...
true
041fa7d58b4c8916abf660eb1bfa82ff8f1b0b6f
SaketSrivastav/epi-py
/trees/check_bst.py
1,156
4.1875
4
#! /usr/bin/python class Check_Bst(): def check_balanced(self, node): """ Input: A tree node Output: (+)ve number if BST is balanced, otherwise -1 Description: Start with root node and calculate the height of the left subtree and right subtree. If an absolute difference of...
true
454081e675b5dfb9a82293d3a79fa2ff90be90fc
rakibkuddus1109/pythonClass
/polymorphism.py
763
4.375
4
# polymorphism : Many ways to define the method # Method overloading # Method overriding # Method overloading: Considering relevant methods based upon no. of arguments that method has # even though the method names are same # Python doesn't support method overloading # class Operation: # def mul(self,a,...
true
99355f7b9957a8dcd2c176e4436969861e571a2b
rakibkuddus1109/pythonClass
/exception_handling.py
1,837
4.34375
4
# Exception Handling: Handling the exception or error # In-built exception : comes with programming language itself # User-defined exception : setting up our own defined exception # In-built exception: # a = [6,5.6,'Python',0,67] # for j in a: # print(1/j) # this would give in-built exception when 'Pyt...
true