blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4d68472475d80f98b64756de3cca5e8f90e85241
DanCowden/PyBites
/19/simple_property.py
775
4.1875
4
""" Write a simple Promo class. Its constructor receives two variables: name (which must be a string) and expires (which must be a datetime object) Add a property called expired which returns a boolean value indicating whether the promo has expired or not. """ from datetime import datetime NOW = datetime.now() cla...
true
a94d66b0405ab15bf992ff22fc8d72d5983d9828
denis-trofimov/challenges
/leetcode/interview/strings/Valid Palindrome.py
781
4.1875
4
# You are here! # Your runtime beats 76.88 % of python3 submissions. # Valid Palindrome # Solution # Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. # Note: For the purpose of this problem, we define empty string as valid palindrome. # Example 1: # Inpu...
true
7e18ee8ce20624b5ac6dfc36b9ddf245c5fbc043
derekdeibert/derekdeibert.github.io
/Python Projects/RollDice.py
1,025
4.25
4
"""This program will roll a dice and allow a user to guess the number.""" from random import randint from time import sleep def get_user_guess(): """Collects the guess from user""" user_guess=int(raw_input("Guess which number I rolled!:")) return user_guess def roll_dice(number_of_sides): first_roll=randint(1...
true
40b2e7bc13c6dc1ef9c10a5e782f5310e0ef577c
rpw1/351-Final-Project
/src/queue.py
2,099
4.28125
4
class ItemQueue: """ A class to store distances in a priority queue and labels in a list with maching indices with the distances. Methods ------- insert(item : int, label : str) This function inserts the distance from least to greatest in order in the items list and places th...
true
c3613d1209e07c7f4c04d43d3159b530c884dbc7
jaadyyah/APSCP
/2017_jaadyyahshearrion_4.02a.py
984
4.5
4
# description of function goes here # input: user sees list of not plural fruit # output: the function returns the plural of the fruits def fruit_pluralizer(list_of_strings): new_fruits = [] for item in list_of_strings: if item == '': item = 'No item' new_fruits.append(item) ...
true
e1c83664bbc031c2c53516d7aac44ad4acb500b4
BiplabG/python_tutorial
/Session II/problem_5.py
374
4.34375
4
"""5. Write a python program to check if a three digit number is palindrome or not. Hint: Palindrome is a number which is same when read from either left hand side or right hand side. For example: 101 or 141 or 656 etc. """ num = int(input("Enter the number: \n")) if (num % 10) == (num // 100): print("Palindrome ...
true
7b3b9d90b2dd4d27ac2875a2471791308d647ac3
BiplabG/python_tutorial
/Session I/problem_3.py
445
4.34375
4
""" Ask a user his name, address and his hobby. Then print a statement as follows: You are <name>. You live in <address>. You like to do <> in your spare time. """ name = input("Name:\n") address = input("Address:\n") hobby = input("Hobby:\n") print("You are %s. You live in %s. You like to do %s in your spare...
true
ab1ae9f26453fdee0d0e5ee8a0c0b604bc193d83
BiplabG/python_tutorial
/Session II/practice_4.py
240
4.1875
4
"""4. Write a python program which prints cube numbers less than a certain number provided by the user. """ num = int(input("Enter the number:")) counter = 0 while (counter ** 3 <= num): print(counter ** 3) counter = counter + 1
true
220e17a0bce87d84f2dbea107b63531dfe601043
HLNN/leetcode
/src/0662-maximum-width-of-binary-tree/maximum-width-of-binary-tree.py
1,816
4.25
4
# Given the root of a binary tree, return the maximum width of the given tree. # # The maximum width of a tree is the maximum width among all levels. # # The width of one level is defined as the length between the end-nodes (the leftmost and rightmost non-null nodes), where the null nodes between the end-nodes that wou...
true
bde099ab0828e59824a392ce9115533e2a3f0b08
HLNN/leetcode
/src/0332-reconstruct-itinerary/reconstruct-itinerary.py
1,866
4.15625
4
# You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it. # # All of the tickets belong to a man who departs from "JFK", thus, the itinerary must begin with "JFK". If there are multiple vali...
true
e4d43d82683865b78715159309da5fd4256a5d63
HLNN/leetcode
/src/1464-reduce-array-size-to-the-half/reduce-array-size-to-the-half.py
1,211
4.15625
4
# You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. # # Return the minimum size of the set so that at least half of the integers of the array are removed. # #   # Example 1: # # # Input: arr = [3,3,3,3,5,5,5,2,2,7] # Output: 2 # Explanati...
true
d1a9f49300eb997d4b2cb1da84b514dff6801a7f
HLNN/leetcode
/src/0006-zigzag-conversion/zigzag-conversion.py
1,495
4.125
4
# The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) # # # P A H N # A P L S I I G # Y I R # # # And then read line by line: "PAHNAPLSIIGYIR" # # Write the code that will take a string and...
true
f09cc935dafa2b61cff7ed80ace981be72c79775
HLNN/leetcode
/src/2304-cells-in-a-range-on-an-excel-sheet/cells-in-a-range-on-an-excel-sheet.py
1,817
4.125
4
# A cell (r, c) of an excel sheet is represented as a string "<col><row>" where: # # # <col> denotes the column number c of the cell. It is represented by alphabetical letters. # # # For example, the 1st column is denoted by 'A', the 2nd by 'B', the 3rd by 'C', and so on. # # # <row> is the row number r of the cell...
true
1d3f298d55c7ce39420752fa25a1dc4409feffe9
HLNN/leetcode
/src/0899-binary-gap/binary-gap.py
1,395
4.125
4
# Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n. If there are no two adjacent 1's, return 0. # # Two 1's are adjacent if there are only 0's separating them (possibly no 0's). The distance between two 1's is the absolute difference between...
true
2e15c9101d8471d05afe671d74b46a488ef0edcd
HLNN/leetcode
/src/1888-find-nearest-point-that-has-the-same-x-or-y-coordinate/find-nearest-point-that-has-the-same-x-or-y-coordinate.py
1,769
4.125
4
# You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [ai, bi] represents that a point exists at (ai, bi). A point is valid if it shares the same x-coordinate or the same y-coordinate as your location. # # Retu...
true
8c3a922fa3cd65184efdcaeb3fb5e936f70edcf7
HLNN/leetcode
/src/1874-form-array-by-concatenating-subarrays-of-another-array/form-array-by-concatenating-subarrays-of-another-array.py
2,057
4.25
4
# You are given a 2D integer array groups of length n. You are also given an integer array nums. # # You are asked if you can choose n disjoint subarrays from the array nums such that the ith subarray is equal to groups[i] (0-indexed), and if i > 0, the (i-1)th subarray appears before the ith subarray in nums (i.e. the...
true
e725c199c6fa75ca2f9aa7c85f349c3e71fd249d
HLNN/leetcode
/src/2433-best-poker-hand/best-poker-hand.py
1,984
4.125
4
# You are given an integer array ranks and a character array suits. You have 5 cards where the ith card has a rank of ranks[i] and a suit of suits[i]. # # The following are the types of poker hands you can make from best to worst: # # # "Flush": Five cards of the same suit. # "Three of a Kind": Three cards of the sam...
true
523e1a35af3a9356d503c6fd313bf9c0f8a899af
HLNN/leetcode
/src/0868-push-dominoes/push-dominoes.py
1,885
4.15625
4
# There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right. # # After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the r...
true
4082c4c22dce52ccef9ff68ecd1f8e9ffeb1ec28
HLNN/leetcode
/src/0009-palindrome-number/palindrome-number.py
878
4.28125
4
# Given an integer x, return true if x is a palindrome, and false otherwise. # #   # Example 1: # # # Input: x = 121 # Output: true # Explanation: 121 reads as 121 from left to right and from right to left. # # # Example 2: # # # Input: x = -121 # Output: false # Explanation: From left to right, it reads -121. From rig...
true
9325a332de0902d4ec6c122a4a30c91b6f57e820
HLNN/leetcode
/src/0031-next-permutation/next-permutation.py
2,168
4.3125
4
# A permutation of an array of integers is an arrangement of its members into a sequence or linear order. # # # For example, for arr = [1,2,3], the following are all the permutations of arr: [1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]. # # # The next permutation of an array of integers is the next lexicog...
true
42c47c2470efbde7d9a3446fe9dd2930ab317dc7
HLNN/leetcode
/src/0225-implement-stack-using-queues/implement-stack-using-queues.py
2,179
4.15625
4
# Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and empty). # # Implement the MyStack class: # # # void push(int x) Pushes element x to the top of the stack. # int pop() Removes the element on the top of the ...
true
7d20a7486e2a83d8cafb24a29844276eabf246c0
dexterneutron/pybootcamp
/level_1/removefromtuple.py
431
4.25
4
"""Exercise 8: Write a Python function to remove an item from a tuple. """ def remove_from_tuple(input_tuple,element_index): new_tuple = tuple(el for i, el in enumerate(input_tuple) if i != element_index) return new_tuple input_tuple = ("red", "blue", "orange", "magenta", "yellow") output_tuple = remove_...
true
24fd71a9007cdc5fddb57447486c2544a907f8f0
dexterneutron/pybootcamp
/level_3/listofwords.py
607
4.375
4
"""Exercise 4: Write a Python function using list comprehension that receives a list of words and returns a list that contains: -The number of characters in each word if the word has 3 or more characters -The string “x” if the word has fewer than 3 characters """ def list_of_words(wordlist): output = [len(word) i...
true
3adf5c398a96c0d3355d0e3d0204867538aada7b
ryanfmurphy/AustinCodingAcademy
/warmups/fizzbuzz2.py
1,341
4.3125
4
''' Tue Nov 4 Warmup: Fizz Buzz Deluxe Remember the Fizz Buzz problem we worked on in the earlier Homework? Create a python program that loops through the numbers 1 to 100, prints each number out. In addition to printing the number, print "fizz" if the number is divisible by 3, and "buzz" if the number is divisible ...
true
cc45bf62aa11e67b85a2a9203d4eda8ef01be826
Dahrio-Francois/ICS3U-Unit3-04-Python
/integers.py
531
4.34375
4
#!/usr/bin/env python 3 # # Created by: Dahrio Francois # Created on: December 2020 # this program identifies if the number is a positive or negative # with user input integer = 0 def main(): # this function identifies a positive or negative number # input number = int(input("Enter your number value...
true
fbc8a6cb7144d879af77af67baa5f18797b8ad9e
laithtareq/Intro2CS
/ex1/math_print.py
1,046
4.53125
5
############################################################# # FILE : math_print.py # WRITER : shay margolis , shaymar , 211831136 # EXERCISE : intro2cs1 ex1 2018-2019 # DESCRIPTION : A set of function relating to math ############################################################# import math def golden_ratio(): ...
true
a8501491eda940dd2bc3083dfe185f9e5616ede4
laithtareq/Intro2CS
/ex10/ship.py
1,166
4.3125
4
############################################################ # FILE : ship.py # WRITER : shay margolis , roy amir # EXERCISE : intro2cs1 ex10 2018-2019 # DESCRIPTION : A class representing the ship ############################################################# from element import Element class Ship(Element): """ ...
true
faa5a5c24df378ff14b80d8c1553b1167a93323b
spgetter/W2Day_3
/shopping_cart.py
1,329
4.15625
4
groceries = { 'milk (1gal)': 4.95, 'hamburger (1lb)': 3.99, 'tomatoes (ea.)': .35, 'asparagus (12lbs)': 7.25, 'water (1oz)': .01, 'single use plastic bag': 3.00, } # cart_total = 0 sub_total = 0 # cart = [["Total =", cart_total]] cart = [] def shopping_cart(): print("\n") response = in...
true
18fa77116d86476f37241b8f3682afb906ea3c40
OrevaElmer/myProject
/passwordGenerator.py
416
4.25
4
#This program generate list of password: import random userInput = int(input("Enter the lenght of the password: ")) passWord = "abcdefghijklmnopqrstuv" selectedText = random.sample(passWord, userInput) passwordText = "".join(selectedText) ''' #Here is another method: passwordText ="" for i in range(u...
true
1531e56c78f0d73e0ba7a1236dac4e9054462c1b
Zadams1989/programming-GitHub
/Ch 7 Initials CM.py
603
4.1875
4
username = input('Enter you first, middle and last name:\n') while username != 'abort': if ' ' not in username: print('Error. Enter first, middle and last name separated by spaces.\n') username = input('Enter you first, middle and last name:\n') elif username.count(' ') < 2: print('...
true
d05c196b7e124b78cc0dcfa026d8f53d96f181e5
SumanKhdka/python-experiments
/cw1/hw.py
1,152
4.71875
5
# A robot moves in a plane starting from the original point (0,0). The robot can move toward # UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following: # UP 5 # DOWN 3 # LEFT 3 # RIGHT 2 # The numbers after the direction are steps. Please write a program to compute the distan...
true
67600d998c1be6668871eccbfc4da808f48ac26f
ferraopam/pamela_py_ws
/tripcost.py
435
4.34375
4
#program to calculate trip cost for the given number of people no_of_persons=int(input("Enter the no of persons:")) distance_km=int(input("Enter the distance in KM:")) milage_km=int(input("Enter the milage in KM:")) fuel_price=int(input("Enter the fuel price:")) no_liters_used=distance_km / milage_km total_cost=no_lit...
true
26d65d7914765a8da1cec881f76638bc1de233c6
DrBanana419/oldconfigs
/cobra/test1.py
356
4.21875
4
def squareroot(x): import random import math g=random.randint(int(x-x**2),int(x+x**2)) while abs(x-g**2)>0.00000000000001: g=(g+x/g)/2 return abs(g) print("This programme gives you the sum of a number and its square root, and then takes the square root of the sum") v=float(input("Number: "))...
true
8a8063438376e796c015c4ad69f3cf5c1d331665
Alessia-Barlascini/coursera-
/Getting-Started/week-7/ex_5.1.py
417
4.15625
4
# repeat asking for a number until the word done is entered # print done # print the total # print the count # print the average at the end somma=0 num=0 while True: val=input('Enter a number: ') if val == 'done': break try: fval=float(val) except: print ('Enter a valid number...
true
251990ff68cadf74f694bab1d8f57c1e90a02322
taishan-143/Macro_Calculator
/src/main/functions/body_fat_percentage_calc.py
1,466
4.125
4
import numpy as np ### Be more specific with measurement guides! # Print a message to the user if this calculator is selected. # male and female body fat percentage equations def male_body_fat_percentage(neck, abdomen, height): return (86.010 * np.log10(abdomen - neck)) - (70.041 * np.log10(height)) + 36.76 def ...
true
9d2228ba173c8db9df7f373ce6c56929c729d5d5
esthergoldman/100-days-of-code
/day1/day1.py
915
4.15625
4
# print("day 1 - Python print Function\nThe function is declared like this\nprint('whay to print')") # print("hello\nhello\nhello") #input() will get user input in console then print() will print "hello" and the user input #print('hello ' + input('what is your name\n') + '!') # print(len(input("whats your name\n")...
true
90ef3c860db2956cf54ce04a97c75e4580d420c5
saurabhsisodia/Articles_cppsecrets.com
/Root_Node_Path.py
1,702
4.3125
4
# Python program to print path from root to a given node in a binary tree # to print path from root to a given node # first we append a node in array ,if it lies in the path # and print the array at last # creating a new node class new_node(object): def __init__(self,value): self.value=value self.left=None s...
true
f7146dbc32a1fa35574a429f605df0c5b84e99c9
saurabhsisodia/Articles_cppsecrets.com
/Distance_root_to_node.py
2,044
4.28125
4
#Python program to find distance from root to given node in a binary tree # to find the distance between a node from root node # we simply traverse the tree and check ,is current node lie in the path from root to the given node, # if yes then we just increment the length by one and follow the same procedure. class n...
true
fe35826debe37f105f93785fad827baa3b1a0954
hanwenzhang123/python-note
/basics/16-dictionaries.py
2,727
4.625
5
# A dictionary is a set of key value pairs and contain ',' separated values # In dictionary, each of its values has a label called the key, and they are not ordered # Dictionaries do not have numerical indexing, they are indexed by keys. # [lists] # {dictionaries} # {key:value, key:value, key:value} - dictionary # ke...
true
06d495ba3b49eadafdc696e0d71852bd140932d9
hanwenzhang123/python-note
/basics/09-multidimensional.py
1,335
4.15625
4
travel_expenses = [ [5.00, 2.75, 22.00, 0.00, 0.00], [24.75, 5.50, 15.00, 22.00, 8.00], [2.75, 5.50, 0.00, 29.00, 5.00], ] print("Travel Expenses: ") week_number = 1 for week in travel_expenses: print("* week #{}: ${}".format(week_number, sum(week))) week_number += 1 # console lens(travel_expenses) #...
true
0dc96256d6a7aad684d99fd4e8cfcc126f084484
hanwenzhang123/python-note
/oop-python/26-construction.py
1,652
4.4375
4
# @classmethod - Constructors, as most classmethods would be considered # A decorator is a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure. # Decorators are usually called before the definition of a function you want to decorate. # @classmeth...
true
5c3fdbafac312e38a471b9f62bd03d3c440fdab8
hanwenzhang123/python-note
/file-system/02-creating-paths.py
1,037
4.28125
4
>>> import os >>> os.getcwd() >>> os.path.join(os.getcwd(), 'backups') #join to a new directory called backups >>> os.path.join(os.getcwd(), '...', 'backups') >>> import pathlib >>> path = pathlib.PurePath(os.getcwd()) >>> path2 = path / 'examples' / 'paths.txt' # a txt in the example directory of current path >>> p...
true
b9041a9ed771bec9e539f893a62dff904db0b6bb
hanwenzhang123/python-note
/basics/06-lists.py
2,117
4.34375
4
# lists are a data structure that allow you to group multiple values together in a single container. # lists are mutable, we can change them, data type not matter # empty string literal - "" # empty list literal - [] # .append() - append items, modify exsiting list # .extend() - combine lists # ~ = ~ + ~ - combine and ...
true
0137094b13ee42c90786874c681db1d6066ea92e
hanwenzhang123/python-note
/basics/46-comprehensions.py
1,680
4.625
5
Comprehensions let you skip the for loop and start creating lists, dicts, and sets straight from your iterables. Comprehensions also let you emulate functional programming aspects like map() and filter() in a more accessible way. number range (5, 101) # we have numbers 5 to 100 #loop halves = [] for num in nums...
true
f22d3f4e04543a28fb334a96c30727f1b6ff025f
jackyho30/Python-Assignments
/BMI calculator Jacky Ho.py
236
4.21875
4
weight = input ("Please enter your weight (kg): ") height = input ("Please enter your height (cm): ") height2 = float (height) / 100 bmi = weight / height2 ** 2 print "Your Body Mass Index (BMI) is = %.1f" % bmi, "kg/m^2"
true
06d139b1861e7da522b21caade0f44db78270ffe
jackyho30/Python-Assignments
/Computer guessing random number.py
2,937
4.21875
4
""" Author: Jacky Ho Date: November 10th, 2016 Description: You think of a number between 1-100 and the computer guesses your number, while you tell him if it's higher or lower""" import random def main(): """The computer attempts to guess the number that you guess and you tell it if its low, corre...
true
1aa47746192b62188458fbe1192a203bd15f8532
rajkamal-v/PythonLessons1
/dictonary_data_type.py
1,445
4.1875
4
#A dictionary is a collection which is unordered, changeable and indexed. #In Python dictionaries are written with curly brackets, and they have keys and values. #{1,3,4} - set #doesnt take duplicate keys, if duplicate is given, it will take the latest dict_1 = {"name":"kamal","age":36} print(len(dict_1)) print(d...
true
5561bffdc226cb929ee05f74bcbc184f36bb6d32
MaxMcF/data_structures_and_algorithms
/challenges/repeated_word/repeated_word.py
823
4.21875
4
from hash_table import HashTable def repeated_word(string): """This function will detect the first repeated word in a string. Currently, there is no handling for punctuation, meaning that if the word is capitalized, or at the end of a senctence, it will be stored as a different word. If the string cont...
true
a9f772545af1ba2fb1e4ca48c4b8ad390d600794
laurieskelly/lrs-bin
/euler/euler_4.py
1,078
4.25
4
# A palindromic number reads the same both ways. The largest palindrome made # from the product of two 2-digit numbers is 9009 = 91 x 99. # Find the largest palindrome made from the product of two 3-digit numbers. digits = 3 def largest_palindromic_product(ndigits): largest = 10**ndigits - 1 if is_palind...
true
d3f0a250349a42802aa835e9683dd7fe51d3ac6e
trent-hodgins-01/ICS3U-Unit6-04-Python
/2d_average.py
1,351
4.53125
5
# !/user/bin/env python3 # Created by Trent Hodgins # Created on 10/26/2021 # This is the 2D Average program # The program asks the user how many rows and cloumns they want # The program generates random numbers between 1-50 to fill the rows/columns # The program then figures out and displays the average of all the nu...
true
c838693c51ae2847566c0e635f80f05db7a215c1
Romny468/FHICT
/Course/3.2.1.9.py
282
4.21875
4
 word = input("enter a word: ") while word != 0: if word == "chupacabra": print("You've successfully left the loop.") break else: print("Ha! You're in a loop till you find the secret word") word = input("\ntry again, enter another word: ")
true
02d6002df846e2f11ee5a5e7345f9df1343db18e
Romny468/FHICT
/Course/3.2.1.6.py
394
4.15625
4
import time # Write a for loop that counts to five. # Body of the loop - print the loop iteration number and the word "Mississippi". # Body of the loop - use: time.sleep(1) # Write a print function with the final message. for i in range(6): print(i, "Mississippi") time.sleep(1) if i == ...
true
cf86dabe4955604b47ccc0b7e3881978291827f1
JonathanGamaS/hackerrank-questions
/python/find_angle_mbc.py
372
4.21875
4
""" Point M is the midpoint of hypotenuse AC. You are given the lengths AB and BC. Your task is to find <MBC (angle 0°, as shown in the figure) in degrees. """ import math def angle_finder(): AB = int(input()) BC = int(input()) MBC = math.degrees(math.atan(AB/BC)) answer = str(int(round(MBC)))+'°' ...
true
d0fb9d8752231bc0728a0572e1045eb7694af8c1
JonathanGamaS/hackerrank-questions
/python/string_formatting.py
462
4.15625
4
""" Given an integer, N, print the following values for each integer I from 1 to N: 1. Decimal 2. Octal 3. Hexadecimal (capitalized) 4. Binary """ def print_formatted(number): b = len(str(bin(number)[2:])) for i in range(1,number+1): print("{0}{1}{2}{3}".format(str(i).rjust(b),str(oct(i)[2:]).rjust(b...
true
ec7ba04208c18b82e5f1b1924183b5a0c5ab2166
ekeydar/python_kids
/lists/rand_list_ex.py
637
4.125
4
import random def rand_list3(): """ return list of 3 random items between 1 to 10 (include 1 and include 10) """ # write your code here # verify that your function returns # 3 numbers # not all items of the list are the same always # numbers are in 1,2,3,4,5,6,7,8,9,10 def main(): ...
true
69edca7bcdea35c28a3917d545dcbcab80e18661
MugenZeta/PythonCoding
/BirthdayApp/Program.py
1,260
4.4375
4
#Birthday Program import datetime def printH(): User_Name = input("Hello. Welcome to the Birthday Tracker Application. Please enter your name: ") def GetBirthDay(): #User Inputes Birthday print() DateY = input("Please put the year you where born [YYYY]: ") DateM = input("Please put the year you w...
true
40a210b5eba4a886a5056ce573276175196e98b1
anatulea/PythonDataStructures
/src/Stacks and Queues/01_balanced_check.py
1,475
4.3125
4
''' Problem Statement Given a string of opening and closing parentheses, check whether it’s balanced. We have 3 types of parentheses: round brackets: (), square brackets: [], and curly brackets: {}. Assume that the string doesn’t contain any other character than these, no spaces words or numbers. As a reminder, balance...
true
c07bef00e1f0ea19ca1f09e5de220f5e6ff2e3df
kuba777/sql
/cars7.py
1,688
4.15625
4
# -*- coding: utf-8 -*- # Using the COUNT() function, calculate the total number of orders for each make and # model. # Output the car’s make and model on one line, the quantity on another line, and then # the order count on the next line. import sqlite3 with sqlite3.connect("cars.db") as connection: c = connec...
true
16e12a8c252bc7e83eebe5e13864b871cc9451d7
taylorhcarroll/PythonIntro
/debug.py
901
4.15625
4
import random msg = "Hello Worldf" # practice writing if else # if msg == "Hello World": # print(msg) # else: # print("I don't know the message") # # I made a function # def friendlyMsg(name): # return f'Hello, {name}! Have a great day!' # print(friendlyMsg("james").upper()) # print(friendlyMsg("clayton")) ...
true
df249f359269c4357e81b95506316c4481928da6
mani67484/FunWithPython
/calculate_taxi_fare_2.py
2,437
4.40625
4
""" After a lengthy meeting, the company's director decided to order a taxi to take the staff home. He ordered N cars exactly as many employees as he had. However, when taxi drivers arrived, it turned out that each taxi driver has a different fare for 1 kilometer.The director knows the distance from work to home for ea...
true
d8445e9f19318af7b9afc98acde565443f2e7713
SindriTh/DataStructures
/PA2/my_linked_list.py
2,601
4.21875
4
class Node(): def __init__(self,data = None,next = None): self.data = data self.next = next # Would it not be better to call it something other than next, which is an inbuilt function? class LinkedList: def __init__(self): self._head = None self._tail = None self._siz...
true
c3b0de9516118a12593fdb1c33288105f5720caf
Heena3093/Python-Assignment
/Assignment 1/Assignment1_7.py
558
4.25
4
#7.Write a program which contains one function that accept one number from user and returns true if number is divisible by 5 otherwise return false. #Input : 8 Output : False #Input : 25 Output : True def DivBy5(value): if value % 5 == 0: return True else: return False def main()...
true
f7cbd0159a129526f623685f9edb077d805eefd3
Heena3093/Python-Assignment
/Assignment 3/Assignment3_4.py
836
4.125
4
#4.Write a program which accept N numbers from user and store it into List. Accept one another number from user and return frequency of that number from List. #Input : Number of elements : 11 #Input Elements : 13 5 45 7 4 56 5 34 2 5 65 #Element to search : 5 #Output : 3 def DisplayCount(LIST,x): cnt = 0 ...
true
e11d7e50b4adf445696bea2e2bbd2623c89e3af9
omnivaliant/High-School-Coding-Projects
/ICS3U1/Assignment #2 Nesting, Div, and Mod/Digits of a number.py
1,664
4.25
4
#Author: Mohit Patel #Date: September 16, 2014 #Purpose: To analyze positive integers and present their characteristics. #------------------------------------------------------------------------------# again = "Y" while again == "y" or again == "Y": number = int(input("Please enter a positive integer: ")) ...
true
bdb7d0ff8b7c439147fc677ac68a71ec851d2f2c
omnivaliant/High-School-Coding-Projects
/ICS3U1/Assignment #2 Nesting, Div, and Mod/Parking Garage.py
2,142
4.15625
4
#Author: Mohit Patel #Date: September 16, 2014 #Purpose: To create a program that will calculate the cost of parking # at a parking garage. #------------------------------------------------------------------------------# again = "Y" while again == "Y" or again == "y": minutes = int(input("Please enter the ...
true
3a9bfeb8bf331298b613dc10f85cadd41199e5fb
1sdc0d3r/code_practice
/leetcode/Python/backspace_compare.py
968
4.15625
4
# Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. # Note that after backspacing an empty text, the text will continue empty. def backSpaceCompare(S, T): def back(x): newString = list() for l in x: if l is n...
true
889195f0a205ab24f651a68ae067d356518c4eef
wellesleygwc/2016
/mf/Sign-in-and-Add-user/app/db.py
1,406
4.15625
4
import sqlite3 database_file = "static/example.db" def create_db(): # All your initialization code connection = sqlite3.connect(database_file) cursor = connection.cursor() # Create a table and add a record to it cursor.execute("create table if not exists users(username text primary key not nu...
true
b9b89f34dc087eb641cda31afde4da5022d41968
RakeshNain/TF-IDF
/TF-IDF/task4_30750008.py
591
4.1875
4
""" This function is finding most suitable document for a given term(word) """ import pandas as pd def choice(term, documents): # finding IDF of given term(word) idf = documents.get_IDF(term) # creating a new DataFrame of the term which contain TF-IDF instead of frequencies tf_idf_df = d...
true
669d633b331c32363512ee50b23e414edece7277
ElliottKasoar/algorithms
/bubblesort.py
1,259
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 17 17:48:06 2020 @author: Elliott """ # Bubble sort algorithm import numpy as np import time # Bubble sort function. # Compares adjacent pairs of elements and swaps if first element is larger # Repeats this (length of array - 1) times, each time ...
true
1d2ace87d805ecaa811e860f29f163a26c85c429
padmacho/pythontutorial
/collections/dict/dict_demo.py
1,585
4.6875
5
capitals = {"india":"delhi", "america":"washington"} print("Access values using key: ", capitals["india"]) name_age = [('dora', 5), ('mario', 10)] d = dict(name_age) print("Dict", d) d = dict(a=1, b=2, c=3) print("Dict", d) # copying method 1 e = d.copy() print("Copied dictionary e: ", e) # copying meth...
true
679d78cde339c2ab96b05a34b983f9530404d4fa
padmacho/pythontutorial
/scopes/assignment_operator.py
311
4.15625
4
a = 0 def fun1(): print("fun1: a=", a) def fun2(): a = 10 # By default, the assignment statement creates variables in the local scope print("fun2: a=", a) def fun3(): global a # refer global variable a = 5 print("fun3: a=", a) fun1() fun2() fun1() fun3() fun1()
true
e14df3b6a6de916386a171b5095f282f2a2885be
Mokarram-Mujtaba/Complete-Python-Tutorial-and-Notes
/23. Python File IO Basics.py
755
4.28125
4
########### Python File IO Basics ######### # Two types of memory # 1. Volatile Memory : Data cleared as System Shut Down # Example : RAM # 2. Non-Volatile Memory : Data remains saved always. # Example : Hard Disk # File : In Non-Volatile Memory we store Data as File # File may be text file,binary file(Ex - Image,mp3...
true
9892c365ccbe67416408836343251224372f854f
Mokarram-Mujtaba/Complete-Python-Tutorial-and-Notes
/15. While Loops In Python.py
506
4.34375
4
############## While loop Tutorial ######### i = 0 # While Condition is true # Inside code of while keep runs # This will keep printing 0 # while(i<45): # print(i) # To stop while loop # update i to break the condition while(i<8): print(i) i = i + 1 # Output : # 0 # 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # As...
true
658bf19caa15b39086e4166c6bd43b8f026939e4
evlevel/lab_6_starting_repo
/lab_6_starting/wordstats.py
794
4.28125
4
# # wordstats.py: # # Starting code for Lab 6-4 # # we'll learn more about reading from text files in HTT11... FILENAME = 'words.txt' fvar = open(FILENAME, 'r') # open file for reading bigline = fvar.read() # read ENTIRE file into single string # what happens when you print such a big line? # try it, by unc...
true
015b5f6887cc692ae30fdef44d1fa87e8b74ae6b
toma-ungureanu/FII-Python
/lab1/ex1.py
1,142
4.3125
4
class Error(Exception): """Exception""" pass class NegativeValueError(Error): """Raised when the input value is negative""" pass class FloatError(Error): """Raised when the input value is negative""" pass def find_gcd_2numbers(num1, num2): try: if num1 < 0 or num2 < 0: ...
true
dc276b879b3045f27a3ae01b0984e82cf831f970
toma-ungureanu/FII-Python
/lab5/ex5.py
816
4.1875
4
import os def writePaths(dirname,filename): file_to_write = open(filename, "w+", encoding='utf-8') for root, dirs, files in os.walk(dirname): path = root.split(os.sep) file_to_write.write((len(path) - 1) * '---') file_to_write.write(os.path.basename(root)) file_to_write.write("...
true
f7fba7853ba6cd086384d43014fae831e5597215
Dhruvish09/PYTHON_TUT
/Loops/function with argument.py
1,111
4.5
4
#Information can be passed into functions as arguments. def my_function(fname): print(fname + " Refsnes") my_function("Emil") my_function("Tobias") my_function("Linus") #You can also send arguments with the key = value syntax. def my_function(child3, child2, child1): print("The youngest child is ...
true
6d260adeec1de35945ff49f6cf3507881b93e724
RavikrianGoru/py_durga
/byte_of_python/py_flowcontrol_func_modules/10_while_else.py
674
4.125
4
# while-else # input() is builtin function. we supply input as string. Once we enter something and press kbd[enter] key. # input() function returns what we entered as string. # then we can convert into any format what we required. pass_mark = 45 running = True print('Process is started') while running: marks = i...
true
3f26b2ccfc2e70402b275e09a4aa6b9a7a4a7b8a
emma-ola/calc
/codechallenge.py
1,015
4.40625
4
# Days in Month # convert this function is_leap(), so that instead of printing "Leap year." or "Not leap year." it # should return True if it is a leap year and return False if it is not a leap year. # create a function called days_in_month() which will take a year and a month as inputs def is_leap(year): """ Th...
true
545f2e6bbc59b938c2e23b1c0a4ffbda28b5f2a9
viveksyngh/Algorithms-and-Data-Structure
/Data Structure/Queue.py
792
4.21875
4
class Queue : def __init__(self) : """ Initialises an empty Queue """ self.items = [] def is_empty(self) : """ Returns 'True' if Queue is empty otherwise 'False' """ return self.items == [] def enqueue(self, item) : """ Inse...
true
40cc7c6d18482056565687650ad8f77cf15208fd
AmitKulkarni23/OpenCV
/Official_OpenCV_Docs/Core_Operations/place_image_over_another_using_roi.py
1,942
4.15625
4
# Placing image over another image using ROI # Use of bitwise operations and image thresholding # API used # cv2.threshold # 1st arg -> gray scale image # 2nd arg -> threshold value used to classify the images # 3rd arg -> Value to be given if pixel value is more than threshold value # 4th arg -> different styles of t...
true
9a7f222209e105a33d45217efb1e1f26656a4a87
AndreasArne/python-examination
/test/python/me/kmom01/plane/plane.py
877
4.5
4
#!/usr/bin/evn python3 """ Program som tar emot värden av en enhetstyp och omvandlar till motsvarande värde av en annan. """ # raise ValueError("hejhejhej") # raise StopIteration("hejhejhej") print("Hello and welcome to the unit converter!") hight = float(input("Enter current hight in meters over sea, and press enter...
true
ab77e72fabb93382bb3f009069465def1d6c3368
suraj-thadarai/Learning-python-from-Scracth
/findingFactorial.py
263
4.375
4
#finding the factorial of a given number def findingFactorial(num): for i in range(1,num): num = num*i return num number = int(input("Enter an Integer: ")) factorial = findingFactorial(number) print("Factorial of a number is:",factorial)
true
6b1883815e71b89b42642fb84a893a599e69496e
cseshahriar/The-python-mega-course-practice-repo
/advance_python/map.py
407
4.28125
4
""" The map() function executes a specified function for each item in an iterable. The item is sent to the function as a parameter. """ def square(n): return n * n my_list = [2, 3, 4, 5, 6, 7, 8, 9] map_list = map(square, my_list) print(map_list) print(list(map_list)) def myfunc(a, b): return a + b x ...
true
ae867fa7bd813de8cc06c1d30a7390eb8201e7fd
cseshahriar/The-python-mega-course-practice-repo
/random/random_example.py
939
4.625
5
# Program to generate a random number between 0 and 9 # importing the random module import random """ return random int in range """ print(random.randint(0, 9)) """ return random int in range""" print(random.randrange(1, 10)) """ return random float in range """ print(random.uniform(20, 30)) """ To pick a random e...
true
414024ec189b3b448632b6743408ca1235df3b7c
Darja-p/python-fundamentals-master
/Labs/06_functions/06_02_stats.py
455
4.125
4
''' Write a script that takes in a list and finds the max, min, average and sum. ''' inp1 = input("Enter a list of numbers: ") def MinMax(a): listN = a.split() listN = [float(i) for i in listN] max_value = max(listN) min_Value = min(listN) avg_Value = sum(listN) / len(listN) sum_Value = sum(li...
true
700b4701729713ce93c836709beef9b393dd6327
Darja-p/python-fundamentals-master
/Labs/08_file_io/08_01_words_analysis.py
646
4.3125
4
''' Write a script that reads in the words from the words.txt file and finds and prints: 1. The shortest word (if there is a tie, print all) 2. The longest word (if there is a tie, print all) 3. The total number of words in the file. ''' from itertools import count list1 = [] with open("words.txt",'r') as fin: ...
true
6a8ba495dd00b7a9bd3d40098780799e4bb5d03d
Darja-p/python-fundamentals-master
/Labs/07_classes_objects_methods/07_05_freeform_inheritance.py
2,115
4.21875
4
''' Build on your previous freeform exercise. Create subclasses of two of the existing classes. Create a subclass of one of those so that the hierarchy is at least three levels. Build these classes out like we did in the previous exercises. If you cannot think of a way to build on your freeform exercise, you can sta...
true
8b84cae134528d332b0cf3e998c873697381a45e
Darja-p/python-fundamentals-master
/Labs/03_more_datatypes/4_dictionaries/03_20_dict_tuples.py
485
4.1875
4
''' Write a script that sorts a dictionary into a list of tuples based on values. For example: input_dict = {"item1": 5, "item2": 6, "item3": 1} result_list = [("item3", 1), ("item1", 5), ("item2", 6)] ''' input_dict = {"item1": 5, "item2": 6, "item3": 1} list1 = list(input_dict.items()) print(list1) def takeSecond...
true
4d0e725efd60894619a1274d24eeb1d823966a72
Darja-p/python-fundamentals-master
/Labs/02_basic_datatypes/02_05_convert.py
731
4.5
4
''' Demonstrate how to: 1) Convert an int to a float 2) Convert a float to an int 3) Perform floor division using a float and an int. 4) Use two user inputted values to perform multiplication. Take note of what information is lost when some conversions take place. ''' a = 2 print (a) a = float ...
true
0ac789041795f5876f64b57d894d57cba7182993
OrNaishtat/Python---Magic-Number
/TheMagicNumber.py
2,032
4.1875
4
######################################################################################################################################## ### NewLight - The Magic Number. ### The magic number generates a random number between 1 and 10, the user needs to guess the number. ### The user has a limited number of lives (NB...
true
6836f4e8fada111cc10e3da114f6139277b1312f
nooknic/MyScript
/var.py
277
4.25
4
#Initialize a variable with an integer value. var = 8 print(var) #Assign a float value to the variable. var = 3.142 print(var) #Assign a string value to the variable. var="Python in easy steps" print(var) #Assign a boolean value to the variable. var = True print(var)
true
5f26386ef1362913cba95ad2ec17ae5869fc90e3
jagrutipyth/Restaurant
/Inheritance_polymorphism.py
807
4.125
4
class Restaurant: def __init__(self,customer,money): self.customer = customer self.__money = money def coupan(self): print(f"Hello, {self.customer},please pay {self.__money} and take your coupan") class IcecreamStand(Restaurant): '''Using this class to show inheritence & polymorp...
true
120762fb80c0df66a6102d87d0bac74ea94dbb4c
Ridwanullahi-code/python-list-data-type
/assignment.py
961
4.25
4
# base from the given list below create a python function using the following condition as specified below # (a) create a seperated lists of string and numbers # (b) sort the strings list in ascending order # (c) sort the string list in descending order # (d) sort the number list from the lowest to high # (e) sort the ...
true
c7a76e6560b621b5e0c8b51a17685d016f46e4d2
lowks/levelup
/hackerrank/staircase/staircase.py
404
4.21875
4
#!/bin/python import sys def staircase(total, number): # Complete this function hash_number = "" for space in range(0, total - number): hash_number += " " for hash in range(0, number): hash_number = hash_number + "#" return hash_number if __name__ == "__main__": n = int(raw_in...
true
9964e05b7c8fd3ee6588d476fa2cbe240c7b921d
jacealan/eulernet
/level2/38-Pandigital multiples.py
1,240
4.1875
4
#!/usr/local/bin/python3 ''' Problem 38 : Pandigital multiples Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same can be a...
true
d1304b21ceb527d863c16c297877ae04b5405962
daredtech/lambda-python-1
/src/14_cal.py
1,756
4.53125
5
""" The Python standard library's 'calendar' module allows you to render a calendar to your terminal. https://docs.python.org/3.6/library/calendar.html Write a program that accepts user input of the form `14_cal.py month [year]` and does the following: - If the user doesn't specify any input, your program should ...
true
a5924b232af9c4c761d7093cce952507ba9341a8
gopikrishnansa/weather_in_your_location
/weather app.py
1,417
4.15625
4
import requests class weather: def get(self): try: #gets data from openweathermap api #converting that info to json #accessing json files #printing the info here global city,api_address,mainweather,descriptio,wind,name name = input("en...
true
a7cd28c10d88473e318bf9daa1192d408d78f54a
sulleyi/CSC-120
/Project1/card.py
474
4.15625
4
class card: """ Class for the card object """ def __init__(self, value, suit): """ initializes card object :param self: instance of card :param value: cards number or face value :param suit: suit value of card (heart,diamond, club, or spade) :return: ...
true
c2a75a3e85541ad15cba57dbc6488e4532082b22
shayansaha85/python_basic_loops_functions
/Factorial.py
307
4.25
4
# Python Program to Find the Factorial of a Number def findFactorial(number): if number==0: return 1 elif number==1: return 1 else: return number * findFactorial(number-1) number = int(input("Enter a number = ")) print("{0}! = {1}".format(number,findFactorial(number)))
true