blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
8220ccf608ca3f6cf590a16c914828dac2ebb92e
GarionR/cp1404
/Prac_04/quick_picks.py
510
4.1875
4
import random LOWEST_NUMBER = 1 HIGHEST_NUMBER = 45 NUMBER_OF_NUMBERS_IN_QUICK_PICK = 6 quick_pick_count = int(input("How many quick picks? ")) for i in range(quick_pick_count): quick_pick = [] while len(quick_pick) < NUMBER_OF_NUMBERS_IN_QUICK_PICK: number = random.randint(LOWEST_NUMBER, HIGHEST_NUMB...
true
62d3159fbf990f88cc9b760f2eb65d8770ce9485
AndrewDowns/AdventOfCode
/Day 2/Puzzle4.py
1,546
4.28125
4
def populatePasswords(): '''Function to loads in the passwords from the passwords file It will then return a structured list of dictionaries for each password''' passwords = [] fh = open("Passwords.txt") for line in fh: pass_dict = dict() line = line.strip() passwor...
true
14ca70a219a3739314e8210b5becae3dd72c0f73
zhiymatt/Leetcode
/Python/328.odd-even-linked-list.136466166.ac.python3.py
1,652
4.125
4
# # [328] Odd Even Linked List # # https://leetcode.com/problems/odd-even-linked-list/description/ # # algorithms # Medium (44.75%) # Total Accepted: 91.6K # Total Submissions: 204.7K # Testcase Example: '[1,2,3,4,5,6,7,8]' # # Given a singly linked list, group all odd nodes together followed by the even # nodes. P...
true
38eb97fa6a670d5b27eb169da4d62e8190dbe046
abraham-george/Python
/Algorithms/matrix_multiplication.py
399
4.3125
4
''' This is a program to multiply 2 arrays. ''' def matrix_multiplication(A,B,n): C = [[0] * n for i in range(n)] for i in range(n): for j in range(n): for k in range(n): C[i][j] = C[i][j] + (A[i][k] * B[k][j]) return C print(matrix_multiplication([[1,2],[3,4]], [[5,6], ...
true
e5bf12b403c54e797fd7c8729306218e3cb74edc
PeterKBailey/challenges
/groupAnagrams.py
815
4.125
4
# Given an array of strings strs, group the anagrams together. You can return the answer in any order. # An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, # typically using all the original letters exactly once. def groupAnagrams(strs): picked = set() separated = ...
true
de087306bd3ec4f85668296c5030df6fd5153706
xingyazhou/Data-Structure-And-Algorithm
/Dictionary/twoSum.py
1,697
4.125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 2 23:05:28 2020 170. Two Sum III - Data structure design Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure. find - Find if there exists any pair of numbers which sum is equa...
true
43616b5b0b939856025649a2635b89e0fa30e4ab
xingyazhou/Data-Structure-And-Algorithm
/Trie/trie_prefixTree.py
2,340
4.125
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 14 14:16:55 2020 208. Implement Trie (Prefix Tree) (Medium) Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns true trie.search("app"); // returns false trie.start...
true
4cd4c07ff1fd552e254c4c6bd8b0f14dda649d8c
xingyazhou/Data-Structure-And-Algorithm
/Heapq/mergeKLists.py
2,820
4.15625
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 24 13:10:43 2020 23. Merge k Sorted Lists (Hard) You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lists = [[1,4,5],[1,3,4],[2,6]] Output...
true
5aa92e32e9d936ecb694dc1cbfbda8381588f918
xingyazhou/Data-Structure-And-Algorithm
/Dictionary/uniqueOccurrences.py
1,749
4.15625
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 13 20:28:06 2020 1207. Unique Number of Occurrences (Easy) Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique. Example 1: Input: arr = [1,2,2,1,1,3] Output: true Explanation: ...
true
f86c3810082ca13108ef2945781c621d2d3ff0ac
pettigrt/HW7_leap
/leap_year.py
594
4.25
4
def leap_year(x): if x % 4 == 0: if x % 100 == 0: if x % 400 == 0: return True else: return False else: return True #No error checking on input for leap year. Assume correct input if __name__ == "__main__": year = input("E...
true
0123d609cd8e89c91a56af425f2f41ee3f2f3b3a
JeromeLefebvre/ProjectEulerLibrary
/memoize.py
766
4.125
4
import collections import functools class memoize(object): '''Decorator. Caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned (not reevaluated). ''' def __init__(self, func): self.func = func self.cache = {} ...
true
06feed8418181804c21cfaeaafad2f13ab23ac56
gokkul22/MyCaptain
/extension.py
320
4.25
4
file = input("Type a file:") f = file.split(".") #to spilt the string into two as before and after the dot print ("The extension of the file is : " + str(f[-1])) #to print the string after dot Output: Type a file:hello.c The extension of the file is : c
true
7c31f3b3c033f5acaa1e86efde8f7fda3b60fbb0
yonatanbeb/Battleship
/board.py
2,253
4.1875
4
""" Name: board.py Purpose: Implement a class representing the Battleship board. Usage: from board import BattleshipBoard """ class BattleshipBoard: def __init__(self): self.hits = 0 self.ships = { 'carrier': [], 'battleship': [], 'destroyer': [], 'submarine': [], 'patrol_boat': []...
true
f9b8a0b737acaacb27ab75f7bb1668c7008488cd
rosalieper/python_code
/deleting_in_list.py
298
4.28125
4
#!usr/bin/python list1 =['python', 'physics', 'chemistry', '1550', 2018] print list1 del list1[3] print "After deleting value of index 3: " print list1 print "length: ", len(list1) print "list*2: ", list1*2 print "python in list: ", "python" in list1 print "List: " for x in list1: print x
true
f0d81db070395c5b1dd1c57acec788e8dbeedde2
SimonFans/LeetCode
/Tree/L111_Minimum Depth of Binary Tree.py
2,201
4.1875
4
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no children. Example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its minimum dep...
true
a4da2e0eac583c7bdae139ce44907ad154988fc6
SimonFans/LeetCode
/Depth_First_Search/L156_Binary_Tree_Upside_Down.py
1,192
4.25
4
''' Given the root of a binary tree, turn the tree upside down and return the new root. You can turn a binary tree upside down with the following steps: The original left child becomes the new root. The original root becomes the new right child. The original right child becomes the new left child. ''' Input: root =...
true
ec168f3bea2f07388b0fe0c0527e337e7bd5cda4
SimonFans/LeetCode
/String/L43_Multipy_Strings.py
1,690
4.1875
4
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Example 1: Input: num1 = "2", num2 = "3" Output: "6" Example 2: Input: num1 = "123", num2 = "456" Output: "56088" Note: The length of both num1 and num2 is < 110. Both num1 and nu...
true
d587e180e95c03f08339fb382ecf6a616ec36a83
SimonFans/LeetCode
/Design/L284_Peeking_Iterator.py
2,323
4.4375
4
''' Design an iterator that supports the peek operation on a list in addition to the hasNext and the next operations. Implement the PeekingIterator class: PeekingIterator(int[] nums) Initializes the object with the given integer array nums. int next() Returns the next element in the array and moves the pointer to the...
true
50443500149d35e3bef98ca88beff7bf6cd00267
SimonFans/LeetCode
/Tree/L257_Binary Tree Paths.py
778
4.125
4
Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: Input: 1 / \ 2 3 \ 5 Output: ["1->2->5", "1->3"] Explanation: All root-to-leaf paths are: 1->2->5, 1->3 class Solution(object): def binaryTreePaths(self, root): """ :type root: T...
true
e6122138c275a7ca084bb1ca0a6f3523a11a7775
SimonFans/LeetCode
/Design/L716_Max_Stack.py
2,019
4.21875
4
Design a max stack that supports push, pop, top, peekMax and popMax. push(x) -- Push element x onto stack. pop() -- Remove the element on top of the stack and return it. top() -- Get the element on the top. peekMax() -- Retrieve the maximum element in the stack. popMax() -- Retrieve the maximum element in the stack, a...
true
282c7d261abd1bd8aae254678569d95e383dde8d
SimonFans/LeetCode
/Two Pointer/L244_Shortest_Word_Distance_II.py
1,992
4.125
4
''' Design a data structure that will be initialized with a string array, and then it should answer queries of the shortest distance between two different strings from the array. Implement the WordDistance class: WordDistance(String[] wordsDict) initializes the object with the strings array wordsDict. int shortest(St...
true
d34e07f1d59819692f5d38dc81a70563e4477ae0
muttakin-ahmed/leetcode
/Max_disk_space_available.py
712
4.15625
4
def max_disk_space(freeSpaces, blockSize): start = 0 end = blockSize # disk_sizes = [] mds = 0 while end <= len(freeSpaces): # disk_sizes.append(min(freeSpaces[start:end])) mds = max(mds, min(freeSpaces[start:end])) start += 1 end += 1 # return max(dis...
true
fcbe2786171c898a52c45e3f7cede1aaf1d4c5ef
rjovelin/Rosalind
/Stronghold/TREE/tree.py
862
4.21875
4
def make_tree(file): ''' Read the file and get the number of nodes in the first line and the pairs of connected nodes in each subsequent line. Return the number of edges necessary to produce a tree with the given number of nodes ''' # read the file, store the list of connections in a larger list ...
true
d4501419517f822d25a3656384eae5815b40105c
rjovelin/Rosalind
/Stronghold/FIB/recurrence_rabbits.py
1,380
4.3125
4
# use a recursive function to calculte the number of rabbits after n months def rabbits(n, k): ''' (int, int) -> int Return the number of rabbit pairs present after n months if each reproduction-age pair of rabbits produce a litter of k rabbits pairs Precondition: we start with 1 pair, and it takes ...
true
366bf40b769ad800bb025830c2f0e9493b7ac8c8
jbbarrau/problems
/rectangles/rectangles.py
835
4.21875
4
""" There is a list of rectangles and a list of points in a 2d space. Note that the edge of each rectangle are aligned to XY axis. How to find rectangles with point or points inside? """ """ Data model: Points is a list of tuples (x,y) Rectangles is a list of list of 2 points: Left bottom corner, Right top corner...
true
fb923f73f1e76a1e58d01a55dbd9513b147d4bcf
kowshikvarma007/Python
/ICP_1/Source Code.py
683
4.1875
4
# Remove and reverse a string strValue = input('Enter string:') print(strValue.replace(strValue[0:3],"")[::-1]),print("\n"), # Arithmetic operations num1 = input('Enter first number:') num2 = input('Enter second number:') fNum = int(num1) sNum = int(num2) print('Addition of two numbers is :' + str(fNum + sNum))...
true
14827d24ebe7d04de7fdcb55eef7d4bb597d8aad
LukeGosnell/Chapter_4
/guess_the_word.py
1,341
4.34375
4
#! /usr/bin/python3 # guess_the_word.py # Luke Gosnell # 10/27/2014 # Design: # Tell the user how to play the game # Pick a random word and ask the user to guess letters in the word # After five tries, tell the user to guess the word # Tell the user whether or not they guessed correctly import random WORDS = ['hopsc...
true
02146ab64af10280db43c7e985150824a69ecd5c
eldho5505/oops
/perimeter.py
537
4.15625
4
def perimeter_of_rectangle(length,width): perimeter_of_rectangle = 2 * (length + width) return perimeter_of_rectangle def area_of_rectangle(length,width): area_of_rectangle = length * width return area_of_rectangle def main(): length = int(input("enter the length:")) width = int(input("enter t...
true
a8a90c88eb1d0dbb4371012e77840da893c061e0
kmrgaurav11235/PythonProBootcamp
/section_02_beginners/lesson_02_dictionaries_and_nesting/04_travel_log_exercise.py
1,159
4.40625
4
# You are going to write a program that adds to a travel_log. You can see travel_log which # is a List that contains 2 Dictionaries. # Write a function that will work with the following line of code to add the entry for Russia # to the travel_log. # add_new_country("Russia", 2, ["Moscow", "Saint Petersburg"]) # You've ...
true
d79f3396308cb01617684bd98f54c9cb6eba6299
kmrgaurav11235/PythonProBootcamp
/section_02_beginners/lesson_01_function_parameters/04_prime_number_checker.py
1,051
4.3125
4
# Prime numbers are numbers that can only be cleanly divided by itself and 1. # https://en.wikipedia.org/wiki/Prime_number # You need to write a function that checks whether if the number passed into it is a prime number or not. # e.g. 2 is a prime number because it's only divisible by 1 and 2. # But 4 is not a prime n...
true
f02212f56d1158e238d64c40591fe62e4947ebe4
kmrgaurav11235/PythonProBootcamp
/section_04_intermediate/lesson_06_tkinter_args_and_kwargs/01_creating_windows_and_labels.py
611
4.40625
4
import tkinter window = tkinter.Tk() # Create a new window window.title("My First GUI Program") # The size of the window will adjust automatically to fit all the components. However, we can set a minimum size window.minsize(width=500, height=300) # Label my_label = tkinter.Label(text="I am a label", font=("Arial", ...
true
fb00b2bf5794ea619cc67ed4bc7f58a1f276950f
kmrgaurav11235/PythonProBootcamp
/section_03_intermediate/lesson_06_instances_states_n_higher_order_functions/03_turtle_race.py
1,687
4.4375
4
from turtle import Turtle, Screen from random import randint window_width = 500 window_height = 400 is_race_on = False screen = Screen() # Since the size of window is important, we will not use the default size screen.setup(width=window_width, height=window_height) user_choice = screen.textinput(title="Make your be...
true
6727b518a4f76bbf41e33aa0e052f363a4412556
kmrgaurav11235/PythonProBootcamp
/section_01_beginners/lesson_04_randomisation_and_lists.py/02_lists.py
1,525
4.65625
5
states_of_america = ["Delaware", "Pennsylvania", "New Jersey", "Georgia", "Connecticut", "Massachusetts"] print(states_of_america[4]) # Negative index print(states_of_america[-1]) # Modification states_of_america[2] = "Maryland" print(states_of_america) # Append states_of_america.append("South Carolina") print("\nNe...
true
3402d12910927075e30423b314d85dbf2b3d31e2
Ravi-Nikam/Python-Programs
/zip.py
232
4.125
4
#zip function combine multiple list 1 by 1 and return into the tuple #and go throw the minimum list list1=[1234,34,54,3,"f",54,56] list2=[1232,342,542,32,45] list3=[12] x=zip(list1,list2,list3) for i in x: print(i)
true
de1d1409092e06f618a81123762c155f93165dc7
dxvidr/cscoursework
/Python/Asessment.py
888
4.15625
4
#User inputs information f = open("Usernames and passwords.txt","a") name = input("Please enter your name: ") age = input("Please enter your age: ") password = input("Please enter a password: ") username = "" for i in range(3): #Loops for the first 3 letters of the name username += (name[i]) username += age...
true
e7ab4a29a3f2e0b83c8c765ceed5388b54f63463
luomeng007/LintCode
/LintCode0022_listFlatten.py
1,836
4.125
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 4 10:25:06 2020 @author: 15025 """ # %% list1 = [[1,1],2,[1,1]] print(len(list1)) # 3 # %% # 需要递归调用!!!! class Solution(object): # @param nestedList a list, each element in the list # can be a list or integer, for example [1,2,[1,2]] # @re...
true
66266b7211cec47457dfb8ea719d967731f1632d
acheun1/05.FunctionsIntermediate_I
/FunctionsIntermediate_I.py
1,218
4.3125
4
#Functions Intermediate I #2018 09 14 #Cheung Anthony # As part of this assignment, please create a function randInt() where # • randInt() returns a random integer between 0 to 100 # • randInt(max=50) returns a random integer between 0 to 50 # • randInt(min=50) returns a random integer between 50 to 100 # • randInt(m...
true
42b2e49f593923684200e17a942d89c333ea9046
makurek/pybites
/intermediate/intermediate-bite-70-create-your-own-iterator.py
727
4.28125
4
""" In this Bite you make an iterator called EggCreator by implementing the __iter__ and __next__ dunder methods (as dictated by the iterator protocol). Have it receive an int called limit which is the max number of eggs to create. It then generates eggs of randomly chosen colors from the COLORS constant. Make sure y...
true
f56da79cdd43320e79d65dda16a564918398f85b
KaranDSharma/CS-Projects
/CSCI/Recitation 13/rec13.py
2,194
4.28125
4
# Algorithm: prints input # 1. just returns what you parse into it # Input parameters: param of no specified type # Output: param # Returns: ø def print_param(param): print (param) #just prints this thing # Algorithm: checks if number is odd or even # 1. if remainder when dividing input value by 2 is 0, ...
true
396a8fdcfb1f23bd6891db3a651f2102db4ae10d
jason3189/Mr.zuo
/Mr.左/month01/代码/day16/exercise02.py
288
4.25
4
list = [2,3,4,6] list01=[] # for item in list: # if item >= 3: # result=item # list01.append(result) # print(list01) result01=[ item for item in list if item >= 3 ] print(result01) result02=(item for item in list if item >= 3 ) print(result02)
true
8d961ffba4c82d0c2b5f78cd3200eb3e34778ebf
travisreed-dfw/TeamTreeHouse-Python-Basics-Project
/masterticket.py
1,660
4.15625
4
TICKET_PRICE = 10 SERVICE_CHARGE = 2 tickets_remaining = 100 # Create the calculate_price function. It takes the number of tickets and returns # TICKET_PRICE * amount_of_tickets def calculate_price(amount_of_tickets): # Create a new constant for $2 service charge # Add service charge to our result ...
true
a1a28ca767e4fbfba3223118f5bca2817c000b83
RishabhK88/PythonPrograms
/2. PrimitiveTypes/EscapeSquences.py
556
4.15625
4
# Escape squences are used as \e where e is the character to be printed # they are used when a character is to be added and syntax doesnt allow it # For example if there is to be a quotation mark in string, it is not possible # because quotation marks will end the string right there, so we use escape # sequence -> ...
true
26a81dbc44c822bcc08b3be1873af51a0837b6cd
RishabhK88/PythonPrograms
/7. Classes/ClassVsInstanceAttributes.py
698
4.34375
4
class Point: default_color = "red" # Class level attribute. We can read this via class # reference(line 19) or object referance(line 18) def __init__(self, x, y): # Constructor self.x = x self.y = y def draw(self): print(f"Point ({self.x}, {self.y})") point = ...
true
9efa8eba95193f9fdee3bb09728f9335a4758139
RishabhK88/PythonPrograms
/5. DataStructures/UnpackingLists.py
849
4.90625
5
# Unpacking lists means getting elements of list individeually into multiple variables numbers = [1, 2, 3] first, second, third = numbers print(first) print(second) print(third) # The above line of code is same as # first = numbers[0] # second = numbers[1] # third = numbers[2] # While unpacking the number of ...
true
e184edbbb160452f208b6da5f2386a8f19cd52f6
RishabhK88/PythonPrograms
/2. PrimitiveTypes/Strings.py
592
4.1875
4
course = "Python Programming" message = """Hi This is me 3 quotes are used for multiple line strings""" print(message) print(len(course)) # len() is used to get length of string print(course[0]) print(course[-1]) # negative index is used to access characters from string print(course[0:2]) # above is used to ...
true
f63bb399e5f554ebb73d743661fac42a0d1d13c4
rgraybeal/LearnPython3TheHardWay
/ex25.py
1,521
4.21875
4
#sentence = "All good things come to those who wait" def reload(): print("Yes, I reloaded with reimport") def reload_2(): print("Yes, I reloaded with reimport") def break_words(stuff): """This function will break up words for us.""" words = stuff.split() print(">>Break_words ...
true
a7d1f0db2230f260efd4d2af391546824558f9cb
mynameischokan/algorithms
/basics/0_3_matrix_addition.py
1,035
4.21875
4
''' Given function that takes 2 matrix lists and `int` Returns the addition result of two matrix lists in range of `int` argument ''' result = [ [0, 0, 0], [0, 0, 0], [0, 0, 0], ] def add(matrix_1, matrix_2, n): for i in range(n): for j in range(n): result[i][j] = matrix_1[i][j] +...
true
b09cc3956ad29fc3fd3fdf3c9d8defd4d4b62834
dejanstojcevski/python_tricks
/standard_library_by_example/text/regular_expressions.py
1,976
4.5
4
import re ''' This module shows basic regular expressions in python with re module. Explains basic methods and classes used in re matching. ''' text = 'Does this text match this the pattern?' # normal re matching match = re.search(r'\bthis', text) # returns new instance of class re.Match. re Match is subclass of re...
true
89b6d2a3cd18042c07f4239909eae4672b40b196
subhamb123/Python-Projects
/Level 4/Return Summary 2.py
1,429
4.125
4
import random import pygame pygame.init() def make_random_word(): 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"] word = [] for i in range(10): word.append(random.choice(alphabet)) return word def ...
true
577cf305750ec9f0251be617ed15845f0b252712
subhamb123/Python-Projects
/Level 1/Count Items 3.py
276
4.1875
4
numbers = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"] three_letters = 0 for number in numbers: if len(number) == 3: three_letters += 1 print(str(three_letters) + " of the numbers from 1 to 10 are written with three letters.")
true
137c0bc7f95dbf7e379c15cd0ceee9b206bcb26a
zyzyx03/cookbook
/Python/python_sandbox/python_sandbox_starter/classes.py
1,236
4.40625
4
# A class is like a blueprint for creating objects. An object has properties and methods # (functions) associated with it. Almost everything in Python is an object # Create class class User: # Constructor def __init__(self, name, email, age): self.name = name self.email = email self.a...
true
f5204980f44c4814a7253763ba8d8cdea6e5f734
lsteiner9/python-chapters-4-to-6
/dateconvert2.py
559
4.21875
4
# dateconvert2.py import string def main(): day = int(input("Please enter day, month, and year numbers: ")) month = int(input()) year = int(input()) date1 = str(month) + "/" + str(day) + "/" + str(year) months = ["January", "February", "March", "April", "May", "June", "July", "August", "Septembe...
true
200ae625dbc19324dfd5480a6dd37c79cd3c7e7e
lsteiner9/python-chapters-4-to-6
/wcpython.py
540
4.125
4
# wcpython.py def main(): print("This program counts the number of lines, words, and characters in " "a file.") filename = input("Enter filename: ") file = open(filename, 'r') lines = file.readlines() wordcount = 0 charcount = 0 for line in lines: charcount += len(line) ...
true
4adfe9921a80b42eb572166d3034823cf200417b
michaelh21/COOP2018
/Chapter03/U03_Ex07_DistanceForm.PY
1,305
4.28125
4
# 3.1.7.py # # Author: Michael Hu # Course: Coding for OOP # Section: A2 # Date: 25 Sep 2018 # IDE: PyCharm # # Assignment Info # Exercise: 7 # Soource: Python Programming # Chapter: 3 # # Program Description # Determine the distance between two user input points on a graph # # Algorithm (pseudocode) # Print Introducti...
true
5beee203c8134ca3f86c4b7cfda0e5042f1fe219
michaelh21/COOP2018
/Chapter06/U06_Ex01_OldMacDonald.py
1,452
4.28125
4
# U06_Ex01_OldMacDonald.py.py # # Author: Michael Hu # Course: Coding for OOP # Section: A3 # Date: 14 Jan 2019 # IDE: #{PRODUCT_NAME} # # Assignement Info # Exercise: 01 # Source: Python Programming # Chapter: 06 # # Program Description # This program writes the Old MacDonald song with lyrics for 5 different ...
true
c9c4d96d3dea40531354cce2cdc567f0f7799e0e
michaelh21/COOP2018
/Chapter06/U06_Ex07_FibonacciFunction.py
1,091
4.4375
4
# U06_Ex07_FibonacciFunction.py.py # # Author: Michael Hu # Course: Coding for OOP # Section: A3 # Date: 14 Feb 2019 # IDE: #{PRODUCT_NAME} # # Assignement Info # Exercise: 07 # Source: Python Programming # Chapter: 06 # # Program Description # This program outputs the number in the Fibonacci sequence that is ...
true
ba969d5290e9352f7ccf4aeeae37a0393a5683b9
michaelh21/COOP2018
/Chapter07/U07_Ex05_BMI.py
939
4.375
4
# U07_Ex05_BMI.py.py # # Author: Michael Hu # Course: Coding for OOP # Section: A3 # Date: 25 Feb 2019 # IDE: #{PRODUCT_NAME} # # Assignement Info # Exercise: # Source: Python Programming # Chapter: # # Program Description # This program tells the user their BMI and their health range. # # # Algorithm (pseud...
true
8259d4eba1cd3d281867409800b75f5c7051e55c
michaelh21/COOP2018
/Chapter02/U02_Ex09_ConvertFtoC.PY
654
4.125
4
# Fahr.py # # Author: Michael Hu # Course: Coding for OOP # Section: A2 # Date: 31 Aug 2018 # IDE: PyCharm # # Assignment Info # Exercise: 9 # Soource: Python Programming # Chapter: 2 # # Program Description # Converts Fahrenheit into Celsius # # Algorithm (pseudocode) # Print Introduction # Get input # Convert C to F ...
true
fc4fb22eb27658bb7c7cf05d5dcb690f99451180
Ahmad-Alawad/fizzbuzz-python
/fizz_buzz_basic.py
392
4.3125
4
def fizz_buzz(num): """ Return Fizz if number is divisible by 3 only Return Buzz if number is divisible by 5 only Return FizzBuzz if number is divisible by 3 and 5 Return number otherwise """ if num%3 == 0 and num%5 == 0: return "FizzBuzz" elif num%3 == 0: return "Fizz" ...
true
0c6f5517931ee6f2fdf8bdc854f3699572ead60b
rohanganguly/random_minor_projects
/string_reverse_small.py
724
4.375
4
"""" program to reverse string - Random Codes Repository- Rohan Ganguly """" import string #importing the string library #input the string into a variable string1 string1= input("Enter the string to reverse:") #the split function to split the input string and save it as a list #the list split contains the wo...
true
15b174014ae58e98a79a4148ab95b94e202967ac
shade-12/python-dsal
/08_Binary_Search/integer_square_root.py
632
4.21875
4
import math def integer_square_root_math(k): """ Returns the largest integer whose square is less than or equal to k. k is a non-negative integer. """ return math.floor(math.sqrt(k)) def integer_square_root_bin(k): """ Returns the largest integer whose square is less than or equal to k. ...
true
03d7a31a6f50ce374aa6fd3e81f6a6fb4ddd5e00
nikitapotdar/break-statment-in-python
/FindNumberDiv3and5.py
965
4.1875
4
'''Program to find first number divisible by 3 & 5 Write a program to print the first +ve number 'n' in a given range found to be divisiable by 3 as well as 5. input -> two numbers for a range r1(lower) & r2(higher) Result output -> <n> is first number divisible by 3 & 5 between <r1> & <r2> ''' print('Find firs...
true
e93cec23bc244a7da0ffe8e22fdc8c779a858550
graciella12/python
/password.py
307
4.125
4
print('login') for tries in range (3,0,-1): print (f'you have {tries} tries') username = input('enter username ') password = input('enter password ') if username == ('gras') and password == ('123'): print ('login sucess') break else: print ('login invalid')
true
96a75c8ab4e30ce69cdfed53a7476154464668dd
ishtiaque06/file_io_and_text_normalization
/Tokenizer.py
1,968
4.21875
4
# tokenizer takes a string and returns a list of the sentences contained in that string. def tokenizer(text): end_punctuation = ['.', '!', '?', ':',';'] sentence = '' sentences = [] sentences_as_a_list = text.split() index = 0 #This while block splits the input text by spaces and adds a space after the endof ...
true
bb76f05649656cab7b969cf8c587587ce8730af7
psuri15/Python2014
/factor_calculator_in_progress.py
410
4.1875
4
def is_multiple(x,y): '''is_multiple(x,y) -> bool returns True is x is a multiple of y, False otherwise''' # check if y divides evenly into x if (x % y == 0): print(y) def sum_of_proper_divs(n): total = 0 x = n y = 1 while y != x: is_multiple(x, y) if (x % y == 0...
true
1ec3de7bc25de62a70d5a3ad141a250e7099b20a
ajsautter/3900-Activity3
/grade_calculator.py
1,918
4.15625
4
# Andrew Sautter # ISQA 3900 9/10/2021 #The purpose of this program is to be able to input values and those values # be converted to a grading system def display_title(): #initial prompt to the user print("Welcome to Grade Calculator") #function to ask user for point value, add null value preventions def get_...
true
f6cd2d3ecc22c9a00372e6969ecba1127cb45578
skardude12345/project-97
/project-97/main.py
672
4.125
4
import random chances = 5 number = random.randint(1, 50) while chances <= 5: guess = int(input("Guess the number between 1 and 50: ")) if guess != number and chances > 0: if guess < number: chances -= 1 print("You didn't get it right. The number is higher than",guess) ...
true
ffddb3fba3d01f3209ceadf007dd2af93cb21a40
yanil3500/code-katas
/src/counting_duplicates.py
892
4.34375
4
""" Kata: Counting Duplicates - Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphanumeric characters, including digits, uppercase and lowercase alphabets. ...
true
0a289dd2e763225e0c2d94a93540a97273b03a49
mavjav-edu/introducing-lists-EdwardAo
/tiy8.py
866
4.3125
4
places=['tokyo','germany','russia','france','chicago','mexico','canada','brazil','china','japan','estonia','panama','samoa','luxemborg','andorra','united states of america','chile','argentia','marshall islands','belize','australia','austria','spain','gibralter','jersey','uganda','sudan','egypt','namibia','algeria','par...
true
bf41b56aef0fee468d7cda9c31ad103320be9d0f
ScottSko/Python---Pearson---Third-Edition---Chapter-8
/Chapter 8 - Scratch Paper.py
749
4.28125
4
def main(): index = -1 name = 'Scott' reverse_name_string = '' first_name = input("Please enter you first name: ") middle_name = input("Please enter your middle name: ") last_name = input("Please enter your last name: ") full_name = (first_name + " " + middle_name + ' ' + la...
true
3d7d239463849ab07254c51693f6c259e4fcdb18
ScottSko/Python---Pearson---Third-Edition---Chapter-8
/Chapter 8 - Algorithm Workbench - #8 #9 #10.py
384
4.125
4
def main(): my_string = "Hello World" new_string = my_string[0:3] print(new_string) ############################ backwards_string = my_string[-3:] print(backwards_string) ############################# my_string_list = "cookies>milk>fudge>cake>ice cream" my_...
true
ae8e809c481d12a38a9ddb1c39e994a59e9731e1
wesleysinks/daysalive
/daysalive.py
1,233
4.125
4
import sys import os import datetime def clearscreen(): if 'nt' in sys.platform.lower(): os.system('cls') else: os.system('clear') def intinput(inputstring): while True: try: return int(input(inputstring)) break except ValueError: print("...
true
f617008159e7b08e14288243c58de0a5090f8d18
blanksblanks/Python-Fun
/46-Simple-Ex/ex17.py
1,150
4.40625
4
def reverse(text): return text[::-1] def palindrome_recognizer(text): ''' (str) -> bool Defines a version of a palindrome recognizer that also accepts phrase palindromes such as, "Dammit, I'm mad!" Note that punctuation, capitalization, and spacing are usually ignored. ''' print text text = text.lower() pu...
true
a11700ca8b7906c979a19bc56cd27f87ed6e4edb
blanksblanks/Python-Fun
/LPTHW/ex5.py
1,583
4.5
4
name = 'Molly' age = 2 # estimation cause she's a stray kitty height = 22.5*2.54 # in to cm weight = 10.0*0.453592 # lb to kg eyes = 'Brown' teeth = 'White' hair = 'Black' print "Let's talk about %s." % name print "She's %d years old." % age print "She's %d inches tall." % height print "She's %d pounds heavy." % weigh...
true
f03bbd6d8b2a744c7ed8d553bbf791620fbc78d0
blanksblanks/Python-Fun
/46-Simple-Ex/ex25.py
1,351
4.3125
4
import re def make_ing_form(verb): ''' (str) -> str Defines function make_ing_form, which given an infinitive verb returns present participle form. In English, the present participle is formed by adding the suffix -ing to the infinite form: go -> going. A simple set of heuristic rules can be given as follows: 1...
true
4c0a82e18348e4223817d4de55351200617021cf
blanksblanks/Python-Fun
/46-Simple-Ex/ex28.py
354
4.4375
4
def find_longest_word(words): ''' (list) -> int Defines a function find_longest_word() that takes a list of words and returns the length of the longest one, using only higher order functions. ''' return max(map(len, words)) print 'Printing longest word in the list...' print find_longest_word(['hi', 'hello', 'gree...
true
a5ada07cdbffccd106bb06bd4b977f103512b1b8
blanksblanks/Python-Fun
/Palindrome/palindrome.py
1,016
4.5
4
# uses slicing feature to reverse text # seq[a:b] code makes slices froms sequence a to b # providing third argument that determines the 'step' by which slicing is done # default step is 1, giving negative step -1 returns text in reverse def reverse(text): return text[::-1] # if the original text and reversed are ...
true
0be920998dfa6bc850d5a8defb40638c8966a1da
Priya2120/dictionary
/que 17.py
460
4.5625
5
# Use dictionary to store antonyms of words. E.g.- 'Right':'Left', 'Up':'Down', etc. # Display all words and then ask user to enter a word and display antonym of it. word = {'right':'left','up':'down','good':'bad','cool':'hot','east':'west'} print ("Enter any word from following words") for i in word.keys(): prin...
true
7d9725d15b09992e7f8f9147971dd6a548327233
j-ckie/htx-immersive-08-2019
/02-week/1-tuesday/labs/j-ckie/01_phonebook_j-ckie.py
1,022
4.40625
4
# Given the following dictionary, representing a mapping from names to phone numbers: # phonebook_dict = { # 'Alice': '703-493-1834', # 'Bob': '857-384-1234', # 'Elizabeth': '484-584-2923' # } # Write code to do the following: # Print Elizabeth's phone number. # Add a entry to the dictionary: Kareem's number...
true
cf0e1597da21dd26e8f3469ded818b228c9bb75d
j-ckie/htx-immersive-08-2019
/02-week/2-wednesday/labs/j-ckie/02_celsius_to_fahrenheit.py
401
4.21875
4
# 2. Celsius to Fahrenheit conversion # The formula to convert a temperature from Celsius to Fahrenheit is: # F = (C * 9/5) + 32 # Write a function that takes a temperature in Celsius, converts it Fahrenheit, and returns the value. def celsius_conversion(): temperature = int(input("Enter a temperature in Celsius...
true
fe5b3fadbdc16bcbb523294e7b4898e22d853900
CarloMcG/BTYSE-2015
/dictionary_check.py
455
4.15625
4
# checks a given example password against the Oxford English Dictionary string = input("password: ") def check(): datafile = open('dictionary.txt') found = Falsefor line in datafile: if string in line: found = True break return found found = check() if found: print ("This password ...
true
8dd9a894879915a4a789d7d7ab4f5cb9f2873e4e
ShadyHegazy/PythonCode
/Occurences of a word in a string.py
376
4.28125
4
# prints the number of times the string 'bob' occurs in a string s\. For example, if s = 'azcbobobegghakl', then the program will print "Number of times bob occurs is: 2" count = 0 x = 0 y = 1 z = 2 while (z < len(s)): if s[x] == 'b' and s[y] == 'o' and s[z] == 'b': count += 1 x += 1 y += 1 z +=...
true
55ddb07cc4d52ac8e7511426cec12918c373278a
surajkumar26/GPIO_Control_Via_Webpage
/web_server/test_2.py
937
4.21875
4
# Write a python program to fetch the data from the two files and check the matching words present in the both files. # Check how many times matching words repeated in the both files and print which files having less number of repeated words and its count value. # Example # # File1.txt: # # “test # python # t...
true
9c08630f966b08f7a21b9fbd89cdb2ccd90f73b1
ahirst2016/ahirst2016.github.io
/my_website/Countingcoins.py
984
4.15625
4
'''Coin Counter Description: This program converts the amount of money input by the user into the equivalent amount using the fewest coins possible(quarters, dimes, nickles, and pennies) by Aaron Hirst 6/25/2017''' quarters = 0 dimes = 0 nickles = 0 pennies = 0 def c...
true
48d878bda4745416936c1effc119d9c44bbbae23
jsweeney3937/PRG105
/wk5_initals.py
639
4.1875
4
def get_user_input(): # gets users name user_name = input("Enter your first, middle, and last name. ") # returns users name return user_name def main(): # sets name to what is returned from function get_user_input name = get_user_input() # splits the string dependant on space...
true
6e74dd71c5a0879c05378a6cf83bb05aa8f3cefc
qscez2001/wsm_project1
/codes/sort.py
2,889
4.375
4
# https://www.geeksforgeeks.org/python-indices-of-n-largest-elements-in-list/ # https://kanoki.org/2020/01/14/find-k-smallest-and-largest-values-and-its-indices-in-a-numpy-array/ # Python3 code to demonstrate working of # Indices of N largest elements in list # using sorted() + lambda + list slicing # initializ...
true
bc5815defe2dba4a04e5f27d3f8627f3f3813013
amonik/pythonnet
/employee.py
2,015
4.40625
4
class Employee: """ Initialize variables""" def __init__(self): self.__name = " " self.__designation = 0 self.__salary = 0 """All the getters and setters are used because we use private variables with __""" """The set_name method sets the set_name attribute""" def set_name(s...
true
96d401e84a7a0bdd33049b91acec03566574ba28
amonik/pythonnet
/ackermann.py
1,346
4.15625
4
# Define the main function with error correction to ask the user for the numbers. def main(): while True: try: m = int(input("Please enter in a number for m >= 0: ")) break except ValueError: print("Must be a non-negative number. ") except RuntimeError: ...
true
2bf2f957066cc1bdd2a485281111e450ab2926e8
eugenejw/Leetcode
/rotate_matrix.py
1,113
4.21875
4
''' You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? ''' import copy class Solution(object): def __init__(self, matrix): self._matrix = matrix def rotate(self): """ :type matrix: List[Lis...
true
75de28475e91bd73b61d4d06d61e7adf92cd9eea
salilvaidya15/data_structures
/linked_list/reverse_list_iterative.py
790
4.28125
4
from lll import LinkedList,Node def reverseList(L1): last = None current = L1.head # traverse list # set previous node (last) to current next # new last is current # current is next node while current: nextNode = current.get_next() current.set_next(last) last ...
true
c61df8c498afd37f5cc8025dda100f9090cdd93a
elenameyerson/ToolBox-WordFrequency
/frequency.py
1,949
4.4375
4
""" Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string def get_word_list(file_name): """ Reads the specified project Gutenberg book. Header comments, punctuation, and whitespace are stripped away. The function returns a list of the words used in the book as a li...
true
4c2407041252130241ba0fa7c0fd779fd1163cc4
georanson/Python-Class
/Chapter 1/chaos.py
721
4.125
4
# Author: Geoffrey Ranson # SN# G11002201 # Date: mm/dd/yyyy # File: chaos.py # Description: Deomstrates a chotic function """ ALGORITHM: The pseudocode description for how the program performs its tasks. Write as many lines as necessary in this space to describe the method selected to solve the problem at h...
true
3bec6a7c13774b9c0a010c07adbe9197631973d8
Jenoe-Balote/ICS3U-Unit5-05-Python
/mailing_address.py
2,108
4.4375
4
#!/usr/bin/env python3 # Created by: Jenoe Balote # Created on: May 2021 # This program formats a proper mailing address for the user def address_format(name, street_number, street_name, city, province, postal_code, apartment_number=None): # This function formats the address address = nam...
true
dc6d531452fd7c4c2e473a767a7de1a26dbda9ef
Ashwinanand/Python
/Dictonary_part1_assignment1.py
855
4.34375
4
""" Author: Student ID : 500187737 Student Name : Anand Veerarahavan """ """About Dictionaries : Dictionaries are used to store data values in key:value pairs. A dictionary is a collection which is ordered*, changeable and does not allow duplicates.""" # Creating a dictonary : dictionary1 = {'studentName': 'An...
true
410a415e085235a13235c7a52bd07124464c1569
Ashwinanand/Python
/class_assignment2_python.py
667
4.25
4
Name = input("Enter a name :\t") Degree_Name = input("Enter the degree name :\t") Credits_obtained = int(input("Enter the Credit taken so far :\t")) Credits_total = int(input("Enter the total number of credits required :\t")) Credits_remaining = int(Credits_total) - int(Credits_obtained) if Credits_remaining > 0:...
true
2923cfd5a67ce1b2d223dddaec3f39b813f5ba62
TheFloatingString/Projectile
/projectile.py
2,723
4.34375
4
#!/usr/bin/env python """ THIS PROGRAM CALCULATES THE DISTANCE OF A PROJECTILE BASED ON ITS SPEED AND ITS ANGLE RELATIVE TO THE GROUND THIS PROGRAM IS COMPLETELY TEXT-BASED MATH EQUATIONS WERE MADE AVAILABLE WITH THE HELP OF QUISHI WANG PYTHON 3 SCRIPT PROGRAMMED BY LAURENCE LIANG """ # IMPORT MODULES from math impor...
true
d3d7c32ee6df1c93bd4089a03642480c00a140bb
Verzivolli/Python_Codes
/Tkinter/GUI From udemy/User_interface.py
1,062
4.1875
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 26 10:09:22 2019 @author: C.R.C """ from tkinter import * # create window object window = Tk() def km_to_miles(): #print(e1_value.get()) ##on insert END will place the text at the end of existing text #t1.insert(END, e1_value.get()) miles = float(e1_val...
true
b4b7f0951e4cbd820f2d4f0c79e34a1841b35f10
jawed321/Spectrum_Internship_Tasks
/Task1/prgm3.py
562
4.3125
4
# Python Program to enter an integer ‘n’ find all prime numbers from 1 to n. #to check if prime no. def checkPrime(n): if n <= 1: return False for i in range(2, n): if n % i == 0: return False return True #print prime no. def printPrime(n): print("Prime num...
true
92b36c4817a044ef628fc87a9eb3a444a021ac6e
vhaghani26/Learning_Python
/MCB 185 (Korf Course)/Class Notes/12_functions_extra.py
2,585
4.40625
4
#!/usr/bin/env python3 import random # Move the triple quotes downward to uncover each segment of code """ # -------------------- FULL FUNCTION SYNTAX -------------------- # Functions often have a fixed number of positional arguments # For example, fun1() has 2, and the order matters def fun1(name, age): print(n...
true
025b9309083bb27b87ce53baf79f6a81b086e211
vhaghani26/Learning_Python
/MCB 185 (Korf Course)/Class Notes/03_text.py
921
4.40625
4
#!/usr/bin/env python3 # Move the triple quotes downward to uncover each segment of code """ # Variables with text are called strings s = 'ACGT' # a string # Square brackets let you access sub-strings as 'slices' # Follow closely below, because the endpoints can be confusing # The first number before : is the star...
true