blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
910c14f98d153b2e1adba8fc1e8009a8b7997cf4
nahaza/pythonTraining
/ua/univer/HW07/ch11ProgTrain01/__main__.py
1,586
4.5625
5
# 1. Employee and ProductionWorker Classes # Write an Employee class that keeps data attributes for the following pieces of information: # • Employee name # • Employee number # Next, write a class named ProductionWorker that is a subclass of the Employee class. # The ProductionWorker class should keep data attributes...
true
16d5d8612c3034a74237217421d8be8a6396193c
nahaza/pythonTraining
/ua/univer/HW05/ch09AlgTrain07.py
256
4.25
4
# 7. Assume each of the variables set1 and set2 references a set. Write code that creates # another set containing only the elements that are found in both set1 and set2, and # assigns the resulting set to the variable set3. set3 = set1.intersection(set2)
true
79a8af55274df3720669dfdf7db13e3e1af5e2a0
nahaza/pythonTraining
/ua/univer/HW02/ch04ProgTrain13.py
1,127
4.59375
5
# 13. Population # Write a program that predicts the approximate size of a population of organisms. The # application should use text boxes to allow the user to enter the starting number of organisms, # the average daily population increase (as a percentage), and the number of days the # organisms will be left to multi...
true
e24c318857d3d8773bad8ccee3c6c2c3507ab58d
nahaza/pythonTraining
/ua/univer/HW06/ch10ProgTrain01/pet.py
1,963
4.5
4
# # # 1. Pet Class # # # Write a class named Pet, which should have the following data attributes: # # # • _ _name (for the name of a pet) # # # • _ _animal_type (for the type of animal that a pet is. Example values are ‘Dog’, ‘Cat’, # # # and ‘Bird’) # # # • _ _age (for the pet’s age) # # # The Pet class should have a...
true
f983e0a8d26c72aec5255d57e27fe9774ddee648
fordude1/ucscPython
/Labs/Lab2/l2q2.py
462
4.40625
4
# Question 2 Write a program that asks the user for an integer # Determine if the integer is odd or even print "Lab 2, Question 2:" misc_int = raw_input("Please enter an integer: ") # test for exception try: answer = int(misc_int) except ValueError: print "The Value entered was not an integer." print "Pro...
true
62427e614da9d6ce9b4d79b1e50a5a6b4ad48330
aquib1011/python-basic
/phone-book/phoneBook.py
1,793
4.4375
4
# April 17, 2020 # Priyanshul Govil # 19070124053 # IT - 3 # PPSL Assignment - # Python program for a database of phone numbers could be stored # using a dictionary and perform Initialize, adding, removing operations. class PhoneBook(dict): def numberAdd(self, name, number): if(name in super().keys()): ...
true
d320de5c875c7b647dfc0c8cc9c1c179e8bffdfc
Zelatrix/stacks-and-queues
/queue.py
944
4.3125
4
class Queue: def __init__(self): self.size = 0 self.elements = [] def __str__(self): return str(self.elements) def enqueue(self, element): self.elements.append(element) self.size += 1 def dequeue(self): self.elements.pop(0) self.size -= 1 d...
true
67414ee993447df5925311b37732901fb1a848eb
flogothetis/Technical-Coding-Interviews-Algorithms-LeetCode
/Must-Do-Coding-Questions-GeeksForGeeks/Arrays/missingNumberInArray.py
441
4.125
4
''' Missing number in array Easy Accuracy: 29.81% Submissions: 6204 Points: 2 Given an array of size N-1 such that it can only contain distinct integers in the range of 1 to N. Find the missing element. ''' def missingNumber (array, N): num1 = 0 for i in range (1, N+1): num1 ^= i num2 = 0 for ...
true
56d55d7e742998c163ff3784968f0763a40fed9f
flogothetis/Technical-Coding-Interviews-Algorithms-LeetCode
/Grokking-Coding-Interview-Patterns/13. BitWise XOR/complementOfBase10.py
921
4.3125
4
''' Problem Statement # Every non-negative integer N has a binary representation, for example, 8 can be represented as “1000” in binary and 7 as “0111” in binary. The complement of a binary representation is the number in binary that we get when we change every 1 to a 0 and every 0 to a 1. For example, the binary com...
true
9bd0016d2ed851d2fbb3d312c2e25a5e1e3542fe
flogothetis/Technical-Coding-Interviews-Algorithms-LeetCode
/Grokking-Coding-Interview-Patterns/3. Fast & Slow Pointers/palindromeLinkedList.py
1,732
4.125
4
''' Palindrome LinkedList Given the head of a Singly LinkedList, write a method to check if the LinkedList is a palindrome or not. Your algorithm should use constant space and the input LinkedList should be in the original form once the algorithm is finished. The algorithm should have O(N)O(N) time complexity where ‘N...
true
213de09d100e03453540e9fa63bc1e741ab8953c
Billoncho/PingPongChallenge
/PingPongChallenge.py
1,468
4.53125
5
# PingPongChallenge.py # Billy Ridgeway # Calculates the height and weight of a given number of Ping Pong balls. def convert_in2cm(inches): # Defines the function to convert inches to centimeters. return inches * 2.54 def convert_lb2kg(pounds): # Defines the function to convert pounds to kilograms. r...
true
b3c11a9e4179440881c935c8c967374a9de07c26
mingtheanlay/practice-python
/python-project/guess-the-number.py
1,334
4.25
4
# import denpendency random import random print("Welcome to Guess the Number Challenge") # random from 1 to 10 number = int(random.randint(1,10)) # loop the menu while True: # get user to input the number that they want to guess user_guess =int(input("Input the number that you want to guess: ")) # if the gu...
true
4ace5c67325e05455fded0d4bd9f3d7f2e597aed
mingtheanlay/practice-python
/python-project/list-less-than-10.py
533
4.3125
4
print("Generate random list...") # Initialize a list with random number list_number = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] print(list_number) # to find the number that less than 5 # if element is less than 5 it add to list of variable number_less_than_five number_less_than_five = [el for el in list_number if el < 5] ...
true
a31dac81f39a2bebc6550fa537d15a4ea0b94d34
fengjiaxin/leetcode
/code/linked_list/25. Reverse Nodes in k-Group.py
2,110
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019-07-16 07:16 # @Author : 冯佳欣 # @File : 25. Reverse Nodes in k-Group.py # @Desc : ''' Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length ...
true
91c51a456f82d861c69b5b2253bf58c1fe4f4f63
fengjiaxin/leetcode
/code/trie/208. Implement Trie (Prefix Tree).py
1,791
4.53125
5
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019-07-09 15:34 # @Author : 冯佳欣 # @File : 208. Implement Trie (Prefix Tree).py # @Desc : ''' Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns true...
true
2701557cf2aed1f2bc676014a31b57056ce1b42c
fengjiaxin/leetcode
/code/tree/106. Construct Binary Tree from Inorder and Postorder Traversal.py
1,575
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019-07-18 07:17 # @Author : 冯佳欣 # @File : 106. Construct Binary Tree from Inorder and Postorder Traversal.py # @Desc : ''' Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist i...
true
1379b2253bd561435ef06effb721e84fd54e548f
fengjiaxin/leetcode
/code/tree/101. Symmetric Tree.py
1,141
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019-07-16 08:20 # @Author : 冯佳欣 # @File : 101. Symmetric Tree.py # @Desc : ''' Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ ...
true
6dc9870239587cc4cbd409bde6373f1a110d1524
KPW10452025/SQlite-and-Python
/13_limit.py
909
4.5
4
# reference from # "SQLite Databases With Python - Full Course" # https://youtu.be/byHcYRpMgI4 # import sqlite3 import sqlite3 # connect to database connect = sqlite3.connect("student_health.db") # create a cursor cursor = connect.cursor() # query the database - LIMIT # use LIMIT to limit the number of output cur...
true
569f4195c7b5a49efdffa122c637338773d7e44f
andrew-bydlon/Courses
/Python/ProjectSolutions/Class82.py
556
4.21875
4
try: MyInteger = input("Enter your favorite integer: ") if int(MyInteger)!= float(MyInteger): raise RuntimeError("You need to enter an integer without decimals") except: print("You need to enter an integer!") raise TypeError try: MyFloat = float(input("Enter your favorite decimal number: ")) except: print("You...
true
c737f8bd6f0e171e9cb1637511b0b2f797c46266
jack1993ire/Assignment-4-
/Ass 4 Sort.py
414
4.59375
5
# This program is going to take a string of words # Then, it will return those words in the opposite order mywords = 'gorilla, dragon, lion, orc, troll, hippo' # Then creates the list! list = mywords.split(",") # Print in the normal order print (list) # And then, print the words backwards! list.reverse() print ...
true
536ebb2b7a39cf67a71ffef139041c2915668679
jag15/class-work
/min.py
340
4.21875
4
largest=None smallest=None while True: test=input("Enter a number: ") if test == "done" : break try: num=float(test) except: print("Invalid input") continue if smallest is None or num<smallest: smallest=num if largest is None or num>largest: largest=num print("") print("Maximum is", largest) print("Min...
true
30e5dbe67ca6755b3abc0082f555c0d7a8a7516a
aqd14/daily-coding
/python/binary search tree/sorted_array_to_BST.py
1,356
4.21875
4
# Given an array where elements are sorted in ascending order, convert it to a height balanced BST. # # For this problem, a height-balanced binary tree is defined as a binary tree # in which the depth of the two subtrees of every node never differ by more than 1. # # Example: # # Given the sorted array: [-10,-3,0,5,9],...
true
21104d3421afeb5b5d2576d6b01c6335c93c37d6
JavaRod/SP_Python220B_2019
/students/MzKhan/lesson03/src/customer_model.py
1,105
4.15625
4
""" Create a customer database in the sqlite3 database and use peewee model to manipulate the data """ import os import peewee #pylint: disable = too-few-public-methods PATH, FOLDER = os.path.split(os.getcwd()) DATABASE_FILE = os.path.join(PATH, 'database', 'customer.db') DATABASE = peewee.SqliteDatabase(DATABASE_FIL...
true
02698a6add8634019f8f9611af16140b7fc48c02
JavaRod/SP_Python220B_2019
/students/franjaku/lesson09/part3/pngdiscover.py
713
4.1875
4
""" Lesson 09 part 3 Make a recursive function to find the png files in a directory. """ import os def find_pictures(cur_dir): """ Recursive function to find pictures from the root directory returns a list of lists structured as follows """ png_found = [] return_list = [] for item i...
true
fc23a0e1b69d8ac30e967a260b98f735667cd1d9
JavaRod/SP_Python220B_2019
/students/amirg/lesson09/assignment/pngdiscover.py
632
4.125
4
''' This file searches returns all png files in a specified directory and their file paths ''' import os FILE_LIST = [] def get_png_files(file_path): '''Method to use recursion to find all png files and their associated filepaths''' FILE_LIST.append(file_path) FILE_LIST.append([]) file_locatio...
true
6536ff009bc7f2ccaab72273cd3891b8abdca606
JavaRod/SP_Python220B_2019
/students/dfspray/Lesson09/src/jpgdiscover.py
841
4.15625
4
""" This program will find all the .jpg (or in my case, .png) files in the file directory system """ import os def find_jpg(path): """This is the recursive function for discovering .jpg files""" path_list = [] for root, directories, files in os.walk(path): file_list = [] #In my version, al...
true
28733b64adfc6fd0a25d990734659ba11402d4f7
AnkyBistt/Python
/Python classes/list.py
501
4.21875
4
list = [1,2,3,"Ankit", 45, 67, "Ranu"] # list in python is like array in other languages list.append("vijay") #append data to the end of the list list.insert(2, 50) #insert data at the mentioned index size = len(list) # print size of the list print(list) print(list[4]) print(list[2:]) # startindex...
true
df368a946ade5b0017c07ba93eab00e2ee0c5fff
AnkyBistt/Python
/Python classes/inheritence sum.py
694
4.1875
4
class BaseClass: num1 = 0 num2 = 0 result = 0 def __init__(self, num1, num2): self.num1 = num1 self.num2 = num2 def sum(self): self.result = self.num1 + self.num2 return self.result class DerivedClass(BaseClass): def __init__(self, num1, num...
true
6a76c465bfd9fbe35baa18ef7fb019168fd2612b
derekYankie/python01
/Assignments/Assignment_3.3_Derek_Afriyie.py
960
4.46875
4
#Assignment 3.3 #Write a program to prompt for a score between 0.0 and 1.0. #If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade #using the following table: "Score Grade" ">= 0.9 A" ">= 0.8 B" ">= 0.7 C" ">= 0.6 D" "< 0.6 F" #If the user enters a value out of range, print...
true
72d5cd8c51bc1b380237e838c027a45809a97fb7
derekYankie/python01
/Assignments/Assignment_10.2_Derek_Afriyie.py
1,653
4.125
4
#Assignment10.4 "Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. " "You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon." "From stephen.marquard@uct.ac.za Sat Jan ...
true
44c6a03bd302802bf962a11cc2c037a2a9bb23e9
xujie-nm/Python
/week_2_guess the number.py
2,574
4.1875
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import random import math #global variables, number is random number num_range = 100 timers = 0 number = -1 # helper function to star...
true
36846bae46ff745b2a121f8d1c1ec0f9ee810c3f
VanshikaP/cs-module-project-recursive-sorting
/src/searching/searching.py
1,562
4.375
4
# TO-DO: Implement a recursive implementation of binary search def binary_search(arr, target, start, end): # Your code here if len(arr) is 0: return -1 if start is end: if target is arr[start]: return start else: return -1 else: mid = (start + end)...
true
87fb566735720688573d8ae4294f325482d21f97
Asperas13/leetcode
/problems/208.py
1,501
4.1875
4
class TrieNode: def __init__(self, value): self.value = value self.children = {} self.is_word_end = False class Trie: def __init__(self): """ Initialize your data structure here. """ self.tree = TrieNode('head') def insert(self, word: str) -> None:...
true
e202473882a0233f12e11d26a806a2c5e5f71b5b
NobleWolf42/Python101
/Chapter 07/polygon.py
875
4.1875
4
from turtle import * from random import randrange, choice def polygon(n, s, h, x, y, c, f): """ Draws a regular polygon with n sides. The length of each side is s. The pen's initial heading is h. The pen begins at point(x, y). The polygon's color is c. The polygon is filled if f is True; ot...
true
6f694e0857799ce24f90a51fbe99614e483fd4fa
NobleWolf42/Python101
/Examples for Landon Python/bmi.py
841
4.5
4
#This section prompts the user for the input of their weight and height pounds = float(input("Please enter your weight in pounds: ")) print("Enter your height, separately, in feet and inches...") feet = float(input("Enter feet: ")) inches = float(input("Enter inches: ")) #This section preforms conversions from standar...
true
6422440a8fefb3ef41a53c1b4a4116866dc969ea
NobleWolf42/Python101
/Ben Labs/Fibonacci_s_Boxes.py
830
4.125
4
#This allows me to use the drawing function (Turtle) from turtle import * #These define the varibles used later on in the program count = 0 lengthofline = 1 previous = 1 #My title title("Fibonacci's Pyramid") #These statements specify no animation and remove the triangle (Turtle) tracer(0) hideturtle() #This create...
true
aab91d352287017b96256d8fd513025c11a212b5
hanh-nguyen/problems_algorithms
/P1_squareroot.py
1,224
4.3125
4
def sqrt(number): """ Calculate the floored square root of a number Args: number(int): Number to find the floored squared root Returns: int: Floored Square Root """ if number < 0: return None if number <= 1: return number low = 0 high = number res...
true
3092c18455c6862b7fd8aa1dbe4630cf20552608
Minakshi-Verma/cs-module-project-recursive-sorting
/src/sorting/sorting.py
1,990
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 # Sorting happens here... a = 0 #from arrA b = 0 #from arrB #k from merged_arr for k in range(0, elements): # start c...
true
b2cee4c279190bf1c7d97c26d9c48f802a2745a9
lingtianwan/Leetcode
/Algorithm/165_CompareVersionNumbers.py
1,393
4.1875
4
# Compare two version numbers version1 and version2. # If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. # # You may assume that the version strings are non-empty and contain only digits and the . character. # The . character does not represent a decimal point and is used to separat...
true
9a93f7ed6f7f5ee22e229b3e70b8c9069718b157
lingtianwan/Leetcode
/Algorithm/125_ValidPalindrome.py
1,005
4.25
4
# Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. # # For example, # "A man, a plan, a canal: Panama" is a palindrome. # "race a car" is not a palindrome. # # Note: # Have you consider that the string might be empty? This is a good question to ask during an ...
true
cb8aa266f2766bbfceb59abdd620a53c802fc336
rvutd/NPTEL-Joy-of-Computing-2020
/W2_PA3.py
462
4.15625
4
# Given two numbers (integers) as input, print the smaller number. # Input Format: # The first line of input contains two numbers separated by a space # Output Format: # Print the smaller number # Example: # Input: # 2 3 # Output: # 2 # -----------------------------------------------------------------...
true
ec05df9204ae9b3b169a6d0380422672e6a65cfb
rvutd/NPTEL-Joy-of-Computing-2020
/W3_PA3.py
908
4.375
4
# Given a list A of numbers (integers), you have to print those numbers which are not multiples of 5. # Input Format: # The first line contains the numbers of list A separated by a space. # Output Format: # Print the numbers in a single line separated by a space which are not multiples of 5. # Example: # In...
true
cfb25a9edcae376b2d9b93d278907f5201d92e6b
rvutd/NPTEL-Joy-of-Computing-2020
/W4_PA2.py
409
4.46875
4
# Given an integer number n, you have to print the factorial of this number. # To know about factorial please click on this link. # Input Format: # A number n. # Output Format: # Print the factorial of n. # Example: # Input: # 4 # Output: # 24 num = int(input()) factorial = int(1) for i in ra...
true
dde0f058f00c61c2c5609def90f03ccc4da54fcb
ujwala14/Python-Lab
/5a.py
1,489
4.15625
4
'''Write a python program to simulate saving account processing in a bank using constructors. Create Deposit and Withdraw with other member functions and Check for Validation while withdrawing the amount and depositing the amount by defining appropriate user defined exceptions.''' class not_valid(Exception): def _...
true
c97aa9c61a890e12daf80c3b1a780b765dd6d962
arajajyothibabu/PythonLearning
/unit2_assignment_03.py
1,985
4.15625
4
__author__ = 'Kalyan' notes = ''' Write your own implementation of converting a number to a given base. It is important to have a good logical and code understanding of this. Till now, we were glossing over error checking, for this function do proper error checking and raise exceptions as appropriate. Reading materi...
true
03179df7c2e7ee81ca5f8f0e1c9bf54c73567b72
cacossio/Python
/Python_stack/Python/Python-fundamentals/Functions Intermediate I/Functions Intermediate I.py
768
4.125
4
import random def randInt(min=0 , max= 100): if min > max: print("min cannot be greater than max") return if min < 0: print ("min cannot be negative") return num = random.random() * (max-min )+ min return num #print(randInt())      # should print a ran...
true
495abf795296e1e0b311e3343a1b1c25617ee35c
PaulWaltersDev/elizabeth
/elizabeth/decorators.py
732
4.15625
4
from elizabeth.core.intd import ROMANIZATION_ALPHABETS def romanized_russian(func): """Cyrillic letter to latin converter. Romanization of the Russian alphabet is the process of transliterating the Russian language from the Cyrillic script into the Latin alphabet. .. note:: At this moment it's work o...
true
8e36c91916a4140c7f10ccb20e36501958eba8b3
EMOS-BF/holbertonschool-higher_level_programming-1
/0x0B-python-input_output/100-append_after.py
637
4.25
4
#!/usr/bin/python3 """ This module finds an string in a file an adds a line. """ def append_after(filename="", search_string="", new_string=""): """Function append_after. Adds an string after a given one is found Args: search_string(str): string to be searched in file. new_string: new s...
true
c7ba05182bab88dd4c146582c32fa2261f9c7f20
EMOS-BF/holbertonschool-higher_level_programming-1
/0x07-python-test_driven_development/5-text_indentation.py
961
4.25
4
#!/usr/bin/python3 """This module has the function text_indentation""" def text_indentation(text): """ Function text_indentation: Args: text (str): string to be split Returns: prints a text with 2 new lines after characters: ., ? and : """ str_new = "" flag_spa = 0 ...
true
64c842e082f4a7b8958629a92bc136f9b7006622
vikki1107/ProjectPy
/academic/findSqRoot.py
1,703
4.65625
5
#!/usr/bin/env python """ Create a square root function that takes two parameters. The first parameter, n, will be the number for which the square root is being computed. The second parameter, guess, will be the current guess for the square root. The guess parameter should have a default value of 1.0. Do not provide a ...
true
6840927f4019b393c4f04437e5bfed9caa4070b6
RameshOswal/bioinformatics-algorithms-coursera
/Assignment_03B.py
1,411
4.21875
4
#!/usr/bin/env python ''' A solution to a programming assignment for the Bioinformatics Algorithms (Part 1) on Coursera. The associated textbook is Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner. The course is run on Coursera and the assignments and textbook are hosted on Step...
true
fc4dfc8e92605db54ecf0129337a45dbf96214f8
SynBioHub/Plugin-Submit-Excel-Library
/col_to_excel.py
601
4.34375
4
def col_to_excel(col): """ Converts the column number to the excel column name (A, B, ... AA etc) Parameters ---------- col : INTEGER The number of the column to convert. Note that 1 converts to A Returns ------- excel_col : STRING The string which describes the name o...
true
3ab07039c1888127dca9081ffc8e0b9ef033d01e
mukeshprasad/30-Day-LeetCoding-Challenge
/July-LeetCoding-Challenge/Week-2/angle_clock.py
405
4.15625
4
''' # Angle Between Hands of a Clock # Given two numbers, hour and minutes. Return the smaller angle (in degrees) formed between the hour and the minute hand. # Example 1: Input: hour = 12, minutes = 30 Output: 165 ''' # SOLUTION: class Solution: def angleClock(self, hour: int, minutes: int) -> float: ...
true
003b6bd227508739f0ca12b2d5abe2875ce65951
mukeshprasad/30-Day-LeetCoding-Challenge
/July-LeetCoding-Challenge/Week-3/reverse_words.py
636
4.34375
4
''' # Reverse Words in a String # Given an input string, reverse the string word by word. # Example 1: Input: "the sky is blue" Output: "blue is sky the" # Note: * A word is defined as a sequence of non-space characters. * Input string may contain leading or trailing spaces. However, your reversed string sh...
true
e101e3faa223ee99f2e2ef3ba605250042729322
jennarunge/exercises
/chapter-7/ex_7_1.py
1,040
4.1875
4
# Programming Exercise 7-1 # # Program to Total a week's sales (seven inputs). # This program prompts a user for a sales amount for each day of the week, # totals them up, then displays the total formatted as currency. # Define the main function # Define local float variable for rtotal sales # Initiali...
true
19d088794dec75935fa13875adcd1103ed916a54
jennarunge/exercises
/chapter-3/exercise-3-5.py
938
4.59375
5
# Programming Exercise 3-5 # # Program to convert a value in kilograms to Newtons, then check whether it is in range. # This program will prompt a user for a mass in kilograms, # convert it to Newtons and use constants to check if the weight is within range, # then display the weight and a range message. # ...
true
7ea4e55fe5b5b8d151f68c3e8220082b7320d49a
jennarunge/exercises
/chapter-2/ex-2-7.1.py
392
4.125
4
#calculate the miles per gallon for a trip #inputs miles_traveled= input("How many miles are traveled:") gallons_of_gasoline= input("How many gallons of gas did you use:") miles_traveled= float(miles_traveled) gallons_of_gasoline= float(gallons_of_gasoline) #processing miles_per_gallon= (miles_traveled/ gallons_of_gas...
true
52ddcdf855defa8b516e8af32f770949dedaefd7
jennarunge/exercises
/chapter-3/exercise-3-2.py
1,421
4.53125
5
# Programming Exercise 3-2 # # Program to find which of two rectangles has the greater area. # This program will get two sets of lengths and widths from a user, # use them to calculate and compare two area values, # and display a message comparing those areas # Local variables # you need length, width and area...
true
d43df52a9a1aaf6cd490ef8bc146f4b527fae19b
mbastola/Algorithms-Data-Structures-in-Python
/Sorting Algorithms/mergesort.py
1,559
4.25
4
#Manil Bastola def mergeSort(lst): if len(lst) > 1: #Split the list in half mid = len(lst)//2 leftList = lst[:mid] rightList = lst[mid:] #Sort the two halves mergeSort(leftList) mergeSort(rightList) #Merge the sorted halves leftIndex = 0 ...
true
89a1ea7ad00a8b40477f13bd8fc2a5096165c9fe
andybloke/python4everyone
/Chp_6/chp_6_ex_2.py
325
4.21875
4
def count(string, letter): count = 0 for character in string: if character == letter: count = count + 1 return count string = input('Enter a string: ') letter = input('Enter a letter to count: ') count = count(string, letter) print('The letter \"%s\" occured %d times in the string\n\"%s\" ' % (letter,count,str...
true
e806372147b8f14dddf8ff05c30af1c043b4643f
Lfritze/cs-module-project-algorithms
/product_of_all_other_numbers/product_of_all_other_numbers.py
1,394
4.1875
4
''' Input: a List of integers Returns: a List of integers ''' def product_of_all_other_numbers(arr): # Your code here king_index = [] # x is index for x, i in enumerate(arr): #start from index -> + index + 1 (ignore current index and go to the next one) lst = arr[:x] + arr[x + 1:] ...
true
3e69bc6059abb1b6547449d3b66051b4a0f9b954
Charud25/Hacktoberfest2021-2
/python/Special_Number.py
496
4.375
4
""" Special number is a numbe in which the sum of the factorial of digits of a number (N) is equal to the number itself. """ import math #taking user input num=int(input("Enter a number: ")) n =num rem=0 rev=0 #while loop to add the factorial of each digit of a number while n>0: rem=n%10 rev+=math.factorial(r...
true
b6e51e06cded48e263dcadec56cdb593c302184d
NItishSh/vscode-devcontainer-python
/count_primes.py
408
4.125
4
def count_primes(num): # check for 0 and 1 if num < 2: return 0 #2 or greater primes = [2] # counter going upto input num x = 3 while x <= num: for y in primes: if x % y == 0: x += 2 break else: primes.append(x)...
true
8cf688fe4a8e3b6a3f6b1aa98216af0bebf3e157
fanzhangg/sliding-tiles
/case_solvable_judge.py
1,697
4.46875
4
from Board import Board # initialize a 3*3 board board = Board(3, 3) def get_out_of_order_pair_num(puzzle): """ If a number is larger than another number after it, the two numbers are a out of order pair. Count the number of out of order pair case in a sliding tile case :param puzzle: a sliding tile ...
true
1ac9e0febb26323146f1f9fce4fcf1560539c054
codernoobi/python
/Python/introduction/functions.py
1,615
4.5
4
x=10 a=1 def my_function(): #define function print("Hello from a function") my_function() #function call def my_function(fname, lname): print(fname) #print first parameter my_function("akash", "hr") def my_function(country = "Norway"): #default parameter print("I am from " + country) my_funct...
true
ea6d75c8a897bdbe78fb6f31ee4e6a78c4c1aafd
codernoobi/python
/Python/practice/spiralhelix.py
650
4.28125
4
# Python program to draw # Spiral Helix Pattern # using Turtle Programming import turtle loadWindow = turtle.Screen() turtle.speed(2) for i in range(100): turtle.circle(5*i) turtle.circle(-5*i) turtle.left(i) turtle.exitonclick() #rainbow benzene # import turtle # colors = ['red', 'purple', 'blue', ...
true
abd54efcfe981329714d7ca396e2281c827f1f4e
codernoobi/python
/Python/introduction/dates.py
1,965
4.5625
5
import datetime #Import the datetime module and display the current date x = datetime.datetime.now() print(x) #The date contains year, month, day, hour, minute, second, and microsecond. print(x.year) print(x.strftime("%A")) #Return the year and name of weekday x = datetime.datetime(2020, 5, 17) #Create a date ...
true
b8bea1a6576f2261231a40a16206358bb5fe556e
Max-Profi/email_and_password_validation
/email-pass-valid.py
1,196
4.3125
4
# Using regular expression module from Standard Library import re """ EMAIL VALIDATION """ user_email = input('Enter your email: ') def validate_email(user_email): # regex expression to use reg = "(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)" # compile regex into pattern pattern = re.compile(re...
true
f0b8eb671331a1011cc3507dc6ef6d5eba2265ad
DvorahC/PythonCourse
/Week1Ex2.py
668
4.21875
4
# 2 Write a program that is receiving 3 numbers from the user and is checking if one of # the numbers is the sum of the 2 other numbers number1 = int(input('Please enter a first number: ')) number2 = int(input('Please enter a second number: ')) number3 = int(input('Please enter a third number: ')) if number1 == ...
true
357e740315f7608679fd498e734257d9b2050bc3
leoriviera/Project-Euler
/python/problem_1.py
545
4.15625
4
def problem_1(): "Find the sum of all the multiples of 3 or 5 below 1000." total = 0 # For each number, num, between 1 and 1000... for num in range(1, 1000): # Find the modulus of 3 and the modulus of 5. mod_3 = (num % 3) mod_5 = (num % 5) # If both the remainders equal...
true
d57075830fc339097421016af6270218d44de8e9
lolilo/Exercise5-Files-Creative-uses-of-lists
/lettercount.py
2,111
4.21875
4
# Write a program, lettercount.py, that opens a file named on the command line and # counts how many times each letter occurs in that file. #Your program should then print those counts to the screen, in alphabetical order. from sys import argv # The command exists returns True if a file exists, based on its name i...
true
e526be411863aa6097c748ec181337e573bdcc43
ramalho/iching
/trigrams.py
2,745
4.25
4
#!/usr/bin/env python3 """ Class ``Trigram`` represents an I Ching trigram. The ``Trigram.build_all()`` class method is invoked when the module is loaded to create class attributes named after the trigrams:: >>> Trigram.MOUNTAIN <Trigram ☶ MOUNTAIN> The ``Trigram.all`` class attribute provides access to eve...
true
b0863f607e608520952763d855d5af67fbdafaf8
EduardoFF/easy_cozmo
/examples/flat/demo_pickup_and_look.py
1,130
4.34375
4
""" Exercise: Find cube 1, pick it up, look for a teammate, present the cube to the teammate. Repeat for cube 2 and 3 Notes: - If cozmo cannot find a cube, it becomes sad and skip to the next cube. - If cozmo cannot find a teammate, it becomes sad and drops the cube. - Extra points: check if cozmo could pick the cube...
true
4d51a368a353390b9bec96a4040518bdbb14cf72
Draines1/Digitalcraftsclasses
/programming102/lists.py
1,291
4.40625
4
#the items in a list can be a variable value. #index-in a list or an array, it is the integer representatioin of the #position of an item in the list or array. #my_kids = ["Alex", "Sky"] #print(my_kids[0]) #1.Create a program that has a list of at least 3 of your favorited foods in order #and assign that list to ...
true
e310b21be20576de21697b47f0786c3d0f411a06
Draines1/Digitalcraftsclasses
/programming102/modifiying_lists.py
1,288
4.5
4
#method-in python (and other languages) a method is a function that #a datatype can run from it's own instance. # my_pets = ["Red", "Bear", "Pluto"] # my_pets.append("Rainbow") # print(my_pets) #you can concatenate your lists # my_dogs = ["Red", "Bear"] # my_cat = ["Pluto"] # my_pets = my_dogs + my_cat # print(my_pet...
true
839596afa0ae9496e9a586db0dadbbb9349c75fb
preetmodh/Folder-Sorting-Automation
/folder_sorter.py
1,250
4.25
4
""" This script iterates through the files in a user's downloads folder on Windows and places each file in its appropriate folder. This script could be run to sort any files in any folder just instead of Downloads in folder_path write relative path of your folder """ import shutil import getpass from pathlib...
true
de4bda979f6d24383fa77b1da41f045c00a1f2e6
minialappatt/Python
/List_sum_average_cube.py
632
4.40625
4
# -*- coding: utf-8 -*- """ List Processing Program to do: 1. Get elements into the list from user 2. Find average value of elements in the list 3. Find the cube of each values in the list """ x=[]#initialise empty list n=int(input("Enter the number of elements required:")) for i in range(0,n):...
true
31d09c54427fc4ee38f5ddef97a4039743ee1eed
minialappatt/Python
/file_copy_reverse_order.py
837
4.28125
4
""" Copying the contents of one file to another in reverse order of lines """ f=open("test.txt","r") #opening the file test.txt in read mode text=f.read() #reading the contents and store in 'text' print("Printing the contents of file:") print(text) f.close() f1=open("test.txt","r") f2=open("reverse_lin...
true
08e794b9d0784f3518d5e823ec0906d15c131772
nidhisha-shetty/Python-programs
/oops-constructor_in_inheritence.py
1,432
4.375
4
#executes constructor in B only class A: def __init__(self): print("constructor in A") class B(A): def __init__(self): print("constructor in B") b1=B() #executes constructor in A, as there is no constructor present in B(extends A) class A: def __init__(self): print("constructor in A") class B(A): ...
true
9c0d6c1fe51f31e8e876f0de530081e418a35b46
nidhisha-shetty/Python-programs
/function.py
2,597
4.40625
4
#In order to avoid coding same set of steps repeatedly, we use functions. #for example, if we have payment option thrice in our project, we will create the paymant function once, and just call it thrice, hence avoiding repeated codes. def sum(num1, num2): #defining sum function add=num1+num2 retur...
true
b409d71884712ca713c09974dea76590e1337984
nidhisha-shetty/Python-programs
/oops-method-overloading.py
581
4.3125
4
#Python doesnot support method overloading, however we may use other implementation in python to make the same function work differently i.e, as per the arguments. #Example 1: def sum(a,b): return a+b def sum(a,b,c): return a+b+c res=sum(2,3,5) #the function which is defined last will be considered print(res) #E...
true
06b429ca18cc7fba1219b29deb2202d51ab9479e
elijahzucker/Project-Euler
/14 Longest Collatz Sequence/14 Longest Collatz sequence.py
713
4.1875
4
def collatize(n): c = 1 #c is the count of terms in the string while(n > 1): #runs oddOrEven until it produces 1 n = oddOrEven(n) c += 1 return c def oddOrEven(n): #piecewise function that applies on operation if n is odd or even if( (n % 2) == 0):...
true
4da9434cd2043115c6c96469e02ca08c20240ffc
NobodyWHU/Leetcode
/385-Mini-Parser/solution.py
2,463
4.25
4
# """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ #class NestedInteger(object): # def __init__(self, value=None): # """ # If value is not specified, initializes an empty list. # Otherwise initializes a ...
true
133c26b45497abc23fdaa92af2261f40f4ba7be0
jasmineprincylobo/PythonPrograms
/dict3.py
338
4.125
4
"""Add name and salary {name:salary} for n number of employees through keyboard in a dictionary and print them in name alphabetical order with salary""" n=int(input("Enter no of records")) d={} for i in range(1,n+1): name=input("Enter name %d"%(i)) sal=int(input("Enter mark %d"%(i))) d[name]=sal #d.sor...
true
6e077859ca7d0b045b62a5a2d892b4cd2010840f
gpsmyth/python
/list2s.py
918
4.25
4
#!/usr/bin/python """ Turn the following English description into code: Create a list with two numbers, 0 and 1, respectively. For 40 times, add to the end of the list the sum of the last two numbers. What is the last number in the list? To test your code, if you repeat 10 times, rather than 40, your answer should be...
true
8d003325128f11a2600a703acc035564f7c2927a
jonush/leetcode
/leetcode/arrays/two_sum.py
1,338
4.1875
4
""" 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. """ def twoSum(nums, target: int): """ ...
true
254d100bce10c35224c3bbb823f6521f48f9d0c8
icest99/Python-Project
/Guess The Number/GuessNumberComputer.py
1,093
4.28125
4
import random def computer_Guess(): x, y = input("Enter lower bar and higher bar. For example, ""'20 50'\n").split() #This is my first time using f-string and it felt so good lmao. it's so easy to use and read. print(f"The lower bar is {x} , the upper bar is {y}") print("I will try to guess it now!") #...
true
f182170f0e8bd655a96c2b38df4aa5b792a04e7b
lakenn/interview_questions
/amazon/Segantii/look_and_say.py
908
4.46875
4
''' Your task is to create a function that will take an integer and return the result of the look-and-say function on that integer. This should be a general function that takes as input any positive integer, and returns an integer; inputs are not limited to the sequence which starts with "1". Conway's Look-and-say se...
true
367a31fe3d43edac28e2968f3962685413ce1313
scandium21/cohort3
/src/python/comp200/syntax.py
2,924
4.125
4
import numbers """ define attributes / variables number string boolean array dictionary / objects None sample if / else functions parameters returns lists add to the front add to the end update values compreh...
true
ddd9a2e589d09ec72b1e92ba584ac1b7961129e7
HalAndBender/Coursera_an_introduction_to_interactive_programming
/week_1b_excercise02.py
877
4.34375
4
# Compute whether a person is cool. ################################################### # Is cool formula # Student should enter function on the next lines. ################################################### # Tests # Student should not change this code. def is_cool(name): """Tests the is_cool function.""" ...
true
1904392cdb293ce0fa9e3789ab24c81ea100933a
emdre/codewars
/highest_rank_number_in_array.py
673
4.15625
4
"""Complete the method which returns the number which is most frequent in the given input array. If there is a tie for most frequent number, return the largest number among them. Note: no empty arrays will be given. Examples [12, 10, 8, 12, 7, 6, 4, 10, 12] --> 12 [12, 10, 8, 12, 7, 6, 4, 10, 12, ...
true
1ee366d52c232be4454d2d7b134c009753408cc4
jhyang12345/algorithm-problems
/problems/flatten_binary_tree.py
1,724
4.34375
4
# Given a binary tree, flatten the binary tree using inorder traversal. # Instead of creating a new list, reuse the nodes, where the list is # represented by following each right child. As such the root should always # be the first element in the list so you do not need to return anything # in the implementation, just ...
true
75ff72c8e975f9f4ec82d428e9ed8592c931b161
jhyang12345/algorithm-problems
/problems/tree_serialization.py
1,798
4.1875
4
# You are given the root of a binary tree. You need to implement 2 functions: # # 1. serialize(root) which serializes the tree into a string representation # 2. deserialize(s) which deserializes the string back to the original tree that it represents # # For this problem, often you will be asked to design your own seri...
true
034d5efb2c0d5c85943fac2006cd2a37308d5586
jhyang12345/algorithm-problems
/problems/square_root.py
483
4.25
4
# Given a positive integer, find the square root of the integer # without using any built in square root or # power functions (math.sqrt or the ** operator). Give accuracy up to 3 decimal points. # # Here's an example and some starter code: def sqrt(x): lo = 0 hi = x count = 0 while count < 1000: ...
true
bffe5be49c0150d816ee715fe70e03bdcc39d493
jhyang12345/algorithm-problems
/problems/string_to_integer.py
713
4.3125
4
# Given a string, convert it to an integer without using the builtin str function. # You are allowed to use ord to convert a character to ASCII code. # # Consider all possible cases of an integer. In the case where the string is not a # valid integer, return None. # # Here's some starting code: def get_num(num): r...
true
371120b7afd58590c0a921be2d9a7809c96a6cc6
jhyang12345/algorithm-problems
/problems/most_frequent_subtree_sum.py
1,323
4.15625
4
# Given a binary tree, find the most frequent subtree sum. # # Example: # # 3 # / \ # 1 -3 # # The above tree has 3 subtrees. The root node with 3, and the 2 leaf nodes, # which gives us a total of 3 subtree sums. The root node has a sum of 1 (3 + 1 + -3), # the left leaf node has a sum of 1, and the right leaf...
true
1f009488b5681041736c1c670df798e3d0fcc8fc
jhyang12345/algorithm-problems
/problems/staircase.py
523
4.21875
4
# You are given a positive integer N which represents the number of steps in a staircase. # You can either climb 1 or 2 steps at a time. Write a function that returns the number # of unique ways to climb the stairs. def staircase(n): cache = [0] * (n + 1) cache[0] = 1 for x in range(1, n + 1): valu...
true
1b3db922444dd4d97fc8eeec4fcb843c5bb4aac0
jhyang12345/algorithm-problems
/problems/majority_element.py
472
4.3125
4
# A majority element is an element that appears more than half the time. # Given a list with a majority element, find the majority element. # # Here's an example and some starting code. def majority_element(nums): dict = {} n = len(nums) for x in nums: if x not in dict: dict[x] = 1 ...
true
62c7953848bac1c4c85d0022b25ac3b999f49e11
jhyang12345/algorithm-problems
/problems/reverse_integer.py
578
4.21875
4
# Given an integer, reverse the digits. Do not convert the integer into a string and reverse it. # # Here's some examples and some starter code. def reverse_integer(num): buffer = abs(num) stack = [] while buffer: leftover = buffer % 10 buffer = buffer // 10 stack.append(leftover) ...
true
ab9ba2c5f6c363deccf7f054a89623e421d4e31c
jhyang12345/algorithm-problems
/problems/compute_intersection.py
667
4.21875
4
# Given two arrays, write a function to compute their intersection - the intersection means the numbers that are in both arrays. # # Example 1: # Input: nums1 = [1,2,2,1], nums2 = [2,2] # Output: [2] # Example 2: # Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] # Output: [9,4] # Note: # Each element in the result must be ...
true