blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0e66cef7b14800d47a750139d943d8c439338232
fengkaiwhu/A_Byte_of_Python3
/example/addr_book.py
1,812
4.1875
4
#!/usr/bin/env python # coding=utf-8 # Filename: addr_book.py class addr_book: '''Represent an addr_book''' book = {} def __init__(self, book): addr_book.book = book def get_book(self): return addr_book.book def add_person(self): name = input('Please input name-->') ...
true
85ca3ab76550a0092f926eb777a834246c85c557
RyanWaltersDev/NSPython_chapter3
/travel_dest.py
729
4.71875
5
#Ryan Walters Nov 21 2020 -- Practicing the different sorting methods with travel destinations #Initial list travel_dest = ['tokyo', 'venice', 'amsterdam', 'osaka', 'wales', 'dublin'] #Printing as a raw Python list and then in order print(travel_dest) print(sorted(travel_dest)) #Printing in reverse alphabetical orde...
true
4ca4e141304cac59a47ae96c22a9d54ea6bd4ef2
danielmlima1971/CursoemVideo-Python-Exercicios
/Mundo 1/Ex022.py
645
4.3125
4
# EXERCICIO 022 # Exercício Python 22: Crie um programa que leia o nome # completo de uma pessoa e mostre: # – O nome com todas as letras maiúsculas e minúsculas. # – Quantas letras ao todo (sem considerar espaços). # – Quantas letras tem o primeiro nome. nome = str(input('Digite seu nome completo: ')) print...
false
e4a79d6a56885eed560cf5a5f2c7ab6c614cb164
danielmlima1971/CursoemVideo-Python-Exercicios
/Mundo2/Ex036-EmprestimoBancario.py
1,167
4.34375
4
# Exercício Python 36: Escreva um programa para aprovar # o empréstimo bancário para a compra de uma casa. # Pergunte o valor da casa, o salário do comprador e em # quantos anos ele vai pagar. A prestação mensal não pode # exceder 30% do salário ou então o empréstimo será negado. print('\033[7;30;41m=\033[m' * 2...
false
9207040ba05bb7cceb6eff73afcae3d3e2d2232a
daisyzl/program-exercise-python
/Sort/4insertsort.py
1,706
4.375
4
#-*-coding:utf-8-*- ''' 插入排序 基本思想:插入排序是一种简单直观的排序算法。它的工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描, 找到相应位置并插入。插入排序在实现上,在从后向前扫描过程中,需要反复把已排序元素逐步向后挪位,为最新元素提供插入空间。 插入排序的时间复杂度问题 最优时间复杂度:O(n) (升序排列,序列已经处于升序状态) 最坏时间复杂度:O(n2) 稳定性:稳定 https://www.runoob.com/python3/python-insertion-sort.html 思想: 把n个待排序的元素看成一个有序表和一个无序表,开始时有序表中只包含一个元素,无序...
false
3b848a03a86b5e409bd266d06e55998791035a9d
daisyzl/program-exercise-python
/BinaryTree/zuidashendu.py
1,373
4.1875
4
# -*- coding:utf-8 -*- ''' function:二叉树的最大深度 给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 说明: 叶子节点是指没有子节点的节点。 示例: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回它的最大深度 3 。 题目:https://leetcode-cn.com/explore/learn/card/data-structure-binary-tree/3/solve-problems-recursively/12/ 答案:https:...
false
d0d118fe3a88f33f1c18d12c565e9e83620fe9f8
spettigrew/cs2-codesignal-practice-tests
/truck_tour.py
2,736
4.5
4
""" Suppose there is a circle. There are N petrol pumps on that circle. Petrol pumps are numbered 0 to (N - 1) (both inclusive). You have two pieces of information corresponding to each of the petrol pump: (1) the amount of petrol that particular petrol pump will give, and (2) the distance from that petrol pump to the ...
true
53ba03e8e1cbb013f566be89f6b0df2722a7319d
spettigrew/cs2-codesignal-practice-tests
/roman-to-integer.py
2,820
4.25
4
""" Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one's added together. 12 is writt...
true
d9bc3016a040ecb9b68e404cf4a9244ed6ee81a6
spettigrew/cs2-codesignal-practice-tests
/anagrams.py
2,712
4.46875
4
""" A student is taking a cryptography class and has found anagrams to be very useful. Two strings are anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact frequency. For example, bacdc and dc...
true
307c0d178659494d3639d78df5f4b1bd1dfc9607
thomasmcclellan/pythonfundamentals
/02.01_strings.py
525
4.21875
4
# Strings hold text info and hold "" or '' # Can have [] 'hello' "hello" "I'm a dog" my_string = 'abcdefg' print(my_string) print(my_string[0]) print(my_string[3:]) print(my_string[:3]) #Goes up to, BUT NOT INCLUDING the number print(my_string[2:5]) print(my_string[::]) print(my_string[::2]) #The number is the step s...
true
d7c16c08b73fa5b2a45356431d35416a2e30155e
alaasal95/problem-solving
/Convert_second _to_hour_min_second.py
323
4.15625
4
''' ----->Ex:// read an integer value(T) representing time in seconds and converts it to equivalent hours(hr),minutes(mn)and second(sec) ''' p1=int p2=int p3=int second=4000 p1=second%60 p2=second/60 print('p2_',p2) p3=p2%60 print('p2',p2) p2=p2/60 print(p2 ,":",p3,":",p1...
true
06e6aa8918528136b1b4a56e463dcfb369580261
emmanuelthegeek/Python-Exercises
/Widgets&gizmos.py
1,130
4.25
4
#An online retailer sells two products. widgets and gizmos. Each widget weighs 75 grams, while each gizmo weighs 112 grams. #Write a program that displays the total weight of an order, in kilograms, given two variables containing the number of widgets #and gizmos. #Solution # 1 widget = 75g # 1 gizmos = 112g # 1000g ...
true
6cc0e043bd8778e825fa2fd6748518a6e641a5f9
MihaiDinca1000/Game
/Exercitii/Test_inheritance.py
2,254
4.59375
5
''' In this Python Object-Oriented Tutorial, we will be learning about inheritance and how to create subclasses. Inheritance allows us to inherit attributes and methods from a parent class. This is useful because we can create subclasses and get all of the functionality of our parents class, and have the ability to...
true
43bdd743c29efec4b9756ce9d6ecd8f5bcf61b99
porregu/unit3
/unitproject.py
1,336
4.21875
4
def arearectangle(a,b): """ solve the area of the rectangle :param a: heigth :param b: with :return: return the fucntion to do it more times """ return a*b def withh():# dpuble (h) because dosent let me put one # with called by the user """ make the user tell the with :return: t...
true
b6d777bda60b89b9880543ecdd6f132a111b039e
tanay2098/homework4
/task2.py
1,023
4.15625
4
import random # importing package random nums = [] # initializing an empty list called nums for i in range(0,2): # Loop for 2 elements nums.append(random.randint(0,10)) # generating 2 numbers between 0 to 10 and appending them in the list t1 = tuple(nums) # converting list into a tuple named t1 correct_answ...
true
f76f683497bbf7caff26732105b355888d3160e1
damiannolan/python-fundamentals
/current-time.py
224
4.1875
4
# Problem 2 - Current Time import time; import datetime; # Print the the date and time using 'time' print("Current time is : ", time.asctime(time.localtime(time.time()))) print("Today's date is: ", datetime.date.today())
true
82bd6970962a9f11921c2dc8892969dacad895c8
srholde2/Project-4
/queue.py
1,103
4.28125
4
class Queue: # queue class constructor def __init__(self): self.queue = ["car", "car", "car", "car", "car"] def enqueue(self): item = input("Please enter the item you wish to add to the queue: ") self.queue.append(item) def dequeue(self): item = self.queu...
true
1050e66e270df03c2c88cb35e5d4bf364de138b7
hiranmayee1123/Hacktoberfest-2021
/windowslidingproblem.py
1,013
4.21875
4
#This technique shows how a nested for loop in some problems can be converted to a single for loop to reduce the time complexity. #Let’s start with a problem for illustration where we can apply this technique – #Given an array of integers of size ‘n’. #Our aim is to calculate the maximum sum of ‘k’ #consecutive elem...
true
183a7f2a4ed17abee62bb4e1bb2879469dbe126f
rickpaige/dc-cohort-week-one
/day3/lists-strings.py
435
4.1875
4
# List ['john', 'jane','sue'] greeting = "Hello" print(greeting[0]) # Prints H print(greeting[0::2]) # Prints Hlo # Converting print(greeting.lower()) print(greeting.upper()) # print(input("What is your name? ").lower()) # Split and Join hello = "Hello, my name is Josh".split(" ") # prints ['Hello', 'my', 'name',...
false
3a7e5870dc242615ee553d0f00295ace995c470a
green-fox-academy/klentix
/Topic 5 Data Structure/List Introduction 1.py
810
4.5625
5
namelist = ['William'] namelist.extend(['Jony', 'Amanda']) # add on multiple items in the list print("No. of name", len(namelist)) # print total number of items print("Name list: ", namelist) # print out each element print("the 3rd name is:", namelist[2]) #iterate through a list and print out individual name for ...
true
ce86046945bc3f35b226e37d29f8be3d4f36b893
PramitaPandit/Rock-Paper-Scissor
/main.py
2,492
4.4375
4
#Rock-Paper-Scissor game # import random #step1: Stating game instructions print('Rules of Rock-Paper-Scissor are as follows:\n Rock v/s Paper -> Paper wins \n Rock v/s Scissor -> Rock wins \n Scissor v/s Paper -> Scissor wins ') # Step2: Taking user input user = input('Enter your name: ') while True: player_cho...
true
3dfecdcc2e10e2a8726896802dbed82b8ceef96c
FX-Wood/python-intro
/name_length.py
291
4.375
4
# Exercise 3: # Write a script that asks for a name and prints out, "Your name is X characters in length." # Replace X with the length of the name without the spaces!!! name = input('Please enter your name: \n > ') print(f"Your name is {len(name.replace(' ', ''))} characters in length")
true
04a659e77718a85fad089298850585a77cdb9d00
FX-Wood/python-intro
/collections/print_names.py
246
4.40625
4
# Exercise 1 # Create a list named students containing some student names (strings). # Print out the second student's name. # Print out the last student's name. students = ["Fred", "Alice", "Bob", "Susie"] print(students[1]) print(students[-1])
true
c7dbc874de58b7713d58d422a399f09efebbe726
deepakkadarivel/python-programming
/7_file_processing/7_2_search_in_file.py
946
4.28125
4
""" “Write a program to prompt for a file name, and then read through the file and look for lines of the form: X-DSPAM-Confidence:0.8475” Pseudo code 1. Read file name from user 2. open file 3. Handle No file exception 4. Iterate through files for text and increment count 5. print total...
true
f2d750dadce5e8cf3359b18e806ba763842042e9
deepakkadarivel/python-programming
/6_1_reverse_string.py
567
4.40625
4
""" Write a while loop that starts at the last character in the string and works it’s way through first character in the string, printing each letter in a separate line except backwards. TODO 1: Accept a string from io TODO 2: Find the length of the string TODO 3: decrement len and print charac...
true
8915bb5963f3b0accb33e02d68fba4a8c3bf7628
deepakkadarivel/python-programming
/6_2_letter_count.py
757
4.375
4
""" Find the count of a letter in a word. Encapsulate the code in a function named count, and generalize it so that it accepts the string and letter as an argument. TODO 1: Accept input for a word and letter to search for. TODO 2: Define a count function that accepts word and letter as parameter to cou...
true
f788b258b7e4820673ca63bfb4293d34aef1ad8f
LuisaoStuff/Entrega-1
/Ejercicio 5.py
701
4.15625
4
# Escriba un programa que pregunte cuántos números se van a introducir, pida esos # números, y muestre un mensaje cada vez que un número no sea mayor que el primero. limite=int(input("\n ¿Cuántos números va a introducir? ")) # Validación while limite<=0: limite=int(input("\n ¡Eso es imposible!\n ¿Cuántos números...
false
6a154af4ddbf024665295fdfab72fe4d6f828de8
Jrbrown09/Brown-Assignment5
/.vscode/exercise6.py
2,138
4.4375
4
from helpers import * ''' Exercise 6 Calories from Fat and Carbohydrates This program calculates the calories from fat and carbohydrates that the user consumed. The calorie amounts are calculated using the input from the user in carbohydrates and fat. ''' ''' Define the 'main' function ''' def main(): fat_gram...
true
32b144e97cd8f10500b1848ebd8af4599ae66d12
markvassell/Python
/test/multiplication_table.py
1,248
4.21875
4
import math print("This is test multiplication table: Still in progress") file_name = "Multiples.txt" try: #opens a file to write to mult_file = open(file_name, "w") while (True): try: inp_range = int(input("Please enter how many multiplication tables you would like to generate: ")) ...
true
c52dac3f89683c8ade4f3bc4f81b4a9ff350cc1d
surendhar-code/python_practice
/program1.py
306
4.3125
4
#python program to interchange first and last elements in a list. def firstlast(list1,n): beg=list1[0] end=list1[n] print("The first and last element of the list {0} is {1} and {2}\n".format(list1,beg,end)) list1=list(range(0,5)) print(list1) n=(len(list1))-1 firstlast(list1,n)
true
60b5cb899cef0911bd7d7a775cfbb7ea557aa01f
Robdowski/code-challenges
/running_sum_1d.py
739
4.125
4
""" This problem asks to keep a running total of the sum of a 1 dimensional array, and add that sum to each item in the array as we traverse. To do this, we can simply declare a variable, running sum, and add it to each item in the array as we traverse. We need to add the sum to the item in the array, while storing th...
true
2d516c584352f0d835fc8f9f7dc076fd032e8af3
N0l1Na/Algorithms_Python
/PIL006/PIL006.py
1,306
4.25
4
""" PIL - The exercise is taken from the Pilshchikov's Pascal problem book Task 8.7 page 40 Regular types: vectors Using the Gender and Height arrays, determine: a) The name of the tallest man b) The average height of women Creator Mikhail Mun """ import random array = [] total_height_women = 0 amount_women = 0 ...
true
3e4ce1aa7ffd6fc8365800767121069c313ff9b7
SashaJohnson123/introduction_to_python
/loops_exercises.py
1,566
4.25
4
# #Question 1 # add via append # my_list = [1, 4, 2, 1] # # while loop + # while len(my_list) < 5: # my_var = input("give me a number? ") # my_list.append(my_var) # print(my_var) # print(my_list) # print(my_list) #Question 2 #print each item in the list + amount: # pets = [ # ["Roary", "ro...
false
ec6e1871e6a55516a520a49b11dcd267d7dbb28a
nguyenthanhthao1908/classpython_basic_online
/rewrite_code_resource_w/dictionary/bai9.py
235
4.3125
4
"""Write a Python program to iterate over dictionaries using for loops.""" D = {"Name": "Thao", "Age": 20, 19: 8} # for i in D.items(): # print(i) # solution 2: for key, value in D.items(): print(key, "is:", D[key])
true
aa2b00e3bcd8cc17d08ef67e68ab65aaa64c0435
nguyenthanhthao1908/classpython_basic_online
/rewrite_code_resource_w/dictionary/bai15.py
226
4.15625
4
"""Write a Python program to get the maximum and minimum value in a dictionary. """ D = {3: 30, 2: 20, 19: 8} print("Maximum:", max(D.keys(), key=(lambda k: D[k]))) print("Minimum:", min(D.keys(), key=(lambda k: D[k])))
true
6c952a8e00c4a823828985e353e4ff04c5c747c8
Bigg-Iron/152_001
/C_activities/C10.py
2,963
4.1875
4
""" 10.1.2: Modify a list. Modify short_names by deleting the first element and changing the last element to Joe. Sample output with input: 'Gertrude Sam Ann Joseph' ['Sam', 'Ann', 'Joe'] """ # user_input = input() # short_names = user_input.split() # ''' Your solution goes here ''' # del short_names[0] # del shor...
true
f683cbbba69ce43dbcf7aa072a7b5890b123aadb
kennylugo/Tweet_Generator_Data_Structures_-_Probability
/1.3_anagram_generator.py
1,343
4.15625
4
import sys, random # THIS ANAGRAM GENERATOR IS NOT WORKING YET # method signature def generate_anagram(): # the list method will break a word apart and add each letter to a list data structure list_of_letters_from_word_input = list(sys.argv[1]) # we store the count of the elements in the list above ...
true
0af53ed79a3d2df089f628732cd0f0989ef4e26c
abdullahclarusway/Python_Assignments
/Assignment_9.py
214
4.28125
4
name = input("Please enter your name:").title() my_name = "Abdullah" if name == my_name: print("Hello, {}! The password is: W@12".format(my_name)) else: print("Hello, {}! See you later.".format(name))
true
146c15c96e35d304f7b67806a38f51f629dbee01
firchatn/python-101-introduction
/week1/for-demos.py
251
4.25
4
""" For use cases """ print("For 1:") for i in range(2, 5, 2): print(i) print("For 2:") for i in range(5, 2, -1): print(i) print("For 3:") l = [1, 5, 9] for i in l: print(i) print("For 4:") s = "hello" for i in s: print(i, end='')
false
5474cc84193f02c47d2a4c23e53ebe6f412e303d
lareniar/Curso2018-2019DAW
/2do Trimestre/Diciembre/factorialFunciones.py
679
4.34375
4
# En esta funcion generamos un calculo factorial de un número def factorial(n1): fact = 1 i = 1 while(i <= n1): fact = fact * i i = i + 1 return fact # En esta funcion calculamos la multiplicación del resultado de diferentes factoriales def triple_factorial(n1,n2,n3): resultado...
false
5f1df607c99984af8b32cabeb6d38bb9b85d91e3
srinisha2628/new_practice
/cuberoot.py
358
4.125
4
x= int(input("enter a number\n")) ans=0 while ans**3 < abs(x): ans+=1 if(ans**3!= abs(x)): print("it is not a perfect cube") else: if(x<0): ans = -ans print("cube root of "+ str(x)+" is "+ str(ans)) cube=int(input("enter a number")) for guess in range(cube+1): if(guess**2==cube): p...
true
076f59fedeb631a4284093eab8358526ea1390a5
mewilczynski/python-classwork
/program41.py
865
4.375
4
#Marta Wilczynski #February 2nd, 2016 © #Chapter 4 assignment program41.py #Start program #Import math since we will be using PI #Set up a range of numbers, using the for loop. #Calculate area of a circle with "radius", where the equation # will be area = (PI * (radius ** 2)) #Calculate circumfrence with "rad...
true
b496deacdbb5b1098a24631825f11221a2cbfcb6
mewilczynski/python-classwork
/order32.py
1,681
4.21875
4
#Marta Wilczynski #February 2nd, 2016 © #order32.py #Start program. #Get the number of t-shirts being purchased from the user, #assign to variable "amountOfShirts". #Calculate amountOfShirts * 12.99, assign to variable "priceOfShirts". #Assign number 8.99 to variable "shipping". #Determine discounts by lookin...
true
61a787ee69c3e67a8fbaab6c6d057aeab66245e6
Manish-bitpirate/Hacktoberfest
/python files/story_maker_by_cyoa.py
2,019
4.125
4
name=input("What's your name?") print("Treasure Hunter, a custom story by " + name ) print("You are a brave explorer that was recognized by the world and found an ancient Mayan temple!") opt1=input("Do you walk in? y/n?") opt2="" opt3="" opt4="" if opt1=="y": print("You walk in, your footsteps echoing in the dark. ...
true
6786774819903db96e9008597ea4d8060fc6f217
sunnysong1204/61a-sp14-website
/slides/lect21.py
2,276
4.125
4
class Tree: """A Tree consists of a label and a sequence of 0 or more Trees, called its children.""" def __init__(self, label, *children): """A Tree with given label and children. For convenience, if children[k] is not a Tree, it is converted into a leaf whose operator is children[...
false
bf74914843bb8ad4e81ba45d203d4f45aeaf80da
kate711/day1
/code/元组.py
555
4.25
4
# 创建元组 my_tuple = ('x', 'y', 'z') print('{}'.format(my_tuple)) print('{}'.format(len(my_tuple))) print('{}'.format(my_tuple[1])) longer_tuple = my_tuple + my_tuple print('{}'.format(longer_tuple)) # 元组解包 one, two, three = my_tuple print('{0} {1} {2}'.format(one, two, three)) var1 = 'red' var2 = 'robin' print('{} {}'.f...
false
111b3cb6d2a16e162794847257edd366dbb1afa3
ProfessorJas/Python_100_days
/day_031/class_attributes_ex.py
1,269
4.4375
4
class Person(object): # Define class attribute and assign the value nation = 'China' city = 'Shanghai' def __init__(self, name, age): # define object attribute self.name = name self.age = age p1 = Person('Joe Wang', 34) p2 = Person('Javier Amgio', 25) print('Visit the class at...
false
2027aa5e1dc4f9de83c2d23b0a4a47eb44783f96
ProfessorJas/Python_100_days
/day_027/str_method.py
2,311
4.34375
4
str = 'abcabcabc' print(str.count('ab')) # count 'ab' in the str print(str.count('ab', 2)) # count 'ab' in the str from index 2 print(str.endswith('bc')) # endwith check with the string end with some string # true print(str.endswith('b')) # false print(str.startswith('ab')) ...
false
9e7c846198b684c569f43e0305bedee64c624eff
ProfessorJas/Python_100_days
/day_027/list_meethod.py
2,661
4.21875
4
print([]) # create an empty list object # [] print(list()) # create an empty list object # [] print([1, 2, 4]) # list with the same type print([1, 2, 3, ('a', 'bc', 'defg'), [12, 34, 'amigo']]) # list with different type print(list('abcd')) # listify an iterative object ...
false
8fde712d6f525b47c1989497f3dbd086c61c7041
SAMLEVENSON/ACET
/Factorialwi.py
233
4.125
4
def main(): print("To find the Factorial of a Number") a= int(input("Enter the Number:")) if(a>=20) fact =1 for i in range(1,a + 1): fact = fact*i print(fac) if __name__ == '__main__': main()
true
63c49cd9cc64bfbaa471cfe06e10071ca8f82ca0
adelyalbuquerque/projetos_adely
/numeros.py
337
4.125
4
def maior_numero(): primeiro_numero = float(raw_input("Digite o primeiro numero: ")) segundo_numero = float(raw_input("Digite o segundo numero: ")) if primeiro_numero > segundo_numero: print "Maior numero: {}".format(primeiro_numero) else: print "Maior numero: {}".format(segundo_numero)...
false
9eb5f962bc60fa4c74d117fab1c7234562f1266d
anantkaushik/Data-Structures-and-Algorithms
/Data-Structures/Graphs/bfs.py
1,458
4.125
4
""" Graph traversal means visiting every vertex and edge exactly once in a well-defined order. While using certain graph algorithms, you must ensure that each vertex of the graph is visited exactly once. The order in which the vertices are visited are important and may depend upon the algorithm or question that you ...
true
2964932bc4395158beb2ee0eba705ee180eaac84
dbzahariev/Python-and-Django
/Python-Basic/exam_preparation_1/part_1/task_4.py
539
4.1875
4
best_player_name = '' best_player_goal = -1 while True: text = input() if text == 'END': break player_name = text player_goals = int(input()) if player_goals > best_player_goal: best_player_name = player_name best_player_goal = player_goals if player_goals >= 10: ...
true
6eadedf8522df051f41b244895ef32a747c2a06e
Vinicius-Moraes20/personal-projects
/programming/python/aula12/ex01.py
323
4.21875
4
nome = str(input("Digite seu nome: ")).strip().capitalize() if (nome == 'Vinicius'): print("Que nome bonito!") elif (nome == 'Pedro' or nome == 'Maria' or nome == 'Paulo'): print("Seu nome é bem popular no Brasil!") elif (nome in 'Ana Claudia Jessica Juliana'): print("Belo nome feminino!") print("Tenha um bo...
false
be68e36dca52277ac44319e15da56c61f319f267
Vinicius-Moraes20/personal-projects
/programming/python/ex044.py
740
4.125
4
valCompras = float(input("Digite o valor total das compras: R$")) print ("""---- Formas de pagamento ---- [1] à vista dinheiro/cheque [2] à vista cartão [3] 2x no cartão [4] 3x ou mais no cartão""") op = int(input("> ")) if op == 1: valPagar = valCompras - (valCompras * 0.10) elif op == 2: valPagar = valCompra...
false
7260c5bc6c62ec8395e56dc66f10c3858e1ae155
cocodrips/python2-collection
/snakeCamel.py
776
4.15625
4
""" snake_case => camelCase camelCase => snake_case """ def is_snake_case(word): if "_" in word : return True return False def translate(word): new_word = "" if is_snake_case(word): is_next_upper = False for c in word: if c == "_": is_next_upper = Tr...
false
0adc5800f99519b907a6939fee2c38ebc950da38
chaosWsF/Python-Practice
/leetcode/0326_power_of_three.py
710
4.34375
4
""" Given an integer, write a function to determine if it is a power of three. Example 1: Input: 27 Output: true Example 2: Input: 0 Output: false Example 3: Input: 9 Output: true Example 4: Input: 45 Output: false Follow up: Could you do it without using any loop / recursio...
true
ba66e9707f75734abd0a2bfb61c9c74655f4ed62
chaosWsF/Python-Practice
/leetcode/0035_search_insert_position.py
1,291
4.15625
4
""" Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Example 1: Input: [1,3,5,6], 5 Output: 2 Example 2: Input: [1,3,5,6], 2 Output: 1 Example 3: ...
true
6c9a0b00945ee3ea85cc7430ec2b40e660d05d4e
chaosWsF/Python-Practice
/leetcode/0532_k-diff_pairs_in_an_array.py
1,281
4.1875
4
""" Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute difference is k. Example 1: Input: [3, 1, 4, 1, 5], k = 2 Output: 2 Ex...
true
99b3a845267202d53a1f0e9e346b8bcb0a21a577
chaosWsF/Python-Practice
/leetcode/0020_valid_parentheses.py
1,707
4.1875
4
""" Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also consider...
true
ee5da787fc7206823a2f764e883ca3d3ecbf5caf
chaosWsF/Python-Practice
/leetcode/0344_reverse_string.py
1,092
4.25
4
""" Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. You may assume all the characters consist of printable ascii characters. Example 1: ...
true
c70a497fa0a9db39e3f4546fd96775912458e71d
chaosWsF/Python-Practice
/leetcode/0027_remove_element.py
1,988
4.25
4
""" Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The order of elements can be changed. It doesn't matter what you leave beyond...
true
bcd5d58a4b1789a205e03f69fe2458b9b4a5b5a2
chaosWsF/Python-Practice
/leetcode/0088_merge_sorted_array.py
2,069
4.21875
4
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from...
true
dd0ca36d22e09a8278608bbd0c02f554bc9cab26
chaosWsF/Python-Practice
/leetcode/1002_find_common_characters.py
1,281
4.15625
4
""" Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates). For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the final answer. You may r...
true
674ef5c016216bb2e64195ccb36ccb056773a720
chaosWsF/Python-Practice
/leetcode/0434_number_of_segments_in_a_string.py
546
4.15625
4
""" Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. Please note that the string does not contain any non-printable characters. Example: Input: "Hello, my name is John" Output: 5 """ class Solution: def countSegments1(self, s): ...
true
400142c7d92f56ad7af22a82663441976791369d
JQuinSmith/learning-python
/ex15.py
813
4.34375
4
# imports the module from sys import argv # the script, and the text file are used as modules script, filename = argv # Assuming "open" opens the file being passed into it for use in the rest of the script. txt = open(filename) # # Serves up the filename based on what is entered into the terminal. # print ("Here's y...
true
71678e32831ef0554e88ee5e916b749ba0a8ced9
Program-Explorers/Random_Password_Generator
/random_password.py
1,963
4.21875
4
# import statements #Random Password Generator import random import string def greeting(): print("This programs makes your password more secure based on a word you provide!" + "\nIt increases the strenth of your password by adding random letters and digits before or after the word\n") class password_g...
true
1cb20485ce03458d71b766dc450d2b9f624f8e21
Benjamin-Menashe/Project_Euler
/problem1.py
470
4.25
4
# -*- coding: utf-8 -*- """ Created on Sun Jan 3 10:09:34 2021 @author: Benjamin """ # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. import numpy as np fives = np.array(rang...
true
8d208cee28c4dc5fa45b42d4a7e57e2508840a3d
Yasaman1997/My_Python_Training
/Test/lists/__init__.py
1,599
4.375
4
zoo_animals = ["pangolin", "cassowary", "sloth", "dog"]; # One animal is missing! if len(zoo_animals) > 3: print "The first animal at the zoo is the " + zoo_animals[0] print "The second animal at the zoo is the " + zoo_animals[1] print "The third animal at the zoo is the " + zoo_animals[2] print "The fourth...
true
b3b79f7f01bee57c0eca157d2034692141628364
pedrohenriquebraga/Curso-Python
/Mundo 3/Aulas/Aula_17_Listas_1.py
645
4.34375
4
# PARA ADICIONAR ELEMENTOS A LISTAS USAMOS: lista.append(elemeto ser adicionado) # PARA ADICIONAR ELEMENTOS EM LUGARES ESPECÍFICOS DA LISTA USAMOS: # lista.insert(posição a ser adicionada, o que vai ser adicionado) # PARA EXCLUIR ELEMENTOS: del lista[elemento] # Também pode - se usar o lista.pop(elemento) # OUTRA MANEI...
false
c57cd7f705639865c0832d6ea4a0017e87e4562f
pedrohenriquebraga/Curso-Python
/Mundo 3/Exercícios/ex_079.py
639
4.125
4
# Verificação de valores em listas valores = list() while True: print("~" * 45) num = int(input("Digite um valor: ")) if num not in valores: valores.append(num) print("VALOR ADICIONADO COM SUCESSO...") else: print("VALOR DUPLICADO!! NÃO VOU ADICIONAR...") continuar = str(in...
false
810e9b7a1d47e4c5e19b452bb3ecda92a5cd79d1
zerojpyle/learningPy
/ex19_practice.py
590
4.15625
4
# define a function to do some math # I'm trying to find 10 ways to run a function def my_calc(number1, number2): print(f"First, {number1} + {number2} = {number1 + number2}!") print(f"Second, {number1} x {number2} = {number1 * number2}!") print(f"And that's it! Come back later and maybe you'll get more.\n")...
true
ea825b27fe780710ee9520c77bc7bdd9b69b6515
zerojpyle/learningPy
/ex6.py
887
4.4375
4
# define variable with a number types_of_people = 10 # define a variable as a literal string x = f"There are {types_of_people} types of people." # define a couple strings as variables binary = "binary" do_not = "don't" # define a variable as a literal string y = f"Those who know {binary} and those who {do_not}." # pr...
true
263486d8994eed386e885f539f2d9e6733973b11
praak/think_python
/chapter6/6_6.py
884
4.15625
4
# Palindrome def first(word): return word[0] def last(word): return word[-1] def middle(word): return word[1:-1] # Part 1: # a = 'aaa' # print a # print 'first: ' , first(a) # print 'middle: ' , middle(a) # print 'last: ' , last(a) # Part 2: def is_palindrome(stringArg): if (first(stringArg) == ...
false
a0f73784a1ad1a2971e71c9844e3d48c9eeed9a1
cyber-holmes/Centimeter_to_meter-and-inches_python
/height_cm.py
418
4.4375
4
#Goal:Convert given Height from Centimeter to Meter and Inches. #Step1:Take the input. height = input("Enter the Height in Centimeter: ") #Step2:Calculate the value of Meter from Centimeter. meter = height/100.0 #Step3:Calculate the value of Inch from Centimeter. inch = height/2.54 #Step4:Print the Height in Meter...
true
3870ff88d2ccf9e93b614019b111298bcf131898
durstido/Data-Structures-Practice
/mergesort.py
907
4.125
4
def mergesort(arr): if (len(arr)>1): mid = len(arr) // 2 left = arr[:mid] right = arr[mid:] mergesort(left) mergesort(right) #indexes for each array left_i = 0 right_i = 0 arr_i = 0 while right_i<len(right) and left_i<len(left): #while there is still elements in both lists if (right[right_i] ...
false
a592a2234e5b6947afc1999a5e3b93dc30d13efd
Termich/All
/Ch1/Workshop_1.py
1,891
4.15625
4
#Загадать случайное число #Ввожу что то, что я изучу через несколько уроков: import random start = 1 end = 100 #Указали точку начала и конца откуда можно производить случайный вывод числ. при чем задали их что они переменные. print('Давайте сыграем в игру: ты загадаешь число, а я попробую его угадать.') print('Для поп...
false
7377dab7bacfc1c807b49f473775fea650c305b3
starmap0312/python
/libraries/enumerate_zip.py
849
4.78125
5
print("1) enumerate():") # 1) enumerate(iterable): # return enumerate object that can be used to iterate both the indices and values of passed-in iterable for index, value in enumerate(["one", "two", "three"]): print(index, value) # 2) zip(iterable1, iterable2): # return an iterator of tuples, where the i-t...
true
9dc6900c0eb28775c0e4e8f9fbb353f0a57f6af9
xploreraj/HelloPython
/algos/programs/ZeckendorfsTheorem.py
479
4.28125
4
''' Print non-consecutive fibonacci numbers summing up to a given number ''' # return nearest fibonacci num lesser or equal to argument def nearest_fibo_num(num): a, b = 0, 1 while True: if a + b > num: break temp = b b = a + b a = temp return b if __name__ == ...
true
2dcff43bb6f73d3b5141178c3374911344e3c4aa
ronaldaguerrero/practice
/python2/python/fundamentals/lambdas.py
1,291
4.6875
5
# # Example 1 # # create a new list, with a lambda as an element # my_list = ['test_string', 99, lambda x : x ** 2] # # access the value in the list # # print(my_list[2]) # will print a lambda object stored in memory # # invoke the lambda function, passing in 5 as the argument # print(my_list[2](5)) # # Example 2 # # ...
true
d2331f4d0ae550d79cc36677b8d55a4c92153840
zahraaliaghazadeh/python
/functions_intro/banner.py
2,242
4.15625
4
# def banner_text(text=" ", screen_width=80): def banner_text(text: str = " ", screen_width: int = 80) -> None: """ Print a string centred, with ** either side. :param text: The string to print. An asterisk (*) will result in a row of asterisks. The default will print a blank line, with a ** borde...
true
5fdfa562e309a1adf91d366bfe03937faa133888
zahraaliaghazadeh/python
/NU-CS5001/lab02/adder.py
463
4.1875
4
# num1 = float(input("Enter a first value: ")) # num2 = float(input("Enter a second value: ")) # sum = num1 + num2 # print("The sum of {} + {} is {}".format(num1, num2, sum)) # ================================== # same code with function dedinition def main(): num1 = float(input("Enter a first value: ")) ...
true
181c9171852431ee36304736b097816f6cf423a3
jenjnif/cassidoo
/parentheses/parentheses.py
2,217
4.28125
4
''' 13 April 2020 This week’s question: Given a number n, write a function to generate all combinations of well-formed parentheses. Example: generateParens(3) [“((()))”, “(()())”, “(())()”, “()(())”, “()()()” ] ''' # def generate_parentheses(n): # parentheses_list = [] # if n == 1: # parentheses_l...
false
ac9d5c265190401c2e11d2b144cbf16961da09a2
snalahi/Python-Basics
/week3_assignment.py
2,114
4.4375
4
# rainfall_mi is a string that contains the average number of inches of rainfall in Michigan for every month (in inches) # with every month separated by a comma. Write code to compute the number of months that have more than 3 inches of # rainfall. Store the result in the variable num_rainy_months. In other words, coun...
true
06dbe5531992d6c6df8feb30c6b97b17b113b824
Daksh-ai/swapcase-of-string
/string swapcase.py
216
4.21875
4
def swapcase(string): return s.swapcase() s=input("Enter The String") sub=swapcase(s) print(sub) #example-->input=Daksh output-->dAKSH #in genrally we say that its used to change the case of string and vice-versa
true
4a5c254c5d241a0c09862ca7995b1652932cd858
arvagas/Sorting
/src/recursive_sorting/recursive_sorting.py
1,557
4.125
4
# TO-DO: complete the helpe function below to merge 2 sorted arrays def merge( arrA, arrB ): elements = len( arrA ) + len( arrB ) merged_arr = [0] * elements # TO-DO count = 0 while count < elements: if len(arrA) == 0: merged_arr[count] = arrB[0] arrB.pop(0) e...
true
654e27532d4de8711c90cdb88e30006c8702751a
srimanikantaarjun/Object_Oriented_Programming_Fundamentals
/08 Constructor in Inheritance.py
868
4.34375
4
class A: def __init__(self): print("in A init") def feature1(self): print("Feature 1 is working") def feature2(self): print("Feature 2 is working") class B: def __init__(self): super().__init__() print("in B init") def feature3(self): ...
true
2d787005363b28c07c13fe69bc091055ee638769
draetus/python_10apps_course
/app3/birthday_countdown.py
1,156
4.1875
4
import datetime def print_header(): print('-------------------------------------') print(' BIRTHDAY APP') print('-------------------------------------') print() def get_birthday_from_user(): print('Tell us when you were born: ') year = int(input('Year [YYYY]: ')) month = int(input...
false
6154996b2d90ec547184c54837d887f043baf163
CodeWithShamim/python-t-code
/Main/Method overriding.py
886
4.15625
4
#Method not overriding........... class google: def __init__(self): print("Result 1 : Hello, programmer!!.") class amazon(google): #add amazon all method.. pass val = amazon() #------------------------------------------------------------------ #Method overriding........... class google: ...
false
bfd3194a3f57b9e1daf459572d0c3a3c9fd0b24c
LarissaMidori/curso_em_video
/exercicio062.py
594
4.15625
4
''' Melhore o DESAFIO 61, perguntando para o usuário se ele quer mostrar mais alguns termos. O programa encerrará quando ele disser que quer mostrar 0 termos. ''' print(f'==== Super analisador de P.A. ====') termo = int(input('Primeiro termo: ')) razao = int(input('Razão: ')) mais = 10 total = 0 cont = 1 while mais !=...
false
e18f604f43805660026cff8a0ce10d14b0b99ea4
LarissaMidori/curso_em_video
/exercicio036.py
703
4.1875
4
''' Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa. Pergunte o valor da casa, o salário do comprador e em quantos anos ele vai pagar. A prestação mensal não pode exceder 30% do salário ou então o empréstimo será negado. ''' casa = float(input('Valor da casa: R$ ')) salario = float(inp...
false
8c6fc494dc35319b1b15e1df3de92677d366f2fe
LarissaMidori/curso_em_video
/exercicio014.py
218
4.28125
4
# Escreva um programa que leia uma temperatura digitada em °C e converta para °F temp = float(input('Digite a temperatura em °C: ')) print(f'A temperatura de {temp:.1f}°C, equivale à {(temp * 1.8 + 32):.1f}°F.')
false
9853a2266d1acbf23b8bba45db882b0b444fa030
hari2pega/Python-Day-wise-Practice-Sheets
/Hari_July 27th_Practice Sheet - Numbers and Introduction to List.py
1,862
4.53125
5
#!/usr/bin/env python # coding: utf-8 # In[1]: #Commenting the Line #What ever has been written after the Hash symbol, It will be considered as Comment #Numbers #Integers 2+3 # In[2]: #Numbers 3-2 # In[3]: #Float - It will be give the decimal value - Declaring in Decimal is called Float 0.1+0.2 # In[8]: ...
true
74402dc7fb9d97f14ecaebf30b201a5b96a7e7e3
dogeplusplus/DailyProgrammer
/222balancingwords.py
1,304
4.3125
4
def balance_word(word): '''the position and letter itself to calculate the weight around the balance point. A word can be balanced if the weight on either side of the balance point is equal. Not all words can be balanced, but those that can are interesting for this challenge. The formula to calculate the weight of th...
true
9b7ebf29fc78cf160361291530a3339ee5e0122a
maq-622674/python
/c语言中文网/py/7.函数和lambda表达式/7.1py函数/main.py
1,135
4.3125
4
''' Python函数(函数定义、函数调用)用法详解 ''' n=0 for c in "http://c.biancheng.net/python/": n = n + 1 print(n) #自定义 len() 函数 def my_len(str): length = 0 for c in str: length = length + 1 return length #调用自定义的 my_len() 函数 length = my_len("http://c.biancheng.net/python/") print(length) #再次调用 my_len() 函数 length ...
false
30c7107dc51933bf4c72c5a9cdd5e87c73ac6d01
maq-622674/python
/csdn_py/7.py网络爬虫基础(上)/1.py中的正则表达式.py
1,106
4.15625
4
# 一些表达式进行提取,正则表达式就是其中一种进行数据筛选的表达式。 # 正则表达式(Regular Expression)是一种文本模式,包括普通字符(例如,a 到 z 之间的字母)和特殊字符(称为"元字符")。 # 正则表达式通常被用来匹配、检索、替换和分割那些符合某个模式(规则)的文本。 # Python 自1.5版本起增加了re模块,它提供Perl风格的正则表达式模式。 # re 模块使 Python 语言拥有全部的正则表达式功能,使用前需要使用 import re 导入此模块 # compile 函数根据一个模式字符串和可选的标志参数生成一个正则表达式对象。该对象拥有一系列方法用于正则表达式匹配和替换。 imp...
false
117a672a7dc9c01ed5581a3983b3d7e57d53ecf9
maq-622674/python
/c语言中文网/py/5.py字符串常用方法/5.11py字符串大小写转换/main.py
521
4.21875
4
''' Python字符串大小写转换(3种)函数及用法 ''' #1.py title()方法 #两个单词之间无论用什么分开他都会把首字母变为大写 #比如apple——orange apple?orange apple_orange apple*orange str="c_biancheng.net" print(str.title()) #2.py lower()方法 #全部变小写 str="I LIKE C" print(str.lower()) #3.py upper()方法 str="i like c" print(str.upper()) #需要注意的是,以上 3 个方法都仅限于将转换后的新字符串返回,而不会修改原...
false
e90b652e9b9d921a5d3ca94e1b299ce07e07812f
sfmajors373/PythonPractice
/OddTest.py
364
4.1875
4
#Input largestoddnumbersofar = 0 counter = 0 #Test/Counter while counter < 10: x = int(input("Enter a number: ")) if x%2 == 1: if x > largestoddnumbersofar: largestoddnumbersofar = x counter = counter + 1 print(counter) #Output if counter == 10: print ("The largest od...
true
02673b7a8aaac520aec772ab345391aae54ab1d8
Vlad-Mihet/MergeSortPython
/MergeSortAlgorithm.py
2,189
4.3125
4
import random # Generating a random Array to be sorted # If needed, the random elements assignment could be removed, so a chosen array could be sorted ArrayToBeSorted = [random.randint(-100, 100) for item in range(15)] def MergeSort (array, left_index, right_index): if left_index >= right_index: r...
true
b20c48f78e7e9ead7849a262a327b419abf97ee8
aloksharma999/GreaterNumber
/GreaterNumber.py
240
4.125
4
a = int(input('Enter the first number: ')) b = int(input('Enter the second number:')) if a > b: print(a,'is the bigger number') elif a <b: print(b,'is the bigger number') elif a ==b: print(str(a) + 'is equal to ' +str(b))
false