blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
75a6883fb38db72e5775e46f6e94e49a3c4a9978
dimitardanailov/google-python-class
/python-dict-file.py
1,842
4.53125
5
# https://developers.google.com/edu/python/dict-files#dict-hash-table ## Can build up a dict by starting with the empty dict {} ## and storing key / value pairs into the dict like this: ## dict[key] = value-for-that-key dict = {} dict['a'] = 'alpha' dict['g'] = 'gamma' dict['o'] = 'omega' print dict ## {'a': ...
true
c7668e86b91ed2fbcaa51d0d4811ae448d0f2a14
RobDBennett/DS-Unit-3-Sprint-1-Software-Engineering
/module4-software-testing-documentation-and-licensing/arithmetic.py
1,941
4.21875
4
#!/usr/bin/env python # Create a class SimpleOperations which takes two arguements: # 1. 'a' (an integer) # 2. 'b' (an integer) # Create methods for (a, b) which will: # 1. Add # 2. Subtract # 3. Multiply # 4. Divide # Create a child class Complex which will inherit from SimpleOperations # and take (a, b) as argueme...
true
8a60d618f47ce9917bf2c8021b2863585af07672
sreesindhu-sabbineni/python-hackerrank
/TextWrap.py
511
4.21875
4
#You are given a string s and width w. #Your task is to wrap the string into a paragraph of width w. import textwrap def wrap(string, max_width): splittedstring = [string[i:i+max_width] for i in range(0,len(string),max_width)] returnstring = "" for st in splittedstring: returnstring += s...
true
90d57fc0012c7370848d13f914790c03a9f10054
Nouw/Programming-class
/les-8/ns-kaartautomaat.py
2,035
4.1875
4
stations = ['Schagen', 'Heerhugowaard', 'Alkmaar', 'Castricum', 'Zaandam', 'Amsterdam sloterdijk', 'Amsterdam Centraal', 'Amsterdam Amstel', 'Utrecht Centraal', "'s-Hertogenbosch", 'Eindhoven', 'Weert', 'Roermond', 'Sittard', 'Maastricht'] def inlezen_beginstation(stations): running = True while running: ...
false
25001af33ac7a663e5f20810c42d5cba3ac73242
AhmedElkhodary/Python-3-Programming-specialization
/1- Python Basics/FinalCourseAssignment/pro5.py
620
4.15625
4
#Provided is a list of data about a store’s inventory where each item #in the list represents the name of an item, how much is in stock, #and how much it costs. Print out each item in the list with the same #formatting, using the .format method (not string concatenation). #For example, the first print statment shou...
true
a53c2faa1c8da8d9f736720d2f653811898ea67a
AhmedElkhodary/Python-3-Programming-specialization
/1- Python Basics/Week4/pro3.py
256
4.3125
4
# For each character in the string already saved in # the variable str1, add each character to a list called chars. str1 = "I love python" # HINT: what's the accumulator? That should go here. chars = [] for ch in str1: chars.append(ch) print(chars)
true
a1b182cd04c27dc9c000923a627c7e6cb2a2ff3b
DiegoCol93/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
2,275
4.25
4
#!/usr/bin/python3 """ Module for storing the Square class. """ from models.rectangle import Rectangle from collections import OrderedDict class Square(Rectangle): """ Por Esta no poner esta documentacion me cague el cuadrado :C """ # __init__ | Private | method |-------------------------------------------| ...
true
cf09393ec6a76c29cdd9ba6b187edc1121fe612b
CorSar5/Python-World2
/exercícios 36-71/ex052.py
220
4.15625
4
n = int(input('Escreva um número: ')) if n % 2 == 0 or n % 3 == 0 or n % 5== 0 or n % 7 == 0: print('Esse número {} não é um número primo'.format(n)) else: print('O número {} é um número primo'.format(n))
false
971187848e721a42aec82fb6aa5d13f881d84ff4
johnmwalters/dsp
/python/q8_parsing.py
1,242
4.40625
4
# The football.csv file contains the results from the English Premier League. # The colums labeled 'Goals and 'Goals Allowed' contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program to rea...
true
714808135eb230b3fca687200a112a888a7809fd
dutraph/python_2021
/basic/while_calc.py
675
4.21875
4
while True: print() n1 = input("Enter 1st number: ") n2 = input("Enter 2nd number: ") oper = input("Enter the operator: ") if not n1.isnumeric() or not n2.isnumeric(): print("Enter a valid number...") continue n1 = int(n1) n2 = int(n2) if oper == '+': pri...
false
c750ed33c5ec4069676685a31f4257f58055d9b0
nataliaqsoares/Curso-em-Video
/Mundo 01/desafio023 - Separando digitos de um numero.py
811
4.1875
4
""" Desafio 023 Faça um programa que leia um número de 0 a 9999 e mostre na tela um dos dígitos separados. Ex: Digite um número: 1834 Unidade: 4 Dezena: 3 Centena: 8 Milhar: 1 """ # Solução 1: com está solução só é possível obter o resulatdo esperado quando se coloca as quatro unidades num = input('Digite um número en...
false
6282e26c75b7c3673cdbbe6a5418af6232cfa647
nataliaqsoares/Curso-em-Video
/Mundo 01/desafio035 - Analisando triangulos v1.0.py
574
4.21875
4
""" Desafio 035 Desenvolva um programa que leia o comprimento de três retas e diga ao usuário se elas podem ou não formar um triângulo """ reta1 = float(input('Informe o valor da primeira reta:')) reta2 = float(input('Informe o valor da segunda reta:')) reta3 = float(input('Informe o valor da terceira reta:')) if (re...
false
dd1ae1af46e3a860d227f51cc14f5270e6e4d66d
nataliaqsoares/Curso-em-Video
/Mundo 01/desafio004 - Dissecando uma variavel.py
718
4.25
4
""" Desafio 004 Faça um programa que leia algo pelo teclado e mostre na tela o seu tipo primitivo e todas as informações possíveis sobre ele """ msg = input(' Digite algo: ') print('O valor {} e ele é do tipo primitivo desse valor é {}'.format(msg, type(msg))) print('Esse valor é númerico? {}'.format(msg.isnumeric()))...
false
1bc9ada8524c22e186391996992ee6458c992b98
nataliaqsoares/Curso-em-Video
/Mundo 03/desafio075 - Analise de dados em uma tupla.py
853
4.28125
4
""" Desafio 075 Desenvolva um programa que leia quatro valores pelo teclado e guarde-os em uma tupla. No final, mostre: a) quantas vezes apareceu o valor 9; b) em que posição foi digitado o primeiro valor 3; c) quais foram os números pares; """ conjunto = (int(input('Informe um número: ')), int(input('Informe um númer...
false
0048caeb7b3546c1ae8cc917685d0df5242ad2b3
nataliaqsoares/Curso-em-Video
/Mundo 01/desafio033 - Maior e menor valores.py
600
4.15625
4
""" Desafio 033 Faça um programa que leia três números e mostre qual é o maior e qual é o menor. """ n1 = int(input('Informe um número: ')) n2 = int(input('Informe mais um número: ')) n3 = int(input('Informe mais um número: ')) maior = 0 menor = 0 if n1 > n2 and n1 > n3: maior = n1 if n2 > n1 and n2 > n3: ma...
false
fccf2bdb5f6afe42e695468b8cefc57fedb19783
nataliaqsoares/Curso-em-Video
/Mundo 01/desafio028 - Jogo de Adivinhacao v.1.0.py
526
4.25
4
""" Desafio 028 Escreva um programa que faça o computador 'pensar' em um número inteiro entre 0 e 5 e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador. O programa deverá escrever na tela se o usuário venceu ou perdeu """ from random import randint print('Estou pensando em um número ent...
false
693dd4620876b1525d56d4b03c47a34f032feb20
nataliaqsoares/Curso-em-Video
/Mundo 02/desafio036 - Aprovando emprestimo.py
842
4.1875
4
""" Desafio 036 Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa. O programa vai perguntar o valor da casa, o salário do comprador e em quantos anos ele vai pagar. Calcule o valor da prestação mensal, sabendo que ela não pode exceder 30% do salário ou então o empréstimo será negado """ ...
false
967aa21504999e6fd116ebd555c548bc26f6903c
nataliaqsoares/Curso-em-Video
/Mundo 01/desafio002.1 - Data de nascimento.py
514
4.125
4
""" Desafio002.1 Crie um programa que leia o dia, o mês e o ano de nascimento de uma pessoa e mostre uma mensagem com a data formatada (mensagem de saida = Você nasceu no dia x de x de x. Correto?) """ # Solução 1 nasci = input('Quando você nasceu? ') print('Você nasceu em', nasci, 'Correto?') # Solução 2 dia = inp...
false
499b850f68b05aceb843bcd4f6f94c9cb1077afc
thales-mro/python-cookbook
/2-strings/4-pattern-match-and-search.py
1,181
4.125
4
import re def date_match(date): if re.match(r'\d+/\d+/\d+', date): print('yes') else: print('no') def main(): text = 'yeah, but no, but yeah, but no, but yeah' print(text.find('no')) date1 = '02/01/2020' date2 = '02 Jan, 2020' date_match(date1) date_match(date2) ...
true
881166784fd6a82253a5b189f956582a7a8de5e0
firebirdrazer/CodingTests
/check_paren.py
1,952
4.40625
4
def check_bracket(Str): stack = [] #make a empty check stack while Str != "": #as long as the input is not empty tChar = Str[0] #extract the first character as the test character ...
true
f76c1e50db88f9f61b22f0a655faf0ff1ed817f7
ryanhgunn/learning
/unique.py
382
4.21875
4
# A script to determine if characters in a given string are unique. import sys string = input("Input a string here: ") for i in range(0, len(string)): for j in range(i + 1, len(string)): if string[i] == string[j]: print("The characters in the given string are not unique.") sys.exi...
true
d279398b290a9f0320bacaa23864b3be614100c3
AndrewGreen96/Python
/math.py
1,217
4.28125
4
# 4.3 Counting to twenty # Use a for loop to print the numbers from 1 to 20. for number in range(1,21): print(number) # 4.4 One million # Make a list from 1 to 1,000,000 and use a for loop to print it big_list = list(range(1,1000001)) print(big_list) # 4.5 Summing to one million # Create a list...
true
f003dd889cdce228f66dbad8f66955c9c32563c0
csgray/IPND_lesson_3
/media.py
1,388
4.625
5
# Lesson 3.4: Make Classes # Mini-Project: Movies Website # In this file, you will define the class Movie. You could do this # directly in entertainment_center.py but many developers keep their # class definitions separate from the rest of their code. This also # gives you practice importing Python files. # https://w...
true
a6abf1f12cc09aeb393630d5c59219e9ae0c479b
chill133/BMI-calculator-
/BMI.py
310
4.25
4
height = input("What is your height?") weight = input("What is your weight?") BMI = 703 * (int(weight))/(int(height)**2) print("Your BMI " + str(BMI)) if (BMI <= 18): print("You are underweight") elif (BMI >= 18) and (BMI <= 26): print("You are normal weight") else: print("You are overweight")
false
e8e71c47bd34a628562c9dfcd351bcd336a99d70
endar-firmansyah/belajar_python
/oddevennumber.py
334
4.375
4
# Python program to check if the input number is odd or even. # A number is even if division by given 2 gives a remainder of 0. # If the remainder is 1, it is an odd number # div = 79 div = int(input("Input a number: ")) if (div % 2) == 0: print("{0} is even Number".format(div)) else: print("{0} is Odd Number"....
true
b928d3b1b8bfac3efa68e1bccaa9347c16482bd8
JianHui1208/Code_File
/Python/Lists.py
291
4.15625
4
thislist = ["a", "b","c"] print(thislist) thislist = ["a", "b", "c"] print(thislist[1]) # same the array start for 0 thislist = ["a", "b", "c"] print(thislist[-1]) # -1 is same like the last itme # -2 is second last itme thislist = ["a", "b", "c", "d", "e", "f", "g"] print(thislist[2:5])
false
7a539c585cf9adca8dc788fea5295f99a65b5e92
wecchi/univesp_com110
/Sem2-Texto22.py
1,217
4.15625
4
''' Texto de apoio - Python3 – Conceitos e aplicações – uma abordagem didática (Ler: seções 2.3, 2.4 e 4.1) | Sérgio Luiz Banin Problema Prático 2.2 Traduza os comandos a seguir para expressões Booleanas em Python e avalie-as: (a)A soma de 2 e 2 é menor que 4. (b)O valor de 7 // 3 é igual a 1 + 1. (c)A soma de ...
false
2681542783b3751bd885d3f5d829d6bf2ccde4be
code-wiki/Data-Structure
/Array/(Manacher's Algoritm)Longest Palindromic Substring.py
1,046
4.125
4
# Hi, here's your problem today. This problem was asked by Twitter: # A palindrome is a sequence of characters that reads the same backwards and forwards. # Given a string, s, find the longest palindromic substring in s. # Example: # Input: "banana" # Output: "anana" # Input: "million" # Output: "illi" # class Solut...
true
f503e91072d0dd6c7402e8ae662b6139feed05e0
adykumar/Leeter
/python/104_maximum-depth-of-binary-tree.py
1,449
4.125
4
""" WORKING.... Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Note: A leaf is a node with no children. Example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its...
true
c5765011e3f9b07eae3a52995d20b45d0f462229
adykumar/Leeter
/python/429_n-ary-tree-level-order-traversal.py
1,083
4.1875
4
""" Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3-ary tree: 1 / | \ 3 2 4 / \ 5 6 We should return its level order traversal: [ [1], [3,2,4], [5,6] ] Note: The depth of th...
true
2b65c4cf9a9372262d2cc927904e36f69cec9cd4
mosabry/Python-Stepik-Challenge
/1.06 Compute the area of a rectangle.py
323
4.15625
4
width_string = input("Please enter width: ") # you need to convert width_string to a NUMBER. If you don't know how to do that, look at step 1 again. width_number = int(width_string) height_string = input("Please enter height: ") height_number = int(height_string) print("The area is:") print(width_number * height_numb...
true
b7b296552886fe0ca8d13d543770e0575361837c
joanamdsantos/world_happiness
/functions.py
1,018
4.125
4
import numpy as np import pandas as pd import seaborn as sns import matplotlib as mpl import matplotlib.pyplot as plt def plot_countrybarplot(df, var, top_num): ''' INPUT: df - pandas dataframe with the data var- variable to plot, not categorical top_num - number of top countries to pl...
true
54f0e746f3067e9c8f182de031b0711fd4033569
shinozaki1595/hacktoberfest2021-3
/Python/Algorithms/Sorting/heap_sort.py
884
4.34375
4
# Converting array to heap def arr_heap(arr, s, i): # To find the largest element among a root and children largest = i l = 2 * i + 1 r = 2 * i + 2 if l < s and arr[i] < arr[l]: largest = l if r < s and arr[largest] < arr[r]: largest = r # Replace the root if it is not the...
false
70d87e6fe32ad1b0d647e85cf8a64c8f59c9398a
marcin-skurczynski/IPB2017
/Daria-ATM.py
568
4.125
4
balance = 542.31 pin = "1423" inputPin = input("Please input your pin: ") while pin != inputPin: print ("Wrong password. Please try again.") inputPin = input("Please input your pin: ") withdrawSum = float(input("How much money do you need? ")) while withdrawSum > balance: print ("The sum you are trying to wi...
true
296dd75cbc77a834515929bc0820794909fb9e54
sdaless/pyfiles
/CSI127/shift_left.py
414
4.3125
4
#Name: Sara D'Alessandro #Date: September 12, 2018 #This program prompts the user to enter a word and then prints the word with each letter shifted left by 1. word = input("Enter a lowercase word: ") codedWord = "" for ch in word: offset = ord(ch) - ord('a') - 1 wrap = offset % 26 newChar = chr(ord('a...
true
b3dbf8b4190548cd3787fbe0021ca46244b116af
sdaless/pyfiles
/CSI127/turtle_color.py
208
4.53125
5
#Sara D'Alessandro #A program that changes the color of turtle #September 26th, 2018 import turtle tut = turtle.Turtle() tut.shape("turtle") hex = input("Enter a hex string starting with '#' sign: ") tut.color(hex)
false
5f7c7a681de3287b0e2c05bb05d18df626eb3b54
sudev/dsa
/graph/UsingAdjacencyList.py
1,677
4.15625
4
# A graph implementation using adjacency list # Python 3 class Vertex(): def __init__(self, key): self.id = key # A dictionary to act as adjacency list. self.connectedTo = {} def addEdge(self, vert, w=0): self.connectedTo[vert] = w # Repr def __str__(self): return str(self.id) + ' connectedTo: ' +...
true
31d68d11fdc06c09e0721e6541024eb33b585c91
selimozen/Hackerrank
/Python/ifelse.py
546
4.3125
4
#ENG: if n is odd, print Weird , if n is even and in the inclusive range of 2 to 5, print Not Weird, #if n is even and in the inclusive range of 6 to 20, print Weird, if is even and greater than 20, print Not Weird #TR: Eğer n sayısı tekil ise, 'Weird' yazdır, eğer n sayısı 2 veya 5'e eşit veya arasında ise Not Weird...
false
a961f3be1e5d83fbd174bc21851b0753bec84c04
andersonresende/learning_python
/chapter_19/recursion.py
1,077
4.21875
4
#nao mudar o tipo de uma variavel e uma boa pratica #nao usar globais dentro de funcoes, pois pode criar dependencias. #durante a recursao o escopo das funcoes e mantido, por isso funciona. #recursao exige que vc crie uma funcao, enquanto procedural nao. #vc nao pode alterar os valores de variaveis a partir de fora da ...
false
609add66f670ba8c7b3863bc12603b83e71c99af
andersonresende/learning_python
/chapter_18/min.py
723
4.125
4
def min1(*args): ''' Retorna o menor valor, passado em uma tupla. ''' res = args[0] for arg in args[1:]: if arg < res: res = arg return res print min1(10,2,3,4) def min2(first, *rest): ''' Retorna o menor valor, recebendo um argumento inicial e outros em uma tupla. ''' for arg in rest: if arg < first:...
false
0406e3cc0d3d09c9bbaf400c2808ebf0737d31d4
bharathkkb/peer-tutor
/peer-tutor-api/timeBlock.py
1,230
4.25
4
import time import datetime class TimeBlock: """ Returns a ```Time Block``` object with the given startTime and endTime """ def __init__(self, start_time, end_time): self.start_time = start_time self.end_time = end_time print("A time block object is created.") def __str__(...
true
6edfeb4705a4f49b354ef9571029d19b9848f8e5
dani3l8200/100-days-of-python
/day1-printing-start/project1.py
454
4.28125
4
#1. Create a greeting for your program. print('Welcome to Project1 of 100 Days of Code Python') #2. Ask the user for the city that they grew up in. city_grew_user = input('Whats is your country that grew up in?\n') #3. Ask the user for the name of a pet. pet_of_user = input('Whats is the name of any pet that having?\n'...
true
215ae22230731d3c486c7b652128fb1b212c78e0
islamrumon/PythonProblems
/Sets.py
2,058
4.40625
4
# Write a Python program to create a new empty set. x =set() print(x) n = set([0, 1, 2, 3, 4]) print(n) # Write a Python program to iteration over sets. num_set = set([0, 1, 2, 3, 4, 5]) for n in num_set: print(n) # Write a Python program to add member(s) in a set. color_set = set() color_set.add("Red") print...
true
aae16277602c86460bafa3df51c1eb258c7d85db
roxdsouza/PythonLessons
/Dictionaries.py
2,088
4.65625
5
# Dictionary is written as a series of key:value pairs seperated by commas, enclosed in curly braces{}. # An empty dictionary is an empty {}. # Dictionaries can be nested by writing one value inside another dictionary, or within a list or tuple. print "--------------------------------" # Defining dictionary dic1 = {'...
true
4fa1560b335f86dae73766c7f6b316e339d54671
roxdsouza/PythonLessons
/Classes04.py
964
4.125
4
# Program to understand class and instance variables # class Edureka: # # # Defining a class variable # domain = 'Big data analytics' # # def SetCourse(self, name): # name is an instance variable # # Defining an instance variable # self.name = name # # # obj1 = Edureka() # Creating an inst...
true
4e7b02140879900cbbb4e3889789c8b3dcd15291
LewisT543/Notes
/Learning_Data_processing/3SQLite-update-delete.py
1,440
4.46875
4
#### SQLITE UPDATING AND DELETING #### # UPDATING DATA # # Each of the tasks created has its own priority, but what if we decide that one of them should be done earlier than the others. # How can we increase its priority? We have to use the SQL statement called UPDATE. # The UPDATE sta...
true
100a33b667fa60386fabf26718b7bdf71d25d26c
satlawa/ucy_dsa_projects
/Project_0/Task2.py
1,759
4.25
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 2: Which telephone number spent the ...
true
89309e6aa3917fee2427a1e16113a3de202994d5
achmielecki/AI_Project
/agent/agent.py
2,136
4.25
4
""" File including Agent class which implementing methods of moving around, making decisions, storing the history of decisions. """ class Agent(object): """ Class representing agent in game world. Agent has to reach to destination point in the shortest distance. World is random generat...
true
b1e4492ff80874eeada53f05d6158fc3ce419297
lovepurple/leecode
/first_bad_version.py
1,574
4.1875
4
""" 278. 2018-8-16 18:15:47 You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose y...
true
29ef17e51ae29ba273a3b59e65419d73bacf6aa0
mathivananr1987/python-workouts
/dictionary-tuple-set.py
1,077
4.125
4
# Tuple is similar to list. But it is immutable. # Data in a tuple is written using parenthesis and commas. fruits = ("apple", "banana", "cherry", "orange", "kiwi", "melon", "mango") print("count of orange", fruits.count("orange")) print('Index value of orange', fruits.index("orange")) # Python Dictionary is an unord...
true
7ca52317a28ac1a45a2a44b3d8d769def95493e5
cd-chicago-june-cohort/dojo_assignments_mikeSullivan1
/python_fundamentals/MakingDicts.py
329
4.34375
4
def print_dict(dict): print "My name is", dict["name"] print "My age is", dict["age"] print "My country of birth is", dict["birthplace"] print "My favorite language is", dict["language"] myDict = {} myDict["name"]="Mike" myDict["age"]=34 myDict["birthplace"]="USA" myDict["language"]="Python" print_dic...
false
63cd3250a2453bc5dcf1083a3f9010fd6496fe1f
BrandonCzaja/Sololearn
/Python/Control_Structures/Boolean_Logic.py
650
4.25
4
# Boolean logic operators are (and, or, not) # And Operator # print(1 == 1 and 2 == 2) # print(1 == 1 and 2 == 3) # print(1 != 1 and 2 == 2) # print(2 < 1 and 3 > 6) # Example of boolean logic with an if statement # I can either leave the expressions unwrapped, wrap each individual statement or wrap the whole if con...
true
674d9922f89514e4266c48ec91b98f223fdcf313
Ang3l1t0/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
410
4.1875
4
#!/usr/bin/python3 """Append """ def append_write(filename="", text=""): """append_write method Keyword Arguments: filename {str} -- file name or path (default: {""}) text {str} -- text to append (default: {""}) Returns: [str] -- text that will append """ with open(filena...
true
982c7852214a41e505052c5674006286fc26b4b9
Ang3l1t0/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
444
4.34375
4
#!/usr/bin/python3 """print_square""" def print_square(size): """print_square Arguments: size {int} -- square size Raises: TypeError: If size is not an integer ValueError: If size is lower than 0 """ if type(size) is not int: raise TypeError("size must be an integ...
true
af528387ea37e35a6f12b53b392f920087e5284b
Ang3l1t0/holbertonschool-higher_level_programming
/0x02-python-import_modules/2-args.py
596
4.375
4
#!/usr/bin/python3 import sys from sys import argv if __name__ == "__main__": # leng argv starts in 1 with the name of the function # 1 = function name if len(argv) == 1: print("{:d} arguments.".format(len(sys.argv) - 1)) # 2 = first argument if is equal to 2 it means just one arg elif len(a...
true
5253817eac722b8e72fa1eadb560f8b7c7d73250
weeksghost/snippets
/fizzbuzz/fizzbuzz.py
562
4.21875
4
"""Write a program that prints the numbers from 1 to 100. But for multiples of three print 'Fizz' instead of the number. For the multiples of five print 'Buzz'. For numbers which are multiples of both three and five print 'FizzBuzz'.""" from random import randint def fizzbuzz(num): for x in range(1, 101): if x ...
true
9a6e7b9ac1d4dceb8acf9e618cbe5dc63a92566e
roger1688/AdvancedPython_2019
/03_oop_init/hw1.py
1,039
4.125
4
class Node: def __init__(self, val): self.val = val self.next = None def print_linked_list(head): now = head while now: print('{} > '.format(now.val),end='') now = now.next print() # print newline # # Linked-list and print test # n1 = Node(1) # n2 = Node(3) # n3 = Node...
false
6305227ae30aa254fc14bbe65e646b3ecfc38224
guingomes/Linguagem_Python
/1.operadores_aritmeticos.py
385
4.125
4
#objetivo é criar um programa em que o usuário insere dois valores para a mensuração de operações diversas. n1 = int(input('Digite um valor: ')) n2 = int(input('Digite outro valor: ')) s = n1+n2 m = n1*n2 d = n1/n2 di = n1//n2 e = n1**n2 print('A soma é: {}, o produto é: {} e a divisão é: {:.3f}'.format(s, m, d)) pri...
false
6724a08be69d5429e28bbf028f3cafe78337b8f2
zzfima/GrokkingAlgorithms
/Rec_sum_p81.py
357
4.125
4
def main(): print(SummArrayNumbers([3, 5, 2, 10])) def SummArrayNumbers(arr): """Sum array of numbers in recursive way Args: arr (array): numerical array Returns: int: sum of numbers """ if len(arr) == 1: return arr[0] return arr[0] + SummArrayNumbers(arr[1:]) i...
false
01af00a403187b6b3a2e68e0c1a3c82b475b8794
walleri18/Programming-tasks-Python-3.x
/Programming tasks/The first paragraph/Six tasks/Six tasks.py
1,177
4.21875
4
# Ипортирование мматематической библиотеки import math # Катеты прямоугольного треугольника oneCathetus, twoCathetus = 1, 1 # Получение данных oneCathetus = float(input("Введите первый катет прямоугольного треугольника: ")) twoCathetus = float(input("Введите второй катет прямоугольного треугольного: ")) oneCathetus ...
false
0077eae25b7f9731ffa985e5f7a8e079e417c27b
ScottBlaine/mycode
/fact/loopingch.py
808
4.28125
4
#!/usr/bin/env python3 farms = [{"name": "NE Farm", "agriculture": ["sheep", "cows", "pigs", "chickens", "llamas", "cats"]}, {"name": "W Farm", "agriculture": ["pigs", "chickens", "llamas"]}, {"name": "SE Farm", "agriculture": ["chickens", "carrots", "celery"]}] Farm = farms[0] for...
false
33d66808b44b182de3a9978dee9a8e88ce2d8b83
kranthikiranm67/TestWorkshop
/question_03.py
1,044
4.1875
4
#question_03 = """ An anagram I am Given two strings s0 and s1, return whether they are anagrams of each other. Two words are anagrams when you can rearrange one to become the other. For example, “listen” and “silent” are anagrams. Constraints: - Length of s0 and s1 is at most 5000. Example 1: Input: s0 = “listen” ...
true
26c06e9f868010768bdc7c7248cd1bf69032b1c4
AlenaRyzhkova/CS50
/pset6/sentimental/caesar.py
628
4.21875
4
from cs50 import get_string import sys # 1. get the key if not len(sys.argv)==2: print("Usage: python caesar.py <key>") sys.exit(1) key = int(sys.argv[1]) # 2. get plain text plaintext = get_string("Please, enter a text for encryption: ") print("Plaintext: " + plaintext) # 3. encipter ciphertext="" for c in ...
true
17e7494fcbb225659e4e6add6d0f4874fdf87f59
dannslima/MundoPythonGuanabara
/MUNDO3/ex072.py
561
4.25
4
#Crie um programa que tenha uma tupla totalmente preenchida com uma contagem por extenso, # de zero até vinte. #Seu programa deverá ler um numero pelo teclado (entre 0 e 20) e motra-lo por extenso. cont = ('zero','um','dois','tres','quatro','cinco','seis','sete','oito','nove','dez','onze','doze', 'treze','quatorze','q...
false
96e2e0d4ccfdb550673860199813c5467b83fe9f
rmedalla/5-2-18
/Calculator.py
429
4.1875
4
first_number = int(input("Enter first number: ")) math_operation = input("Choose an operand +, -, *, /: ") second_number = int(input("Enter second number: ")) if math_operation == "+": print(first_number + second_number) if math_operation == "-": print(first_number - second_number) if math_operation == "*": ...
false
df9a22117bd98acc6880792e5c3c0273f270067d
umasp11/PythonLearning
/polymerphism.py
1,482
4.3125
4
#polymorphism is the condition of occurrence in different forms. it uses two method overRiding & overLoading # Overriding means having two method with same name but doing different tasks, it means one method overrides the other #Methd overriding is used when programmer want to modify the existing behavior of a method ...
true
62c33ddc7ddc1daba876dd0422432686fcf361eb
umasp11/PythonLearning
/Threading.py
890
4.125
4
''' Multitasking: Execute multiple task at the same time Processed based multitasking: Executing multi task at same time where each task is a separate independent program(process) Thread based multitasking: Executing multiple task at the same time where each task is a separate independent part of the same program(proce...
true
24cda752498f51e747e869109f81da988089ca5a
developerhat/project-folder
/oop_practice.py
608
4.125
4
#OOP Practice 04/08/20 class Employee: def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last + '@patgo.com' def fullname(self): return '{} {}'.format(self.first, self.last) emp_1 = Employee('pat','...
false
116936cad73564abb9355199f5c8604d0b0bb8e7
girish75/PythonByGireeshP
/pycode/Quesetion1assignment.py
925
4.40625
4
# 1. Accept user input of two complex numbers (total 4 inputs, 2 for real and 2 for imaginary part). # Perform complex number operations (c1 + c2, c1 - c2, c1 * c2) a = int(input("For first complex number, enter real number")) b = int(input("For first complex number, enter imaginary number")) a1 = int(input("For sec...
true
ac235a932c259aac16a2a47fe0a45f9255e8a6f0
girish75/PythonByGireeshP
/pythonproject/FirstProject/jsong.py
1,813
4.3125
4
import json ''' The Json module provides an easy way to encode and decode data in JSON Convert from Python to JSON: If you have a Python object, you can convert it into a JSON string by using the json.dumps() method. convert Python objects of the following types, into JSON strings: dict, list tuple, string...
true
2196af2ef6617fbba8292dda5aed2649e1aac0a3
himal8848/Data-Structures-and-Algorithms-in-Python
/bubble_sort.py
315
4.1875
4
#Bubble Sort in Python def bubble_sort(list): for i in range(len(list)-1,0,-1): for j in range(i): if list[j] > list[j+1]: temp = list[j] list[j] = list[j+1] list[j+1] = temp list = [23,12,8,9,25,13,6] result = bubble_sort(list) print(list)
false
75260678d000751037a56f69e517b253e7d82ad9
aasmith33/GPA-Calculator
/GPAsmith.py
647
4.1875
4
# This program allows a user to input their name, credit hours, and quality points. Then it calculates their GPA and outputs their name and GPA. import time name = str(input('What is your name? ')) # asks user for their name hours = int(input('How many credit hours have you earned? ')) # asks user for credit hours ea...
true
eaa7fec6da4273925a0cb7b68c910a729bf26f3c
Yaguit/lab-code-simplicity-efficiency
/your-code/challenge-2.py
822
4.15625
4
""" The code below generates a given number of random strings that consists of numbers and lower case English letters. You can also define the range of the variable lengths of the strings being generated. The code is functional but has a lot of room for improvement. Use what you have learned about simple and efficien...
true
59a5e4e86c2ccfd9b33ca254a220754fe981ebf7
newkstime/PythonLabs
/Lab07/Lab07P4.py
2,277
4.1875
4
def main(): numberOfLabs = int(input("How many labs are you entering?")) while numberOfLabs <= 0: print("Invalid input") numberOfLabs = int(input("How many labs are you entering?")) labScores = [] i = 0 while i < numberOfLabs: score = float(input("Enter a lab score:")) ...
true
842938b66f413e4a260395823d59a0a589bbdecf
newkstime/PythonLabs
/Lab03 - Selection Control Structures/Lab03P2.py
824
4.21875
4
secondsSinceMidnight = int(input("Please enter the number of seconds since midnight:")) seconds = '{:02}'.format(secondsSinceMidnight % 60) minutesSinceMidnight = secondsSinceMidnight // 60 minutes = '{:02}'.format(minutesSinceMidnight % 60) hoursSinceMidnight = minutesSinceMidnight // 60 if hoursSinceMidnight < 24 and...
true
762f0115352b4b776ece45f8d5998b5ec06cd2ea
M-Karthik7/Numpy
/main.py
2,932
4.125
4
Numpy Notes Numpy is faster than lists. computers sees any number in binary fromat it stores the int in 4 bytes ex : 5--> 00000000 00000000 00000000 00000101 (int32) list is an built in int type for python it consists of 1) size -- 4 bytes 2) reference count -- 8...
true
9344dfc77da748a5bcfc5c2eac7a1cd0b0e810f3
Panda-ing/practice-py
/python_course/pentagram/pentagram_v3.0.py
573
4.25
4
""" 作者:xxx 功能:五角星绘制 版本:3.0 日期:17/6/2020 新增功能:加入循环操作绘制不同大小的图形 新增功能:使用迭代绘制不同大小的图形 """ import turtle def draw_pentagram(size): count = 1 while count <= 5: turtle.forward(size) turtle.right(144) count = count + 1 def main(): """ 主函数 """ size = 50 ...
false
1ca0d3089cf33131b408c6f11ff4ec813a02f6f4
chengyin38/python_fundamentals
/Fizz Buzz Lab.py
2,092
4.53125
5
# Databricks notebook source # MAGIC %md # MAGIC # Fizz Buzz Lab # MAGIC # MAGIC * Write a function called `fizzBuzz` that takes in a number. # MAGIC * If the number is divisible by 3 print `Fizz`. If the number is divisible by 5 print `Buzz`. If it is divisible by both 3 and 5 print `FizzBuzz` on one line. # MAGIC ...
true
a85d09e57b7a1e7fdaa8055003c922b494b7e437
angelfaraldo/intro_python_music
/1-01_crear-y-ejecutar-programas.py
1,424
4.46875
4
""" INTRODUCCIÓN A LA PROGRAMACIÓN EN PYTHON A TRAVÉS DE LA MÚSICA Ángel Faraldo, del 19 al 23 de julio de 2021 Campus Junior, Universitat Pompeu Fabra "1-01_crear-y-ejecutar-programas" contenidos: print(), comentarios, input(), variables, string concatenation """ # PRINT y CADENAS print("hola, chicas y chicos!") pri...
false
d9a10876de3734ff92d0aa77aff01c8fe5f280f8
maslyankov/python-small-programs
/F87302_L3_T1.py
550
4.28125
4
# Encrypt a string using Cesar's cipher. import sys plain = sys.argv[1] key = int(sys.argv[2]) translated = '' for i in plain: if i.isalpha(): num = ord(i) num += key if i.isupper(): if num > ord('Z'): num -= 26 elif num < ord('A'): ...
false
78c81da0381174869334638036a3d11d5bb493a0
suntyneu/test
/test/类Class/6、析构函数.py
915
4.15625
4
""" 析构函数:__del__(): 释放对象时候自动调用 """ class Person(object): def run(self): print("run") def eat(self, food): print("eat" + food) def say(self): print("Hello!my name is %s,I am %d years old" % (self.name, self.age)) def __init__(self, name, age, height, weight): # 可以有其他的参数列表 ...
false
065abbd254823c5bd5cfdcc7a14a5b66b36441fa
suntyneu/test
/for语句.py
733
4.1875
4
""" for 语句 格式: for 变量名 in 集合: 语句 逻辑:按顺序取 "集合" 中的每个元素,赋值给 "变量" 在执行语句。如此循环往复,直到取完“集合”中的元素截止。 range([start,]end[,step]) 函数 列表生成器 start 默认为0 step 步长默认为1 功能:生成数列 for i in [1, 2, 3, 4, 5]: print(i) """ a = range(12) print(a) for x in range(12): print(x) for y in range(2, 20, 2): pr...
false
634ec7c51e7db7cdc6a46c67478617c4f8d1748c
suntyneu/test
/面向对象/练习.py
916
4.1875
4
""" 公路(Road): 属性:公路名称,公路长度 车 (car): 属性:车名,时速 方法:1.求车名在那条公路上以多少时速行驶了都吃, get_time(self,road) 2.初始化车属性信息__init__方法 3、打印显示车属性信息 """ class Road(object): def __init__(self, road_name, road_len): self.road_name = road_name self.road_len = road_len print(self.ro...
false
f93465e46e7201df11fcd754cf9bcffeb9fe17f1
suntyneu/test
/函数/装饰器.py
2,659
4.15625
4
""" 装饰器 概念:一个闭包,把一个函数当成参数,返回一个替代版的函数。 本质上就是一个返回函数的函数 """ def func1(): print("sunck is a good man") def outer(func): def inner(): print("*******************") func() return inner # f 是函数func1的加强版本 f = outer(func1) f() """ 那么,函数装饰器的工作原理是怎样的呢?假设用 funA() 函数装饰器去装饰 fu...
false
77091f08b893364629e2d7170dbf1aeffe5fab5a
Gangamagadum98/Python-Programs
/sample/Calculator.py
451
4.15625
4
print("Enter the 1st number") num1=int(input()) print("Enter the 2nd number") num2=int(input()) print("Enter the Operation") operation=input() if operation=="+": print("the addition of two numbers is",num1+num2) elif operation == "-": print("the addition of two numbers is", num1 - num2) ...
true
6f4786334da4a577e81d74ef1c58e7c0691b82b9
Obadha/andela-bootcamp
/control_structures.py
354
4.1875
4
# if False: # print "it's true" # else: # print "it's false" # if 2>6: # print "You're awesome" # elif 4<6: # print "Yes sir!" # else: # print "Okay Maybe Not" # for i in xrange (10): # if i % 2: # print i, # find out if divisible by 3 and 5 # counter = 0 # while counter < 5: # print "its true" # print c...
true
eb65ff92ef8086781e3657ca6f543dc2edadc228
ArielAyala/python-conceptos-basicos-y-avanzados
/Unidad 4/Listas.py
737
4.21875
4
numeros = [1, 2, 3, 4, 5] datos = [5, "cadena", 5.5, "texto"] print("Numeros", numeros) print("Datos", datos) # Mostramos datos de la lista por índice print("Mostramos datos de la lista por índice :", datos[-1]) # Mostramos datos por Slicing print("Mostramos datos por Slicing :", datos[0:2]) # Suma de Listas listas...
false
e129e980c58a0c812c96d4d862404361765cbaa6
rafiqulislam21/python_codes
/serieWithValue.py
660
4.1875
4
n = int(input("Enter the last number : ")) sumVal = 0 #avoid builtin names, here sum is a built in name in python for x in range(1, n+1, 1): # here for x in range(1 = start value, n = end value, 1 = increasing value) if x != n: print(str(x)+" + ", end =" ") #this line will show 1+2+3+............ #...
true
407ae0b9bd3004e0655b747f9f5ffda563ae8cae
anooptrivedi/workshops-python-level2
/list2.py
338
4.21875
4
# Slicing in List - more examples example = [0,1,2,3,4,5,6,7,8,9] print(example[:]) print(example[0:10:2]) print(example[1:10:2]) print(example[10:0:-1]) #counting from right to left print(example[10:0:-2]) #counting from right to left print(example[::-3]) #counting from right to left print(example[:5:-1]) #counting ...
true
ca7c8607e41db501f958a746028fb28040133d54
anooptrivedi/workshops-python-level2
/guessgame.py
460
4.125
4
# Number guessing game import random secret = random.randint(1,10) guess = 0 attempts = 0 while secret != guess: guess = int(input("Guess a number between 1 and 10: ")) attempts = attempts + 1; if (guess == secret): print("You found the secret number", secret, "in", attempts, "attempts") ...
true
8f8e8651d25ac8333692a5aa18bc26589f3fefe4
swaraj1999/python
/chap 8 set/set_intro.py
1,092
4.1875
4
# set data type # unordered collection of unique items s={1,2,3,2,'swaraj'} print(s) # we cant do indexing here like:: s[1]>>wrong here,UNORDERED L={1,2,4,4,8,7,0,9,8,8,0,9,7} s2=set(L) # removes duplicate,unique items only print(s2) s3=list(set(L)) print(s3) ...
true
15c3309d2d94b809fccc1c1aaaa0cd66cdfd3954
swaraj1999/python
/chap 4 function/exercise11.py
317
4.375
4
# pallindrome function like madam, def is_pallindrome(name): return name == name[::-1] #if name == reverse of name # then true,otherwise false # print(is_pallindrome(input("enter name"))) #not working for all words print(is_pallindrome("horse")) #working for all words
true
6d08454da7f8c3b15ec404505a6b77b9192e570e
breschdleng/Pracs
/fair_unfair_coin.py
1,307
4.28125
4
import random """ Given an unfair coin, where probability of HEADS coming up is P and TAILS is (1-P), implement a fair coin from the given unfair coin Approach: assume an unfair coin that gives HEADS with prob 0.3 and TAILS with 0.7. The objective is to convert this to a fair set of probabilities of 0.5 each Solution...
true
5b6fc5dbfa1e7d85d4c80642ecb2822c23d5a6be
ShainaJordan/thinkful_lessons
/fibo.py
282
4.15625
4
#Define the function for the Fibonacci algorithm def F(n): if n < 2: return n else: print "the function is iterating through the %d function" %(n) return (F(n-2) + F(n-1)) n = 8 print "The %d number in the Fibonacci sequence is: %d" %(n, F(n))
true
556ba64f9a8ac34fae4876547d44e2d990582742
DL-py/python-notebook
/001基础部分/015函数.py
1,548
4.34375
4
""" 函数: """ """ 函数定义: def 函数名(参数): 代码 """ """ 函数的说明文档: 1.定义函数说明文档的语法: def 函数名(参数): """ """内部写函数信息 代码 2.查看函数的说明文档方法: help(函数名) """ # 函数说明文档的高级使用: def sum_num3(a, b): """ 求和函数sum_num3 :param a:参数1 :param b:函数2 :return:返回值 """ return a + b """ 返回值:可以返回多个值(默认是元组),也可以返回列表、字典、集合等 """...
false
8d852b9ba3fb4403dc783cc6c703c451ee0197f7
Pranav-Tumminkatti/Python-Turtle-Graphics
/Turtle Graphics Tutorial.py
979
4.40625
4
#Turtle Graphics in Pygame #Reference: https://docs.python.org/2/library/turtle.html #Reference: https://michael0x2a.com/blog/turtle-examples #Very Important Reference: https://realpython.com/beginners-guide-python-turtle/ import turtle tim = turtle.Turtle() #set item type tim.color('red') #set colour tim.pensize(5...
true
b68c9db55ce6af793f0fc36505e12e741c497c31
sAnjali12/BsicasPythonProgrammas
/python/userInput_PrimeNum.py
339
4.1875
4
start_num = int(input("enter your start number")) end_num = int(input("enter your end number")) while (start_num<=end_num): count = 0 i = 2 while (i<=start_num/2): if (start_num): print "number is not prime" count = count+1 break i = i+1 if (count==0 and start_num!=1): print "prime number" start_...
true
3750e8f1fc7137dddda348c755655db99026922b
xilaluna/web1.1-homework-1-req-res-flask
/app.py
1,335
4.21875
4
# TODO: Follow the assignment instructions to complete the required routes! # (And make sure to delete this TODO message when you're done!) from flask import Flask app = Flask(__name__) @app.route('/') def home(): """Shows a greeting to the user.""" return f'Are you there, world? It\'s me, Ducky!' @app.r...
true
d4509f58c0d0721b86336e567946646df9431717
770847573/Python_learn
/Hello/错误和异常/抛出异常raise.py
391
4.15625
4
# 产生异常的形式 # 形式一:根据具体问题产生异常【异常对象】 try: list1 = [12, 3, 43, 34] print(list1[23]) except IndexError as e: print(e) #形式2:直接通过异常类创建异常对象, # raise异常类(异常描述)表示在程序中跑出一个异常对象 try: raise IndexError("下标越界~~~") except IndexError as e: print(e)
false
7bbf2b2e59d035278ed1512201e70391af6c2e8a
770847573/Python_learn
/day19/4.多态的应用.py
1,664
4.4375
4
# 1.多态的概念 # a. class Animal(object): pass class Cat(Animal): pass # 在继承的前提下,一个子类对象的类型可以是当前类,也可以是父类,也可以是祖先类 c = Cat() # isinstance(对象,类型)判断对象是否是指定的类型 print(isinstance(c,object)) # True print(isinstance(c,Animal)) # True print(isinstance(c,Cat)) # True a = Animal() print(isinstance(a,Cat)) # False # b. ...
false