blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
98269365703f82e15da200949483316583454b29
lshpaner/python-datascience-cornell
/Writing Custom Python Functions, Classes, and Workflows/Simple Ciphers With Lists and Dictionaries/exercise.py
2,492
4.59375
5
""" Simple Ciphers With Lists and Dictionaries Author: Leon Shpaner Date: August 14, 2020 """ # Examine the starter code in the editor window. # We first define a character string named letters which includes all the # upper-case and lower-case letters in the Roman alphabet. # We then create a dictionary (using a ...
true
bcdb572bcbba2ed318e0d0d9121285be989d6621
lastcanti/effectivePython
/item3helperFuncs.py
848
4.4375
4
# -----****minimal Python 3 effective usage guide****----- # bytes, string, and unicode differences # always converts to str def to_str(bytes_or_str): if isinstance(bytes_or_str, bytes): value = bytes_or_str.decode('utf-8') else: value = bytes_or_str return value # always converts to bytes...
true
6e27535bde7a1978b86b9d03381e72a745af83ed
VladislavRazoronov/Ingredient-optimiser
/examples/abstract_type.py
1,520
4.28125
4
class AbstractFood: """ Abstract type for food """ def __getitem__(self, value_name): if f'_{value_name}' in self.__dir__(): return self.__getattribute__(f'_{value_name}') else: raise KeyError('Argument does not exist') def __setitem__(self, value_name, ...
true
6c291c935764c099d5c861d070780800d69d965d
HOL-BilalELJAMAL/holbertonschool-python
/0x0B-python-inheritance/11-square.py
1,102
4.28125
4
#!/usr/bin/python3 """ 11-square.py Module that defines a class called Square that inherits from class Rectangle and returns its size Including a method to calculate the Square's area Including __str__ method to represent the Square """ Rectangle = __import__('9-rectangle').Rectangle class Square...
true
da4284aa2521689c430d51e0c275b40f2f86348d
HOL-BilalELJAMAL/holbertonschool-python
/0x0C-python-input_output/0-read_file.py
393
4.125
4
#!/usr/bin/python3 """ 0-read_file.py Module that defines a function called read_file that reads a text file (UTF8) and prints it to stdout """ def read_file(filename=""): """ Function that reads a text file and prints it to stdout Args: filename (file): File name """ with ope...
true
0bbcccf7cb91667ab15a317c53ac951c900d93a6
HOL-BilalELJAMAL/holbertonschool-python
/0x0B-python-inheritance/10-square.py
819
4.28125
4
#!/usr/bin/python3 """ 10-square.py Module that defines a class called Square that inherits from class Rectangle and returns its size Including a method to calculate the Square's area """ Rectangle = __import__('9-rectangle').Rectangle class Square(Rectangle): """ Represents a class called Re...
true
adee2a41e59f94a940f45ebbf8fddb16582614a6
sonsus/LearningPython
/pywork2016/arithmetics_classEx1018.py
1,334
4.15625
4
#Four arithmetics class Arithmetics: a=0 b=0 #without __init__, initialization works as declared above def __init__(self,dat1=0,dat2=0): a=dat1 b=dat2 return None def set_data(self,dat1,dat2): self.a=dat1 self.b=dat2 retur...
true
aa226fc06796e2e12132527b270f9671bd66bb55
annabalan/python-challenges
/Practice-Python/ex-01.py
489
4.25
4
#Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. def aging(): name = input("Enter your name: ") age = int(input("Enter your age: ")) number = int(input("Enter a number: ")) year = st...
true
bc917efa9ab9aef3260e21326d9c10c7f51cbc0e
strawhatasif/python
/calculate_average_rainfall.py
2,396
4.5
4
# This program calculates and displays average rainfall based on rainfall amounts per month entered by the user. # constant for number of months in a year NUMBER_OF_MONTHS_IN_YEAR = 12 # stores the number of years entered by the user number_of_years = int((input('Please enter the number of years: '))) # if the initi...
true
e6c7ddd18304dd9cb6fadb4d98058483494c0300
strawhatasif/python
/commission_earned_for_investor.py
2,983
4.34375
4
# This program tracks the purchase and sale of stock based on investor input. # constant percentage for how much commission an investor earns. COMMISSION_RATE = 0.03 # PURCHASE OF STOCK SECTION # Stores the name of the investor when entered. investor_name = input('What is your name? ') # Stores the number of shares ...
true
6fc6becc03fbd9d920f80033889746e04d5852ed
justintuduong/CodingDojo-Python
/Python/intro_to_data_structures/singly_linked_lists.py
1,957
4.125
4
class SLNode: def __init__ (self,val): self.value = val self.next = None class SList: def __init__ (self): self.head = None def add_to_front(self,val): new_node = SLNode(val) current_head = self.head #save the current head in a variable new_node.next = c...
true
5457e1f66077f12627fd08b2660669b21c3f34d3
AmonBrollo/Cone-Volume-Calculater
/cone_volume.py
813
4.28125
4
#file name: cone_volume.py #author: Amon Brollo """Compute and print the volume of a right circular cone.""" import math def main(): # Get the radius and height of the cone from the user. radius = float(input("Please enter the radius of the cone: ")) height = float(input("Please enter the height of the ...
true
e93a9c53e043b7c1689f8c5c89b6365708153861
diamondhojo/Python-Scripts
/More or Less.py
928
4.21875
4
#Enter min and max values, try to guess if the second number is greater than, equal to, or less than the first number import random import time min = int(input("Enter your minimum number: ")) max = int(input("Enter your maximum number: ")) first = random.randint(min,max) second = random.randint(min,max) print ("The...
true
01d4ea985f057d18b978cdb28e8f8d17eac02a6d
matthew-kearney/cs-module-project-recursive-sorting
/src/sorting/sorting.py
1,938
4.28125
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [0] * elements # Your code here index_a = 0 index_b = 0 # Iterate through all indices in merged array for i in range(elements): # Make sure that...
true
00b7d2b18548c195bedf516c25a3eda1f4a169ed
Joewash1/password
/Password2-2.py
596
4.21875
4
s=input("please enter your password :: ") Password = str( 'as1987Jantu35*^ft$TTTdyuHi28Mary') if (s == Password): print("You have successfully entered the correct password") while (s != Password): print("Hint:1 The length of your password is 32 characters") s=input("please enter your password :: ") if(...
true
bdb4ad158aeda38ada8f2ca88850aab3338393b4
elrosale/git-intro
/intro-python/part1/hands_on_exercise.py
1,140
4.3125
4
"""Intro to Python - Part 1 - Hands-On Exercise.""" import math import random # TODO: Write a print statement that displays both the type and value of `pi` pi = math.pi print(type(pi), (pi)) # TODO: Write a conditional to print out if `i` is less than or greater than 50 i = random.randint(0, 100) if i < 50: ...
true
277001f219bf21982133779920f98e4b77ca9ec0
DeLucasso/WePython
/100 days of Python/Day3_Leap_Year.py
465
4.3125
4
year = int(input("Which year do you want to check? ")) # A Leap Year must be divisible by four. But Leap Years don't happen every four years … there is an exception. #If the year is also divisible by 100, it is not a Leap Year unless it is also divisible by 400. if year % 4 == 0: if year % 100 == 0: if year % 4...
true
435f96309f8dbcc0ebf5de61390aae7f06d4d7e9
ashwin1321/Python-Basics
/exercise2.py
1,541
4.34375
4
##### FAULTY CALCULATOR ##### def calculetor(): print("\nWellcome to Calc:") operation = input(''' Please type in the math operation you would like to complete: + for addition - for subtraction * for multiplication / for division ** for power % for modulo Enter...
true
1b022a05c38b11750eeb5bc824ea2968628533a5
ashwin1321/Python-Basics
/lists and its function.py
1,724
4.625
5
########## LISTS ####### # list is mutable, we can replace the items in the lists ''' grocery = [ 'harpic', ' vim bar', 'deodrant', 'bhindi',54] # we can include stirng and integer together in a list print(grocery) print(grocery[2]) ''' ''' numbers = [12,4,55,16,7] # list can also be...
true
53b0a04657a620aaaf20bfee9f8a5b8e9b08e322
ashwin1321/Python-Basics
/oops10.public, protected and private.py
1,231
4.125
4
class Employee: no_of_leaves = 8 # This is a public variable having access for everybody inside a class var = 8 _protec = 9 # we write a protected variable by writing "_" before a variable name. Its accessi...
true
0209c76a48557122b10eaedbac5667641078a631
jvansch1/Data-Science-Class
/NumPy/conditional_selection.py
292
4.125
4
import numpy as np arr = np.arange(0,11) # see which elements are greater than 5 bool_array = arr > 5 #use returned array of booleans to select elements from original array print(arr[bool_array]) #shorthand print(arr[arr > 5]) arr_2d = np.arange(50).reshape(5,10) print(arr_2d[2:, 6:)
true
dc914377bfebde9b6f5a4e2b942897d4cd2a8e25
lilimehedyn/Small-projects
/dictionary_practice.py
1,082
4.125
4
#create a dict study_hard = {'course': 'PythonDev', 'period': 'The first month', 'topics': ['Linux', 'Git', 'Databases','Tests', 'OOP'] } # add new item study_hard['tasks'] = ['homework', 'practice online on w3resourse', 'read about generators', 'pull requests', 'peer-review', 'status', 'feedbac...
true
97dce44d9bdd9dfad2fd37f8e79d5956f6c64bd0
Vagacoder/LeetCode
/Python/DynamicProgram/Q0122_BestTimeBuySellStock2.py
2,454
4.15625
4
# # * 122. Best Time to Buy and Sell Stock II # * Easy # * Say you have an array prices for which the ith element is the price of a given # * stock on day i. # * Design an algorithm to find the maximum profit. You may complete as many # * transactions as you like (i.e., buy one and sell one share of the stock multi...
true
6396751b5e099078737ff179113ceda89fbce28c
dishashetty5/Python-for-Everybody-Functions
/chap4 7.py
743
4.40625
4
"""Rewrite the grade program from the previous chapter using a function called computegrade that takes a score as its parameter and returns a grade as a string. Score Grade >= 0.9 A >= 0.8 B >= 0.7 C >= 0.6 D < 0.6 F""" score=float(input("enter the score:")) def computegrade(score): try: if(scor...
true
dfe1b71f4bca7dc0438ae83fd418ad131fb8aba9
huzaifahshamim/coding-practice-problems
/Lists, Arrays, and Strings Problems/1.3-URLify.py
1,061
4.1875
4
""" Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters, and that you are given the "true" length of the string. (Note: if implementing in Java, please use a character array so that you can perform this operation i...
true
e294f151d8eaded0356ab30f0cc961a31aff3698
vishnuvs369/python-tutorials
/inputs.py
421
4.21875
4
# inputs name = input("Enter your name") email = input("Enter your email") print(name , email) #------------------------------------------------- num1 = input("Enter the first number") #The input number is in string we need to convert to integer num2 = input("Enter the second number") #num1 = int(input("Enter...
true
0bddc508ce2a5079507fdd0dbe4f55a0c09a2ef7
Joezeo/codes-repo
/python-pro/io_prac.py
508
4.15625
4
forbideen = ('!', ',', '.', ';', '/', '?', ' ') def remove_forbideen(text): text = text.lower() for ch in text: if ch in forbideen: text = text.replace(ch, '') return text def reverse(text): return text[::-1]# 反转字符串 def is_palindrome(text): return text == reverse(text) in...
true
6e83d95f12ae67d956867620574d63000b4ed848
famosofk/PythonTricks
/ex/dataStructures.py
800
4.40625
4
#tuples x = ('string', 3, 7, 'bh', 89) print(type(x)) #tuples are imatuble. This is a list of different types object. We create tuples using (). In python this would be listof y = ["fabin", 3, "diretoria", 8, 73] y.append("banana") print(type(y)) #lists are mutable tuples. We create lists using [] #both of them are ...
true
03dae7a8d59866b3c788c42fbc5c43a09d4e89ef
famosofk/PythonTricks
/2-DataStructures/week3/files.py
739
4.3125
4
# to read a file we need to use open(). this returns a variable called file handler, used to perform operations on file. #handle = open(filename, mode) #Mode is opcional. If you plan to read, use 'r', and use 'w' if you want to write #each line in file is treated as a sequence of strings, so if you want to print name ...
true
8a781a70cc04d0d89c28c3db8da5d5ee0e9b49da
AhmadAli137/Base-e-Calculator
/BorderHacks2020.py
1,521
4.34375
4
import math #library for math operation such as factorials print("==============================================") print("Welcome to the Exponent-Base-e Calculator:") print("----------------------------------------------") print(" by Ahmad Ali ") #Prompts print(" (BorderHacks 2020...
true
ee5ff425f61a596cc7edddb5bc3b11211cdc2e56
urandu/Random-problems
/devc_challenges/interest_challenge.py
938
4.21875
4
def question_generator(questions): for question in questions: yield question.get("short") + input(question.get("q")) def answer_questions(questions): output = "|" for answer in question_generator(questions): output = output + answer + " | " return output questions = [ { ...
true
c44ca53b2a11e083c23a725efcb3ac17df10d8ee
bowersj00/CSP4th
/Bowers_MyCipher.py
1,146
4.28125
4
alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] def shifter(start_string, shift): new_string="" for character in start_string: if character.isalpha(): new_string=new_string+(alphabet[(alphabet.index(character)+shift)%26]) ...
true
d86b80e7d3283ff2ee1b062e14539dbb87e34206
anillava1999/Innomatics-Intership-Task
/Task 2/Task3.py
1,778
4.40625
4
''' Given the names and grades for each student in a class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. Note: If there are multiple students with the second lowest grade, order their names alphabetically and print each name on a new line. Example ...
true
3664b39e29387cb4c7beb0413249014d34b132bc
Arsalan-Habib/computer-graphics-assignments
/mercedez-logo/main.py
1,719
4.21875
4
import turtle # initializing the screen window. canvas = turtle.Screen() canvas.bgcolor('light grey') canvas.title('Mercedez logo') # initializing the Turtle object drawer = turtle.Turtle() drawer.shape('turtle') drawer.speed(3) # Calculating the radius of the circumscribing circle of the triangle. # The formula is:...
true
49fb9f94501503eedfd7f5913efb3c8ffe656e68
Saij84/AutomatetheBoringStuff_Course
/src/scripts/12_guessNumber.py
968
4.3125
4
import random #toDo ''' -ask players name -player need to guess a random number between 1 - 20 -player only have 6 guesses -player need to be able to input a number -check need to be performed to ensure number us between 1 - 20 -check that player is imputing int -after input give player hint -"Your guess i...
true
d28b91aa36ee49eb6666a655e1ef9fb6239b1413
geisonfgf/code-challenges
/challenges/find_odd_ocurrence.py
701
4.28125
4
""" Given an array of positive integers. All numbers occur even number of times except one number which occurs odd number of times. Find the number in O(n) time & constant space. Input = [1, 2, 3, 2, 3, 1, 3] Expected result = 3 """ def find_odd_ocurrence(arr): result = 0 for i in xrange(len(arr)): ...
true
1758af802adc1bf5dbf6b10bf4c04fd19d48e975
mk9300241/HDA
/even.py
209
4.34375
4
#Write a Python program to find whether a given number (accept from the user) is even or odd num = int(input("Enter a number:")) if (num%2==0): print(num," is even"); else: print(num," is odd");
true
3c16a7d51658806c1233e14640f6ce6d3cabda12
voksmart/python
/QuickBytes/StringOperations.py
1,601
4.125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 11 13:35:40 2019 @author: Mohit """ # String Assignment str1 = "Hello" str2 = "John" # Checking String Length print("Length of String is :",len(str1)) # String Concatenation (join) print(str1 + " "+str2) # String Formatting # inserting name of guest a...
true
c5e7b72cabf084c40320d31eb089b93451d7072d
ErosMLima/python-server-connection
/average.py
217
4.375
4
num = int(input("how many numbers ?")) total_sum = 0 for n in range (num): numbers = float(input("Enter any number")) total_sum += numbers avg = total_sum / num print('The Average number is?'. avg)
true
3a926ac51f31f52184607c8e4b27c99b4cbb9fb8
AnujPatel21/DataStructure
/Merge_Sort.py
863
4.25
4
def merge_sort(unsorted_list): if len(unsorted_list) <= 1: return unsorted_list middle = len(unsorted_list) // 2 left_half = unsorted_list[:middle] right_half = unsorted_list[middle:] left_half = merge_sort(left_half) right_half = merge_sort(right_half) return list(merge(left_half,...
true
9fe71cad659e416a3c9349114ceebacae3895b15
12agnes/Exercism
/pangram/pangram.py
317
4.125
4
def is_pangram(sentence): small = set() # iterate over characters inside sentence for character in sentence: # if character found inside the set try: if character.isalpha(): small.add(character.lower()) except: raise Exception("the sentence is not qualified to be pangram") return len(small) == 26
true
c5a777c88c3e6352b2890e7cc21d5df29976e7e7
edwardcodes/Udemy-100DaysOfPython
/Self Mini Projects/turtle-throw/who_throw_better.py
1,371
4.3125
4
# import the necessary libraries from turtle import Turtle, Screen import random # Create custom screen screen = Screen() screen.setup(width=600, height=500) guess = screen.textinput(title="Who will throw better", prompt="Guess which turtle will throw longer distance?") colors = ["red", "orang...
true
73d4dbc12fed8bc83ac68f19a31a729283c9a05f
cascam07/csf
/hw2.py
2,244
4.34375
4
# Name: ... Cameron Casey # Evergreen Login: ... cascam07 # Computer Science Foundations # Programming as a Way of Life # Homework 2 # You may do your work by editing this file, or by typing code at the # command line and copying it into the appropriate part of this file when # you are done. When you are done, runnin...
true
8bbd6935cc49c5280a79327c61d90ffb2ef5889c
Skp80/mle-tech-interviews
/data-structure-challenges/leetcode/543. Diameter of Binary Tree.py
1,658
4.25
4
""" Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. The length of a path between two nodes is represented by the number of edges between ...
true
f0881f9ec77a982825071ed8106c4900278ac1a5
vuthysreang/python_bootcamp
/sreangvuthy17/week01/ex/17_str_last.py
625
4.40625
4
""" Description : You will write a program that ask for one string as and return the last character. If no argument is passed, display “Empty” Requirements : ● Program must be named : ​17_str_last.py​ and saved into​ week01/ex ​folder Hint : ❖ print function ❖ string ind...
true
b09cbe34ac66a41d58ab047f0dfbb6024c9a105e
vuthysreang/python_bootcamp
/Documents/week03/sreangvuthy17/week03/ex/45_auto_folder.py
2,173
4.46875
4
""" Description : You will create a program that take a list of string as argument, that represents folders names. Then, for each, you will create a folder with the corresponding name. Before create anything, you will check that the folders doesn’t already exists. ...
true
201dac84630f55ffceb24392cd58051b66e60495
vuthysreang/python_bootcamp
/sreangvuthy17/week01/ex/08_random.py
465
4.28125
4
""" Description : You will write a program that take display a random number between 1 and 100 Requirements : ● Program must be named : ​08_random.py​ and saved into​ week01/ex ​folder Hint : ❖ print function ❖ random """ # import random library import random # print random output between ...
true
421e2d5f4300102b66651efd180d3dbd6bf66a82
vuthysreang/python_bootcamp
/sreangvuthy17/week01/ex/06_odd_even.py
1,491
4.46875
4
""" Description : You will write a program that take will ask for a number in parameter and display ​“<number> is EVEN” or ​“number is ODD”​. If the number is not an integer, you will have to display ​“<input> is not a valid number.”​. If you enter ​“exit” ​or “EX...
true
926c19499256827be9c6f281257082f307432908
vuthysreang/python_bootcamp
/Documents/week03/sreangvuthy17/week03/ex/59_regex_html.py
1,235
4.1875
4
""" Description : You will create a function that take a string in parameter and remove every HTML content ( everything between ‘<’ and ‘>’ ) You will return the new formatted string. You need to do it using REGEX only. EXAMPLE : regex_html​("<html lang = 'pl' >...
true
a287483a91fa92fd183f524039b0255d4ea11f7d
vuthysreang/python_bootcamp
/sreangvuthy17/week02/ex/35_current_time.py
1,079
4.3125
4
""" Description : You will write a function that return the current time with the following format: hh:mm:ss The return value must be a string. Requirements : ● Program must be named : 35_current_time.py and saved into week02/ex folder Hint : ❖ function ❖ datetime Output : ...
true
0613d7beaa42dfe4acbccbcd93a154f788ba7c6f
vuthysreang/python_bootcamp
/sreangvuthy17/week03/ex/41_current_path.py
577
4.15625
4
""" Description : You will write a function that print the current path of your program folder, then you will return it as a string. Requirements : ● Program name : ​41_current_path.py ● Function name : ​current_path ● Directory : ​week03/ex ​folder Hint : ❖ ...
true
9e2f2ccb0e7c1f8103abb86d1581e24ca4d03f3d
aengel22/Homework_Stuff
/module12_high_low.py
2,532
4.21875
4
# The get_price function accepts a string that is assumed to be # in the format MM-DD-YYYY:Price. It returns the Price component # as a float. def get_price(str): # Split the string at the colon. items = str.split(':') # Return the price, as a float. return float(items[1]) # The get_year funct...
true
55ebfed116af1e9389e2a81d432a237b90e7262e
RecklessDunker/Codewars
/Get the Middle Character.py
789
4.25
4
# -------------------------------------------------------- # Author: James Griffiths # Date Created: Wednesday, 3rd July 2019 # Version: 1.0 # -------------------------------------------------------- # # You are going to be given a word. Your job is to return the middle character of the # word. If the word's length is ...
true
deec653fc1bbe1f2ff5d32d2970265a89e68b7b0
cthompson7/MIS3640
/Session01/hello.py
2,277
4.59375
5
print("Hello, Christian!") # Whenever you are experimenting with a new feature, you should try to make mistakes. For example, in the “Hello, world!” program, what happens if you leave out one of the quotation marks? What if you leave out both? What if you spell print wrong? print(Hello, world!") # When I leave out o...
true
e2ae0826393ebf746222d47506a538662f0c4016
cthompson7/MIS3640
/Session11/binary_search.py
1,069
4.28125
4
def binary_search(my_list, x): ''' this function adopts bisection/binary search to find the index of a given number in an ordered list my_list: an ordered list of numbers from smallest to largest x: a number returns the index of x if x is in my_list, None if not. ''' left = 0 right =...
true
d2c3f792c5b41ff79f7d6f7fa76c75317c6687be
aleperno/blog
/fibo.py
1,313
4.25
4
#!/usr/bin/python import time def recursiveFibo(number): """Recursive implementation of the fibonacci function""" if (number < 2): return number else: return recursiveFibo(number-1)+recursiveFibo(number-2) def iterativeFibo(number): list = [0,1] for i in range(2,number+1): list.append(list[i-1]+list[i-2])...
true
7850a710550a6bba787f81b5945d70098c60ba14
jradd/small_data
/emergency_map_method.py
518
4.46875
4
#!/usr/bin/env python ''' the following is an example of map method in python: class Set: def __init__(self, values=None): s1 = [] # s2 = Set([1,2,2,3]) self.dict = {} if values is not None: for value in values: self.add(value) def __repr__(self): return "Set: " + str(self.dic...
true
925ffcfcff7df4ee4db086783374321ee32f092a
Andreabrian/python-programming-examples-on-lists
/assign1.py
295
4.21875
4
#find the largest number in the list. a=[] n=int(input("Enter the number of elements:")) for i in range(n): a.append(int(input("enter new element:"))) print(a) s=a[0] for i in range(1,len(a)): if a[i]>s: s=a[i] y=("the largest number is: ") print(y,s)
true
5f498fc6d83701963d4800d121630523e805568b
chriskok/PythonLearningWorkspace
/tutorial11-tryelsefinally.py
1,333
4.4375
4
# ---------- FINALLY & ELSE ---------- # finally is used when you always want certain code to # execute whether an exception is raised or not num1, num2 = input("Enter to values to divide : ").split() try: quotient = int(num1) / int(num2) print("{} / {} = {}".format(num1, num2, quotient)) except ZeroDivision...
true
1d1b0213e352a561d37417353719711b31bd3de4
chriskok/PythonLearningWorkspace
/primenumber.py
696
4.34375
4
# Note, prime can only be divided by 1 and itself # 5 is prime because only divided by 1 and 5 - positive factor # 6 is not a prime, divide by 1,2,3,6 # use a for loop and check if modulus == 0 True def is_prime(num): for i in range(2, num): if (num % i) == 0: return False return True d...
true
8d598dc40e8428a74f5668cc6b6a29a86214e9bd
chriskok/PythonLearningWorkspace
/pinetree.py
1,026
4.3125
4
# How tall is the tree: 5 # 1 while loop and 3 for loops # ### ##### ####### ######### # # 4 spaces: 1 hash # 3 spaces: 3 hashes # 2 spaces: 5 hashes # ... # 0 spaces: 9 hashes # Need to do # 1. Decrement spaces by 1 each time through the loop # 2. Increment the hashes by 2 each time through the loop #...
true
cd6759aa55356291bb5b1f277fd8f0a88f950be1
TapasDash/Python-Coding-Practice
/oddEvenList.py
519
4.1875
4
''' This is a simple programme which takes in input from the user as a series of numbers then, filter out the even and odd ones and append them in two different lists naming them oddList and evenList Input : 1,2,3,4,5,6 Output : oddList = [1,3,5] evenList = [2,4,6] ''' myList = [eval(x) for x in input("Enter ser...
true
04edbaa127a19c39abb58fc4ab009161ddd40aee
rexarabe/Python_Projects
/class_01.py
1,414
4.53125
5
"""Creating and using class """ #The car class class Car(): """ A simple attemt to model a car. """ def __init__(self, make, model, year): """Initialize car attributes.""" self.make = make self.model = model self.year = year #Fuel capacity and level in gallons. ...
true
b71c815fa1f8167c8594774745dfccef3931add9
mustafaAlp/StockMarketGame
/Bond.py
1,075
4.3125
4
#!/usr/bin/env python """ This module includes Bond class which is a subclass of the Item class. Purpose of the module to learn how to use inheritance and polymorphizm in the python. Its free to use and change. writen by Mustafa ALP. 16.06.2015 """ import random as ra from Item import Item # ...
true
76512e65fadd9589b50889cbf42b99f68686983e
andrewlehmann/hackerrank-challenges
/Python Data Structures/Compare two linked lists/compare_linked_lists.py
956
4.1875
4
#Body """ Compare two linked list head could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node return back the head of the linked list in the below method. """ def equalityCheck(first, ot...
true
f5090b41b7e5cb5e98c4dc3ac85f092df79000bd
iyoussou/CAAP-CS
/hw1/fibonacci.py
469
4.28125
4
#Prints a specific value of the Fibonacci Sequence. def main(): print("This program prints a specific term of the Fibonacci Sequence.") term = eval(input("Which term of the Fibonacci Sequence would you like?: ")) current = 1 previous = 0 old_previous = 0 for i in range(0, term-1): old_previous = previous ...
true
2212f3aa40b95de35bb686d7462c95119bc865be
idealgupta/pyhon-basic
/matrix1.py
310
4.1875
4
matrix =[ [3,4,5], [5,7,8], [4,9,7] ] print(matrix) transposed=[] #for colem for i in range(3): list=[] for row in matrix: list.append(row[i]) transposed.append(list) print(transposed) #same trans =[[row[i] for row in matrix] for i in range(3)] print(trans)
true
8646d28c0880d9b3851d0ec49e97ef259031bec3
akshitshah702/Akshit_Task_5
/# Task 5 Q3.py
436
4.21875
4
# Task 5 Q3 def mult_digits(): x = input("Enter number ") while type(x) is not int: try: while int(x) <= 1: x = input("Please enter a number greater than 1: ") x = int(x) except ValueError: x = input("P...
true
183b9a7d439dca14510d9257712d90d1adc8a515
ANTRIKSH-GANJOO/-HACKTOBERFEST2K20
/Python/QuickSort.py
801
4.125
4
def partition(array, low, high): i = (low - 1) pivot = array[high] for j in range(low, high): if array[j] <= pivot: i = i + 1 array[i], array[j] = array[j], array[i] array[i+1], array[high] = array[high], array[i+1] return (i + 1) def quickSort(array, low, high)...
true
c4f2ba0d605988bfcfb046c42e92b4ef216c0534
ANTRIKSH-GANJOO/-HACKTOBERFEST2K20
/Python/Merge_sort.py
916
4.28125
4
def merge_sort(unsorted_list): if len(unsorted_list) <= 1: return unsorted_list # Finding the middle point and partitioning the array into two halves middle = len(unsorted_list) // 2 left = unsorted_list[:middle] right = unsorted_list[middle:] left = merge_sort(left) right = merge_s...
true
6e3235205388258659eb7ac63925152e52267ed9
ANTRIKSH-GANJOO/-HACKTOBERFEST2K20
/Python/Insertion_sort.py
305
4.21875
4
def insertionSort(array): for index in range(1,len(array)): currentvalue = array[index] position = index while position>0 and array[position-1]>currentvalue: array[position]=array[position-1] position = position-1 array[position]=currentvalue return array
true
f48416b78c2e6a29a4b041b843cd8de5d280a2b0
anilgeorge04/cs50harvard
/python-intro/credit.py
1,958
4.25
4
# This software validates a credit card number entered by the user # Validity checks: Format, Luhn's checksum algorithm*, Number of digits, Starting digit(s) with RegEx # Output: It reports whether the card is Amex, Mastercard, Visa or Invalid # *Luhn's checksum algorithm: https:#en.wikipedia.org/wiki/Luhn_algorithm im...
true
0cf8dabae652848b5d0ac46fd753e0ee977630ee
AjayMistry29/pythonTraining
/Extra_Task_Data_Structure/ETQ8.py
831
4.1875
4
even_list=[] odd_list=[] while True: enter_input = int(input("Enter a number from from 1 to 50: ")) if enter_input>=1 and enter_input<=50 and (enter_input % 2) != 0 and len(odd_list)<5: odd_list.append(enter_input) print("Odd List :" ,odd_list) continue elif enter_input>=...
true
b7497ea31a107328ecb0242600df34d808483353
AjayMistry29/pythonTraining
/Task4/T4Q2.py
359
4.3125
4
def upperlower(string): upper = 0 lower = 0 for i in string: if (i>='a'and i<='z'): lower=lower+1 if (i>='A'and i<='Z'): upper=upper+1 print('Lower case characters = %s' %lower, 'Upper case characters = %s' %upper) string = input("E...
true
3fab33ec2b0ec5d95bcfefbab6c1b878d0c81daf
mrodzlgd/dc-ds-071519
/Warm_Ups/number_finder.py
766
4.25
4
def prime_finder(numbers): import numpy as np prime=np.array([]) """will select only the prime #'s from a given numpy array""" for n in np.nditer(numbers): if (n%2)>0: prime = np.append(prime,n) return prime #a series of numbers in which each number ( Fibonacci number ) ...
true
df78a002fdb80aa75916d98777f5036f53c24082
mariololo/EulerProblems
/problem41.py
1,162
4.25
4
""" We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? """ def is_pandigital(n): digits = [] for dig in str(n): if dig in digits: return ...
true
97cc0a8e13f2517cd8c55c0741cc5d94bfa4d7ea
AshTiwari/Standard-DSA-Topics-with-Python
/Array/Array_Merge_Sorted_Array_in_O(1)_Space.py
772
4.28125
4
# Merge two sorted array in O(1) time. from binaryInsertion import binaryInsertion ######### Increase the Efficiency by using binaryInsertion function to add element in sorted arr2 ########### def addElement(arr,element): index = 0 # alternate way is to use binaryInsertion. while(index < len(arr)-1): if arr[in...
true
835cfbcb2ebd756769226a1b3745427f70c17c50
LucioOSilva/HackerRankPython-PS
/LinkedList-PrintTheElementsOfALinkedList.py
1,868
4.375
4
""" If you're new to linked lists, this is a great exercise for learning about them. Given a pointer to the head node of a linked list, print its elements in order, one element per line. If the head pointer is null (indicating the list is empty), don’t print anything. Input Format: The first line of input contains "n"...
true
8db7becd41ea2f645a1f523a662ca9715da4121b
MrKonrados/PythonTraining
/Change Calculator/change_calc.py
1,369
4.3125
4
""" BASIC GOAL Imagine that your friend is a cashier, but has a hard time counting back change to customers. Create a program that allows him to input a certain amount of change, and then print how how many quarters, dimes, nickels, and pennies are needed to make up the amount needed. For example, if he inputs 1.47...
true
b017de724c850cdc2c2dd757d7508ee2083db0f6
lmitchell4/Python
/ch_3_collatz.py
428
4.3125
4
## Collatz sequence def collatz(number): if number % 2 == 0: print(number // 2) return(number // 2) else: print(3*number + 1) return(3*number + 1) inputOK = False while not inputOK: try: print('Enter an integer to start the Collatz sequence:') n = int(input()) inputOK = True excep...
true
a95914f8996bc96b2e60ca8951bdeaf3611652d5
igelritter/learning-python
/ex35-lphw.py
2,759
4.125
4
#This is basically a text style adventure. Each room is defined as a function #as well as the starting and dying text. #importing the exit function from sys import exit #gold room. def gold_room(): print "This room is full of gold. How much do you take?" next=(raw_input(">")) #This 'if/else' statement is brok...
true
95af2966515dd3cfca5459096762f8c0d5790ab3
dao-heart/Leetcode-solutions
/pythonDataStructures/llist.py
2,157
4.1875
4
# Linked List class Node: def __init__(self, data): self.data = data self.next = None ## Test the nodes n1 = Node("Mon") n2 = Node("Tues") n1.next = n2 print(n1) class LinkedList: print_list = [] def __init__(self): self.headval = None def __repr__(self): return "->".j...
true
06e0eeff8467efd1538056e984644ea665656c0c
mobbarley/python2x
/fizzbuzz.py
559
4.3125
4
# This program mocks the script for the game fizz - buzz where we print all the numbers # from 1 to the number entered by the user but we say Fizz when number is divisible by 3 # and Buzz when it is divisible by 5, when it is both like in 15, 30 etc we will say FizzBuzz num = int(raw_input("Enter a number : ")) if nu...
true
88663a9fba92b5e8ca7a0121d3fdfabea283cb05
cindygao93/Dartboard
/assignment 2 third try.py
2,469
4.1875
4
##this is a program in turtle that will draw a dart board from turtle import * def main() : shape("turtle") pendown() pencolor("yellow") pensize(5) speed(20) radius=200 subradius=0 forward(radius) left(90) sideCount = 0 color = "yellow" while sideCount <80: ...
true
8dc6e4c41403953b42dde18cfb626598815bcee7
rkuzmyn/DevOps_online_Lviv_2020Q42021Q1
/m9/task9.1/count_vowels.py
428
4.125
4
vowels = 'aeiou' def count_vowels(string, vowels): # casefold() it is how lower() , but stronger string = string.casefold() # Forms a dictionary with key as a vowel count = {}.fromkeys(vowels, 0) # To count the vowels for character in string: if character in count: count[...
true
d643bffc1fc1c1c029543510b66c5a0b1bc77377
slauney/Portfolio
/Python/InClassMarking/TC5/HighestCommonDivisor.py
2,611
4.125
4
########################################### # Desc: Highest Common Divisor # # Author: Zach Slaunwhite ########################################### def main(): #initialize the continue condition continueLoop = "y" #while continue loop is equal to y, repeat the program while(continueLoop == "y"): ...
true
6c85d89a5becfcce7df81801b3cd511c82b829b8
slauney/Portfolio
/Python/Labs/Lab04/ProvincialTaxes.py
2,194
4.21875
4
########################################### # Desc: Enter application description here. # # Author: Enter name here. ########################################### def main(): # Constants GST = 1.05 HARMONIZED_TAX = 1.15 # PROVINCIAL_TAX will be added onto GST to bring tax to 1.11 PROVINCIAL_TAX = 0....
true
df11e224537c2d5ea2aa747b7a71e12b0c4a975c
slauney/Portfolio
/Python/InClassMarking/TC2/taxCalculator.py
1,638
4.25
4
########################################### # Desc: Calculates the total amount of tax withheld from an employee's weekly salary (income tax?) # # Author: Zach Slaunwhite ########################################### def main(): # Main function for execution of program code. # Make sure you tab once for every li...
true
067ba4d62b07896b1a484dc7a47a39d9aba968e7
ggibson5972/Project-Euler
/euler_prob_1.py
232
4.15625
4
result = 0 #iterate from 1 to 1000 for i in range(1000): #determine if i is a multiple of 3 or 5 if ((i % 3 == 0) or (i % 5 == 0)): #if i is a multiple of 3 or 5, add to sum (result) result += i print result
true
052857681781833e79edd5eecb1e32b99f561749
chmod730/My-Python-Projects
/speed_of_light.py
944
4.375
4
''' This will query the user for a mass in kilograms and outputs the energy it contains in joules. ''' SPEED_OF_LIGHT = 299792458 # c in m/s2 TNT = 0.00000000024 # Equivalent to 1 joule def main(): print() print("This program works out the energy contained in a given mass using Einstein's famous equation:...
true
eb54fcd8f36e094f77bccdcebc0ae8230a2db34d
adneena/think-python
/Iteration/excercise1.py
1,142
4.25
4
import math def mysqrt(a): """Calculates square root using Newton's method: a - positive integer < 0; x - estimated value, in this case a/2 """ x = a/2 while True: estimated_root = (x + a/x) / 2 if estimated_root == x: return estimated_root break ...
true
3642cd6a682a9a05c2a5bc9c7597fd02af43a417
adneena/think-python
/Fruitiful-functions/excercise-3.py
856
4.34375
4
''' 1. Type these functions into a file named palindrome.py and test them out. What happens if you call middle with a string with two letters? One letter? What about the empty string, which is written '' and contains no letters? 2. Write a function called is_palindrome that takes a string argument and returns True if i...
true
5674ddd6d622dad21e14352332cdb85bf7adf9fc
adneena/think-python
/variables-expressions-statements/excercise1.py
520
4.375
4
''' Assume that we execute the following assignment statements: width = 17 height = 12.0 delimiter = '.' For each of the following expressions, write the value of the expression and the type (of the value of the expression). 1. width/2 2. width/2.0 3. height/3 4. 1 + 2 * 5 5. delimiter * 5 ''' width = 17 height = 12.0 ...
true
5327e3c6d6563e1fe25572b838f7274c7524c7ba
09jhoward/Revison-exercies
/task 2 temprature.py
482
4.15625
4
#08/10/2014 #Jess Howard #development exercises #write a program that reads in the temperature of water in a container(in centigrade and displays a message stating whether the water os frozen,boiling or neither. temp= int(input(" Please enter the water temprature in the unit of centigrade:")) if temp<= 0: pr...
true
7aa43ddbb81ccbb9e8ad6fa74424dbe46fdeca35
Wambita/pythonwork
/converter.py
597
4.1875
4
#Program to convert pounds to kilograms #Prompt user to enter the first value in pounds print("Enter the first value in pounds you wish to convert into kilograms") pound1= float(input()) #prompt user to enter the second value in pounds print("Enter the second value in pounds you wish to convert into kilograms") pound...
true
e0aea95c21e5134bef5cf6501033d9b9d7d8119a
hwichman/CYEN301
/KeyedCaesar/KeyedCaesar.py
1,330
4.21875
4
import sys alphabet = "abcdefghijklmnopqrstuvwxyz" ### Main ### # Check for arguments if sys.argv < 3: raise Exception("CaesarCipher.py <1-25> <alphabetKey>") try: # Make sure second argument is an int numKey = int(sys.argv[1]) except: print "Key must be an integer." alphaKey = sys.arv[2] # New al...
true
2a4a4034e78d0dca4a5e3429fc29e0df2cfbb35e
popovata/ShortenURL
/shorten_url/app/utils.py
393
4.21875
4
""" A file contains utility functions """ import random import string LETTERS_AND_DIGITS = string.ascii_letters + string.digits def get_random_alphanumeric_string(length): """ Generates a random string of the given length :param length: length of a result string :return: a random string """ ...
true
f2fba366bd724b0bbcb6d9ef80cad1edcb1e546e
AswinSenthilrajan/PythonRockPaperScissor
/PaperStoneScissor/StonePaperScissor.py
848
4.1875
4
from random import randrange options = ["Scissor", "Stone", "Paper"] random_number = randrange(3) user_option = input("Choose between Paper, Scissor and Stone:") computer_option = options[random_number] def play(): if computer_option == user_option: user_optionNew = input("Choose again:") elif compute...
true
2311b07ae564fd53cabee5532a39392c9e86793c
hiteshvaidya/Football-League
/football.py
2,397
4.25
4
# Football-League #This is a simple python program for a Football League Management System. It uses sqlite and tkinter for managing database and UI. #created by Hitesh Vaidya from tkinter import * import sqlite3 class App: def __init__(self,master): frame = Frame(master) frame.pack() a=St...
true
2224d73582b20f4542eb637c3a40579571ed4ac3
azzaHA/Movie-Trailer
/media.py
1,220
4.21875
4
""" Define Movie class to encapsulate movies attributes and methods """ class Movie(): """ Define attributes and methods associated to Movie objects * Attributes: title (string): Movie name story_line (string): Brief summary of the movie trailer_youtube_id (string): trailer ID on ...
true