blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
2b7714e2eb4e8e55cbb62612eb1a8c37b42b0c69
VikingOfValhalla/PY4E_Python_4_Everybody
/excercise_03_02/excercise_03_02_assignment.py
499
4.21875
4
score = input("Enter Score: ") # gives the command to try the if statement for letter_grade try: letter_grade = float(score) # if the try command above does not work, it will print the below except: print("Error with your score input") # Possible inputs if letter_grade >= float(0.9): print('A') elif lett...
true
ce8b58f3c70574491db63b3fd64cd067e42a8849
yumi2198-cmis/yumi2198-cmis-cs2
/cs2quiz2.py
2,114
4.21875
4
import math #PART 1: Terminology #1) Give 3 examples of boolean expressions. #q1 a) 2 == 3 #q2 b) a > b and b == c #q3 c) x == c or a > x # #q4 2) What does 'return' do? # In python programming, return has the job of taking an argument and giving out the result. It basically shows what argument a certain "def" does. ...
true
9581a123e0f718e4b46fbabf4289ae5b94bdd4af
RajathT/dsa
/python/Linked_List/flatten_doubly_list.py
1,734
4.25
4
""" # Definition for a Node. class Node(object): def __init__(self, val, prev, next, child): self.val = val self.prev = prev self.next = next self.child = child """ class Solution(object): def flatten(self, head): """ :type head: Node :rtype: Node ...
true
ab60756eb584ef0085c519439de82ba9ef1a365a
RajathT/dsa
/python/Trees/tree_right_side_view.py
1,011
4.21875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None ''' Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Ex...
true
8e6cab1789c39d0ec5520e7dddb384f9f3e56682
gautam199429/pythoncodes
/os.py
2,784
4.3125
4
import os # Create empty dictionary player_dict = {} # Create an empty string enter_player = '' # Enter a loop to enter inforation from keyboard while enter_player.upper() != 'X': print 'Sports Team Administration App' # If the file exists, then allow us to manage it, otherwise force creation. if os.pat...
true
742e8b0dbf3966fed15d40dc3eee899f3fedb59d
nnagwek/python_Examples
/pycharm/flowcontrolstatements/gradingSystem.py
466
4.25
4
maths = float(input('Enter marks in maths : ')) physics = float(input('Enter marks in physics : ')) chemistry = float(input('Enter marks in chemistry : ')) if maths < 35 or physics < 35 or chemistry < 35: print('Student has failed!!!') else: print('Student has Passed!!!') average = (maths + physics + chemis...
true
9e86bd62c745472931f6a27de0e60e1f4646b9df
sridevisriramu/pythonSamples
/raw_input_If_Else.py
225
4.25
4
print 'Welcome to the Pig Latin Translator!' # Start coding here! original = raw_input("enter a word = ") print "User entered word is = " + str(original) if(len(original)>0): print original else: print "empty string"
true
58c0349c83d605f31d2cef274793b26355aa25ff
DaniMarek/pythonexercises13
/lstodic.py
1,010
4.25
4
# Create a function that takes in two lists and creates a single dictionary. The first list contains keys and the second list contains the values. Assume the lists will be of equal length. # Your first function will take in two lists containing some strings. name = ["Anna", "Eli", "Pariece", "Brendan", "Amy", "Shan...
true
48fe2fbb091316a82c366f567aef9c089e73a574
TejasviniK/Python-Practice-Codes
/getCaptitals.py
255
4.125
4
def get_capitals(the_string): capStr = "" for s in the_string : if ord(s) >= 67 and ord(s) <= 90: capStr += s return capStr print(get_capitals("CS1301")) print(get_capitals("Georgia Institute of Technology"))
true
5890fca781ca1ccec74571a9c5d962cad956b352
changediyasunny/Challenges
/leetcode_2018/7_reverse_integer.py
873
4.125
4
""" 7. Reverse Integer Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, ...
true
fae854c0275661ef01a70a10a9befdd4e35a3756
changediyasunny/Challenges
/leetcode_2018/655_print_2D_binary_tree.py
2,209
4.125
4
""" 655. Print Binary Tree Print a binary tree in an m*n 2D string array following these rules: The row number m should be equal to the height of the given binary tree. The column number n should always be an odd number. Example 1: Input: 1 / 2 Output: [["", "1", ""], ["2", "", ""]] Example 2: Input: ...
true
3cbbdba5fccc9957370774c31a727840c2bd90f3
changediyasunny/Challenges
/leetcode_2018/208_implement_trie.py
2,173
4.21875
4
""" 208. Implement Trie (prefix tree) 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.startsWith("app"); // returns true trie.insert("app"); trie.search("app"); ...
true
664c7738c1e235d552343733bd98b7239e3f4213
changediyasunny/Challenges
/leetcode_2018/150_eval_reverse_polish_notation.py
2,130
4.15625
4
""" 150. Evaluate Reverse Polish Notation Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Note: Division between two integers should truncate toward zero. The given RPN expression is always valid. That me...
true
9a18f7c85ecd1a54178e39c4058f63f6be85edfa
changediyasunny/Challenges
/leetcode_2018/207_course_schedule.py
2,261
4.1875
4
""" 207. Course Schedule There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and a list of prerequisite pairs, is it possible for ...
true
c9fdcf043b9a4fdd46f51714328b1c829df41b82
RuslanIhnatenko/Python-Enchantress
/lectures/tests/asserts_practice.py
446
4.125
4
def is_prime(number): """Return True if *number* is prime.""" if number <= 1: return False for element in range(2, number): if number % element == 0: return False return True assert is_prime(7) is True, "7 is prime number" assert is_prime(10) is False, "10 is not a prime nu...
true
6d3f6c4facea5db2d699029b8773651fd77a55eb
dabay/LeetCodePython
/MaximumSubarray.py
1,067
4.28125
4
# -*- coding: utf8 -*- ''' Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the largest sum = 6. More practice: If you have figured out the O(n) solution, try coding ano...
true
b50acc9bb4d87dc26c8798a05e025cbcd275b70e
dabay/LeetCodePython
/172FactorialTrailingZeroes.py
573
4.15625
4
# -*- coding: utf8 -*- ''' https://oj.leetcode.com/problems/factorial-trailing-zeroes/ Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. ''' class Solution: # @return an integer def trailingZeroes(self, n): result = 0 ...
true
6338838f56dc97b6dbfc227a5693fdc9e0eb4d50
dabay/LeetCodePython
/FlattenBinaryTreeToLinkedList.py
2,012
4.5
4
# -*- coding: utf8 -*- ''' Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ 5 \ 6 '...
true
6f564d7d1802a29f5151d709e96b40232d01ebb7
dabay/LeetCodePython
/SetMatrixZeroes.py
1,482
4.25
4
# -*- coding: utf8 -*- ''' Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 哎,这道题有点巧妙呐~ ''' class Solution: # @param matrix, a list of lists of integers # RETURN NOTHING, MODIFY matrix IN PLACE. def setZeroes(self, matrix): row_count = len(matrix) ...
true
a8b91d51f0cff6f909b3a88f94d3c35f04f455cd
dabay/LeetCodePython
/PartitionList.py
1,753
4.15625
4
# -*- coding: utf8 -*- ''' Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions. For example, Given 1->4->3->2->5->2 and x = 3, return 1->2->2->4->3->5. '...
true
cf2cf2ff16a4c6f209b47c69fdc4ea88164dc0aa
jingriver/testPython
/python_language/filter_words/filter_words.py
700
4.21875
4
""" Filter Words ------------ Print out only words that start with "o", ignoring case:: lyrics = '''My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh bring back my Bonnie to me. ''' Bonus points: print out...
true
1f2aae3ca06df9c0835afed1a77bdda03f9207ec
jingriver/testPython
/numpy/mothers_day/mothers_day_solution.py
859
4.125
4
""" Mother's day ============ In the USA and Canada, Mother's Day is the second Sunday of May. Use NumPy's datetime64 data type and datetime64 utilities to compute the date of Mother's Day for the current year. Note: NumPy datetime64 values can be created from a string with the format YYYY-MM-DD HH:MM:SS.sss where ev...
true
240916cbc51c8858649a8d39d9663aeb542482cd
richiede/my_algos
/01_my_sorting_algo.py
1,316
4.4375
4
# This is a program that will take multiple string inputs from a user to create a list # The algo will then sort the list in alphabetical order. # 3 lists are initialised my_list = [] my_temp_list = [] sorted_list = [] # Input is taken from the user and added to the "my_list" list print('Welcome! Please create a list...
true
9b06eb2c5458ee0268a5ed2b8e86e02d15ca9ae7
stoicamirela/PythonScriptingLanguagesProjects
/Project4/main.py
1,148
4.40625
4
#simple exercise with dictionary: we have a dictionary with phone numbers and names, and we show first the names and ask user #what number phone he wants, based on that we show the value of the key name. Bonus things are changing k to value as shown in #inverted_dict variable. I also sorted the dictionary in a for #...
true
2d4d0e8a2f72334ed27e9cb5855afac242f90897
Arfa-uroz/practice_program
/tuple.py
600
4.375
4
"""Given an integer,n, and n space-separated integers as input, create a tuple ,t , of those n integers. Then compute and print the result of hash(t). Note: hash() is one of the functions in the __builtins__ module, so it need not be imported.""" if __name__ == '__main__': n = int(input()) #n number ...
true
d3feee4d25dba244579179657ce2005908a7aa1e
Arfa-uroz/practice_program
/swap_case.py
233
4.21875
4
def swap_case(s): new_string = s.swapcase() #swaps the case of all the letters return(new_string) if __name__ == '__main__': s = input("Enter your string here ") result = swap_case(s) print(result)
true
3f6d19203aedf5b9156817db55db27f471fb0950
LambdaSchool-forks/DS-Unit-3-Sprint-2-SQL-and-Databases
/SC/northwind.py
2,296
4.21875
4
import sqlite3 # create connection sl_conn = sqlite3.connect('/Users/Elizabeth/sql/northwind_small.sqlite3') curs = sl_conn.cursor() # table names # [('Category',), ('Customer',), ('CustomerCustomerDemo',), # ('CustomerDemographic',), ('Employee',), ('EmployeeTerritory',), ('Order',), # ('OrderDetail',), ('Product',)...
true
a23aedd69fd4ec2d6500ba5a8bb05b0efbc67a1b
Allen-1242/Python-Prorgrams
/Python Programs/Python Programs/SQL_python/sql2.py
954
4.1875
4
import sqlite3 con = sqlite3.connect('my_data.db') cur = con.cursor() while(True): print("Welcome to the database") print("1.Insert the row\t2.View the table\n3.Update the table\t 4.Drop the table\n5.Exit") imp = int(input("Enter the operation needed")) if imp == 1: print("Welcome to insertion \n") f = in...
true
5758d2fbfde70ce6058f703bd003826a748dc63e
joco1026/Python-Challenge
/4/dynamic_url.py
757
4.125
4
#!/usr/bin/python #http://www.iainbenson.com/programming/Python/Challenge/solution4.php #This is an example of using a linked list to dynamically open HTML pages. #It will parse an HTML page for a number and then dynamically open the next page. import urllib, re url="http://www.pythonchallenge.com/pc/def/linkedlist....
true
4f42a130f24a8159a696bd2ea33712e5e79b5750
FranzSchubert92/cw
/python/best_travel.py
1,976
4.21875
4
#! /usr/bin/env python3 """ John and Mary want to travel between a few towns A, B, C ... Mary has on a sheet of paper a list of distances between these towns. ls = [50, 55, 57, 58, 60]. John is tired of driving and he says to Mary that he doesn't want to drive more than t = 174 miles and he will visit only 3 town...
true
c57415dc01430b0d3b9824290a5c6828673cb2be
kiba0510/holbertonschool-higher_level_programming
/0x06-python-classes/1-square.py
329
4.21875
4
#!/usr/bin/python3 """ Square Module - Use when you need to print a square """ class Square: """ Class defining the size of a square """ def __init__(self, size=0): """ Initialization of instanced attribute Args: size: The size of a square """ self.__siz...
true
6abd13360b2e330db9bc328d479d248713960d95
natallia-bonadia/dev-studies
/Lets Code/Coding Tank - Python/Python/Lets Code/Aula 2 - Scripts em Python.py
2,091
4.25
4
### EXERCÍCIOS AULA 2 - SCRIPTS EM PYTHON ### ''' 1) Faça um script que mostra a média de duas notas. A = int(input("Digite a média 1:")) B = int(input("Digite a média 2:")) resultado = (A + B) / 2 print(resultado) ---------- 2) Faça um script para somar dois números e multiplicar o resultado pelo primeiro número. ...
false
ace00dd2e10aefdd23c28b0222f91b6e109374ee
microsoft/python-course
/pycourse.py
1,413
4.125
4
# Functions for Introduction to Python Course ## Turtle Graphics import jturtle as turtle def square(x): """ Draw a square with side x """ for t in range(4): turtle.forward(x) turtle.right(90) def house(size): """ Draw a house of specified size """ square(size) turtle.forward(si...
true
b350082c8536e3b80dd2ac9dd8badd9114f5630b
uncamy/Games
/pigLatin.py
611
4.15625
4
pyg = 'ay'# piece of code for use later original = raw_input('Enter a word:') #user input word to be translated if len(original) > 0 and original.isalpha(): print original word = original.lower() first =word[0] #for words that start with a vowel if first == "a" or first=="e" or first=="i" or firs...
true
e869611625c651a76222ef709319cd7917eb7a30
raxxar1024/code_snippet
/leetcode 051-100/95. Unique Binary Search Trees II.py
1,412
4.1875
4
""" Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return all 5 unique BST's shown below. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / ...
true
72ef48d15fdf5d8d3df74a38dd1438f7148f8a33
raxxar1024/code_snippet
/leetcode 051-100/53. Maximum Subarray.py
893
4.21875
4
""" Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has the largest sum = 6. click to show more practice. More practice: If you have figured out the O(n) solution, try cod...
true
c09c07c9c0234ee00371ec41b11e847df9aa775c
MichaelLenghel/Python-Algorithm-Problems
/recursive_reverse_string/recursive_reverse_string.py
373
4.4375
4
# Program to recursively reverse a string def reverse(s): # Base Case if s == "": return s # Recursive calls else: return reverse(s[1:]) + s[0] # return s[-1:] + reverse(s[:len(s) - 1]) # return s[len(s) - 1] + reverse(s[:len(s) - 1]) if __name__ == "__main__": print(reverse("Hello, world!...
true
a3e8e1b1798d035a0297d479b785cdaf42589c02
MichaelLenghel/Python-Algorithm-Problems
/anagram_check/anagram_check.py
1,745
4.28125
4
# Program that will check if two strings are anagrams, not including captials or spaces # Has a time complexity of O(N), ideal for small data sets, but space complexity is of O(26). As 26 references are made from hashmap. def anagram_check(s1, s2): # Declare the dictionary ana_li = {} # Removes spaces in bo...
true
bfe78fd78d5f1335f46f8b2ecd4d0b6ffa8fb05e
saulosantiago/AutomatosExemplo1
/exercicio1.py
2,356
4.1875
4
""" Linguagem pipoca Letras possíveis: +, -, *, /, imprima, recebe, entrada Gramatica: Toda sentença tem que terminar em ! Variaveis tem @ no inicio do nome exemplo de codigo: @nomedavariavel recebe 50! @variavel2 recebe entrada! imprima @variavel2 + @nomedavariavel! """ """ Automato1: Finito e deterministico: Esta...
false
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
2496ecec840fb88042ad2838809c8b4d6005648b
evertondutra/Curso_em_Video_Python
/exe078.py
781
4.125
4
""" Faça um programa que leia 5 valores numéricos e guarde-os em uma lista. No final, mostre qual foi o maior e o menor valore digitado e suas respectivas posições na lista. """ val = [] maior = 0 for c in range(0,5): val.append(int(input(f'Digite o {c+1}º número: '))) if c == 0: maior = menor = val[c] ...
false
174bdefb77c6d8b342dab35336e151e92bccb6a6
evertondutra/Curso_em_Video_Python
/exe065.py
656
4.15625
4
""" Crie um programa que leia vários números pelo teclado. No final, mostre a média, o maior e o menor número digitado, e pergunte se o uspuario deseja continuar. """ cont = maior = menor = soma = 0 resp = 'S' while resp != 'N': n = int(input('Digite um número: ')) soma += n cont += 1 if cont == 1: ...
false
ac00b8e51e02a68663ae812b2bb2b4040efb16e8
evertondutra/Curso_em_Video_Python
/exe079.py
921
4.15625
4
""" Crie um programa que possa digitar vários valores numéricos e cadastre-os em uma lista. Caso o número ja exista la dentro, ele não será adicionado. No final, serão exibidos todos os valores únicos digitados, em ordem crescente. """ val = [] p = 0 while True: while True: n = input('Digite um valor: ') ...
false
de52a1bf248d629ba07d828c320f9070afe6102d
marinasupernova/100daysofcode
/For_loop, While_loop, Random, Math : Sept_11/While_loop, Random : Sept_14/Tasks_52_59.py
2,433
4.1875
4
import random '''import random num = random.random() print(num)''' '''import random color = random.choice (["red", "black", "greeen"]) print(color)''' '''Task 52 num = random.randint(1,100) print(num)''' '''Task 53 fruits = random.choice(["apple", "banana", "apricot", "cherry", "peach"]) print(fruits)''' '''Task 5...
false
0b74b40d19eb4e5be0592e07711742f4354abe7d
marinasupernova/100daysofcode
/Subprograms: functions/tasks 118 -123.py
2,202
4.125
4
import random ''' def get_random(): low_num = int(input("Please enter a low number: ")) high_num = int(input("Please enter a high number: ")) comp_num = random.randint(low_num, high_num) return comp_num ''' '''Task 120 def add_numbs(): num1 = random.randint(5,20) num2 = random.randint(5,20)...
false
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
f9c3502f97c2fd29472cb81d474ce22f534ce1bb
palhaogv/Python-exercises
/ex086.py
378
4.15625
4
#crie uma matriz 3x3 e preencha com valores lidos pelo teclado #No final, mostre a matriz na tela com o valor correto. lista = [] for c in range(1, 10): n = int(input(f'Digite o valor da {c}ª posição: ')) lista.append(n) print(f'[{lista[0]}][{lista[1]}][{lista[2]}]\n' f'[{lista[3]}][{lista[4]}][{lista[5...
false
f6774e74fc359a562f361b06b593d20a2d269570
lxh1997zj/-offer_and_LeetCode
/剑指offer-牛客顺序/to_offer_07.py
2,313
4.1875
4
# !/usr/bin/env python3 # -*- coding:utf-8 -*- '大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。n <= 39' # n=0时,f(n)=0 n=1时,f(n)=1 n>1时,f(n)=f(n-1)+f(n-2) class Solution: def Fibonacci(self, n): # 循环 # write code here a, b = 0, 1 if n <= 0: return 0 if n == 1: ...
false
50708a5460e439e9ecb844e38d53de193bf1fe1e
lxh1997zj/-offer_and_LeetCode
/Sorting_Algorithm/bubble_sort_python.py
329
4.28125
4
# !/usr/bin/env python3 # -*- coding:utf-8 -*- """冒泡排序""" def bubble_sort(array): for i in range(len(array)-1, 0, -1): for j in range(i): if array[j] > array[j+1]: array[j], array[j+1] = array[j+1], array[j] return array array = [1,2,5,4,3,6,9,8,7] print(bubble_sort(array)...
false
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
e80e59e41310dd7485f910b796b83338fc4d168e
zhengjiani/pyAlgorithm
/leetcodeDay/March/prac876.py
1,719
4.15625
4
# -*- encoding: utf-8 -*- """ @File : prac876.py @Time : 2020/3/23 8:55 AM @Author : zhengjiani @Email : 936089353@qq.com @Software: PyCharm 链表的中间结点 给定一个带有头结点 head 的非空单链表,返回链表的中间结点。 如果有两个中间结点,则返回第二个中间结点。 """ # Definition for singly-linked list. class ListNode: def __init__(self, x, p=0): self.val =...
false
183566bd154e64127d97cda018a0e524cdbc9f62
anjalisaraarun/campk12python
/circlee.py
581
4.1875
4
import turtle def circle(): print('Hello') circle() def draw_circle(turtle,color,size,x,y): turtle.penup() turtle.color(color) turtle.fillcolor(color) turtle.goto(x,y) turtle.pendown() turtle.begin_fill() turtle.circle(size) turtle.end_fill() turtuga = turtle.Turtle() turtuga.shap...
false
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
33df38eafae8d6f4cf4ef33ead92b816e0a7aa12
Zadams1989/programming-GitHub
/Ch 7 TeleTranslator CM.py
1,131
4.125
4
number=input("Enter a phone number to be translated:\n") def teletranslator(phone=number): phone = phone.replace('A', '2') phone = phone.replace('B', '2') phone = phone.replace('C', '2') phone = phone.replace('D', '3') phone = phone.replace('E', '3') phone = phone.replace('F', '3') ...
false
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
4a89b00907c8cf026de45269ff5728a68d7fe296
Ayush10/CSC-3530-Advance-Programming
/area_of_traiangle.py
573
4.375
4
# Importing Math # import math # Program to calculate Area of Triangle # Formula: [Area of a triangle = (s*(s-a)*(s-b)*(s-c))-1/2] print("Enter three sides of a triangle") a = float(input("Enter first side: ")) b = float(input("Enter second side: ")) c = float(input("Enter third side: ")) # Calculating Semi-Perimiter s...
false
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
b60e640d867c6964f52743c79ed44ba8650c89f9
rajkamal-v/PythonLessons1
/numbers.py
801
4.15625
4
num1 = 10 num2 = 20 num3 = 30; num4 = 40 num5 = num6 = 50 # 50 <----- num6, num5 num7, num8, name = 60, 70.90, 'Python' print(num7) print(num8) print(name) name1 = "\"I am also a \"String\"" # '\' is an escape character name2 = "I'm a string" with_backslash = "i\'m a\tthing" #\n - it is a newline ...
false
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