blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
85caf17aad54055d0ace73bc1f70447ba870fed1
ibm-5150/Python-HW
/HW-2/task_1.py
529
4.28125
4
a = int(input("Insert a: ")) b = int(input("Insert b: ")) a_positive = bool(a > 0) print("Number a is positive: " + str(a_positive)) a_pair = bool(a % 2 == 0) print("Number a is pair: " + str(a_pair)) a_multiple = bool(a % 13 == 0) print("Number a is multiple of 13: " + str(a_multiple)) a_b_pair = bool(...
false
bbc4aaf7932b8895de06fdf899830298f7e5448c
shashank2123/Regular_Expression-_python
/phone_number_matching_using_re.py
418
4.46875
4
#import regular expression mofule import re pattern='\d\d\d-\d\d\d-\d\d\d\d' #if you want to give the different pattern uncomment below statement #pattern=input('Enter the pattern :') #give the text in which you have to extract the phone number message=input("drop ur message :") phone_re=re.findall(p...
true
46376844a9896a533dac9f8ae2dee23714736ff1
Fabrizio99/Learning-Python
/Tipos de Datos.py
699
4.21875
4
# se hacen comentarios con # #imprimir mensaje print("do not give up") # tipos de numeros # enteros x=3 print(type(x)) # flotantes x=3.23 print(type(x)) y=23e3 print(y) y=12E2 print(y) z = -87.7e-3 print(z) #complejos #se escribe "j" como la parte imaginaria x=3+5j print(x) print(type(x)) # CASTEO #int() # Construye...
false
dee1afdec993b3af139fa6d4704a615a66297ab7
mohd-tanveer/PythonAdvance
/lecture22Assertion.py
987
4.375
4
#lecture22 #Assertions: '''-------------------------- assertion is use for DeBugging Purpose as an alternative of Print statements, if we are using print statement that should be remove after fixing the problem how ver aseert is not need to be executed based on choice we can enabled or disable the assertion state...
true
127ea617de37032cdd252d0759d5c45ebe480f0f
jessica-younker/Python-Exercises
/exercises/tuples/zoo.py
1,008
4.6875
5
# Create a tuple named zoo that contains your favorite animals. # Find one of your animals using the .index(value) method on the tuple. # Determine if an animal is in your tuple by using for value in tuple. # Create a variable for each of the animals in your tuple with this cool feature of Python. # # example # (li...
true
5893204d4d87c6cea3769ad555a678e2fb988213
eduhmc/CS61A
/Teoria/Class Code/Lecture 2.py
1,252
4.4375
4
# python DEMO1: "Names, Assignment, and User-Defined Functions" pi from math import pi pi * 71 / 223 from math import sin sin sin(pi/2) # Assignment radius = 10 radius 2 * radius area, circ = pi * radius * radius, 2 * pi * radius area circ radius = 20 # Function values max max(3, 4) f = max f max f(3, 4) max = 7 f(3,...
true
677c7c2fdfeec2f5a49312b26561c267b63e009e
boconlonton/python-deep-dive
/part-2/2-iterators/2-iterator.py
1,656
4.40625
4
""" An object is called Iterator if it implement the following methods: - __iter__(): return the object itself - __next__(): return the next item or raise StopIteration Issues: - Exhaustion problems! """ class Squares: def __init__(self, length): self.length = length self.i = 0 d...
true
6081cf27b2906e07a0d05e0476a386e53d783112
boconlonton/python-deep-dive
/part-2/4-iteration-tools/5-chaining_teeing.py
1,789
4.15625
4
"""Chaining & Teeing""" from itertools import chain, tee # Chaining l1 = (i**2 for i in range(4)) l2 = (i**2 for i in range(4, 8)) l3 = (i**2 for i in range(8, 12)) # for gen in l1, l2, l3: # for item in gen: # print(item) def chain_iterables(*iterables): """Demonstrate how itertools.chain() works""...
false
16dcb28955930caff5c78e1ac0b847619574e83a
boconlonton/python-deep-dive
/part-2/3-generators/3-making_an_iterable_from_generator.py
476
4.15625
4
"""Making an Iterable from a Generator""" class Squares: """An iterable that return square result""" def __init__(self, n): self._n = n def __iter__(self): """Iterable Protocol""" return Squares.squares_gen(self._n) @staticmethod def squares_gen(n): """A generato...
true
26d2b4cc58759cad51ee66c9475dca0179fdfa48
zhuyuedlut/advanced_programming
/chapter8/define_format.py
990
4.125
4
format_dict = { 'ymd': '{d.year}-{d.month}-{d.day}', 'mdy': '{d.month}/{d.day}/{d.year}', 'dmy': '{d.day}/{d.month}/{d.year}' } class Date: def __init__(self, year, month, day): self.year = year self.month = month self.day = day def __format__(self, format_type='ymd'): ...
false
b21a9b070f78dd7d934e65cd3bfe17b87e863078
khalid-joomun/GuessTheNumber-game
/NumberGuessing/NumberGuessing.py
980
4.34375
4
# Number guessing game a.k.a HiLo # The player enters a number. The program says whether the number to be guessed # is higher or lower than the user's guess. # This continues until the player guesses the right number import random number = random.randint(-100, 100) attempt = 1 guess = 101 while (guess != number): ...
true
49cb24a5d6d8e5ea0741bc387e22f28a5e7917b3
dmccuk/python
/lists.py
2,170
4.15625
4
my_list1 = [1,2,3,4] print(my_list1) print(type(my_list1)) list1 = ["Dennis",3.4,5.6,"Lists are Flexible",14] print(list1) list2 = [1,2,3,4,5,6,7,8,9,0,0,0,5] print(len(list2)) my_list3 = list("Hello World!") print(my_list3) my_list = [1,2,3,4,5,"a","b",3.14] print(my_list) print(my_list[0]) print(my_list[2]) pri...
true
39d8c938441d8babf1617b426d4517b7f7207d0d
ruzguz/python-stuff
/comprehension/remove_vowels.py
201
4.15625
4
VOWELS = 'AaEeIiOoUu' def remove_vowels(str): return ''.join([c for c in str if c not in VOWELS]) if __name__ == '__main__': str = input('Type something: ') print(remove_vowels(str))
false
8b62302ed392858b97950faee80d4894a4402cf0
ruzguz/python-stuff
/17-modules/operations.py
1,183
4.125
4
import mathf def print_menu(): print('1 - sum') print('2 - subtraction') print('3 - multiplication') print('4 - square number') print('5 - division') if __name__ == '__main__': while True: print('Welcome to the calculator:') print_menu() option = input('Select ...
false
1716b42edbcbd4eabb3111947f27abd9a9d632a3
ruzguz/python-stuff
/4-functions/test.py
537
4.21875
4
# -*- coding:utf8 -*- import turtle # Is called when the program start def main(): window = turtle.Screen() dave = turtle.Turtle() # draw square draw_square(dave) turtle.mainloop() # Fundtion to draw a square def draw_square(t): lenght = int(input('square size: ')) for i in r...
true
09a889f867f388761c051331a443e5dbd97460e2
brisa123/python_practice_programs
/fizzbuzz.py
341
4.1875
4
import os #if number divisible by 3, print fizz, if divisible by 5, print buzz, if divisible by both, print fizzbuzz,else print num for num in range(1,100): if (num%3==0 and num%5==0): print("fizzbuzz") elif(num%3==0): print("fizz") elif(num%5==0): print("buzz") else...
true
57a086a2350cddbf305407d94b21a0e1f6ddb91b
kranthikiranm67/Second_Assignment
/02_flip_123.py
1,164
4.3125
4
""" You are given an integer n consisting of digits 1, 2 and 3 and you can flip one digit to a 3. Return the maximum number you can make. Example 1 Input n = 123 Output 323 Explanation We flip 1 to 3 Example 2 Input n = 333 Output 333 Explanation Flipping doesn't help. """ import unittest # Implement the belo...
true
b49a990f2050f7e369c9adece857d7da2682e66c
raysomnath/Python-Basics
/Class__str__repr__init__private_protected_public/public_protected_private_attributes.py
2,516
4.3125
4
# There are two ways to restrict the access to class attributes: # First, we can prefix an attribute name with a leading underscore "_". # This marks the attribute as protected. It tells users of the class not to use this attribute unless, somebody writes a subclass # Second, we can prefix an attribute name with two le...
true
44c75ce287e91308b7d15f743aef0b9fc7c7d919
raysomnath/Python-Basics
/Class__str__repr__init__private_protected_public/the__init__method.py
850
4.5
4
# __init__ is a method which is immediately and automatically called after an instance has been created. # This name is fixed and it is not possible to chose another name. The __init__ method is used to initialize an instance. # The __init__ method can be anywhere in a class definition, but it is usually the first me...
true
e30f732155cf705bfe538ee1df522859661b66b7
raysomnath/Python-Basics
/Arithmetic_Operators.py
1,197
4.3125
4
import sys numbers = 1+2*3 / 4.0 print (numbers) remainder = 11 % 3 print(remainder) # using two multiplication symbol makes a power relationship squared = 7 ** 2 cubed = 2 ** 3 print(squared) print(cubed) #python supports string concatenation helloworld = "hello" + " " + "world" print(helloworld) #Python also s...
true
174b65aa091f61e733f5c5fae74f111184a3146a
raysomnath/Python-Basics
/args_kwargs/args_kwargs.py
1,004
4.46875
4
import sys # *args and **kwargs are mostly used in function definitions. # *args and **kwargs allow you to pass a variable number of arguments to a function. # What variable means here is that you do not know beforehand how many arguments # can be passed to your function by the user so in this case you use these tw...
true
4ba77af2125a0d44ee0ce4ac29b67afa8e89bc63
raysomnath/Python-Basics
/Decorator/ReturningFunctoinsFromFunctions.py
777
4.375
4
import sys # Python also allows you to use functions as return values.\ # The following example returns one of the inner functions from the outer parent() function: def parent(num): def first_child(): return "Hi I am Emma" def second_child(): return "Call me Liam" if num == 1: ...
true
916f03b0f1df29e5381bd2f2929d3bacf88bcb84
brandon-todd/alien_invasion_game
/Downloads/project2/project2/main.py
1,904
4.25
4
""" This takes temperature of cities in 5 different days and cost of five hotels to find the highest average temperature of a trip to each city in the dictionary and plans hotels to stay at along the way to maximize your budget in this example of $850. """ from itertools import permutations, combinations_with_replacem...
true
f3272bc5d1cad2c5efd9184c2db469821e5fb671
mohak007/adrian-github-list_and_strings
/program 11.py
279
4.25
4
#Write a function that merges two sorted lists into a new sorted list. [1,4,6],[2,3,5] → [1,2,3,4,5,6]. You can do this quicker than concatenating them followed by a sort. lista=[1,4,6] listb=[2,3,5] lista.sort() listb.sort() listc=lista +listb listc.sort() print(listc)
true
4bf3b3e5b97721fb459c6a799d1ff52be24e89e6
sanchezpe/pythonproject3
/pa3.py
1,276
4.15625
4
#ask user 1 for information name1=input("Enter name of customer #1: ") gallons1=eval(input("Enter gallons for customer #1: ")) question1=input("Is customer #1 residential or commercial? ") print("------------------------------------------------------") #aks user 2 for information name2=input("Enter name of c...
true
361253b2f7a7378f3287399f1d3e6d20d06aa725
dchasepdx/rpg-dice-roller
/rollerFinal.py
1,256
4.1875
4
from random import randint count = 1 #initialize a count. start at 1 for more intuitive print results #get input for number of dice and sides userRoll = input("Enter number and sides of dice like so: xdy. x is number of dice and y is number of sides: ") dice_total = 0 #initilaze dice_total #turn input into a l...
true
a960307e51a41398e3092dfba2550339e7cdb2ef
Aitd1/learnPython
/实现各种常用算法/栈/stackTest.py
2,033
4.25
4
class Stack(object): def __init__(self, limit=10): self.stack = [] # 存放元素 self.limit = limit # 栈容量极限 def push(self, data): ''' 思路: 理解:压入push:即将新的元素放在栈顶 步骤: 1.检查栈是否溢出。溢出并抛出异常。 2.然后添加新元素。 ''' # 判断栈是否溢出 ...
false
76987196ee98cd77e1f0142547fac3de5c50c885
cglsoft/DataScience-FDSI
/Semana 1/Aula5/cast_list.py
1,057
4.21875
4
# Quiz: Lista do elenco de Flying Circus # Você criará uma lista dos atores que apareceram no programa de televisão Monty Python's Flying Circus. # Escreva uma função chamada create_cast_list, que recebe um nome de arquivo como entrada e retorna uma # lista de nomes de atores. # Ela será executada no arquivo flying_c...
false
9b66b129cefbe2f3dc32f33cf523504fc362e678
daygregory/PFAB_3_2014
/list.py
410
4.125
4
list1 = ['English' , 'Spanish' , 'Math' , 'Biology' , 'Computer Science' , 'Gym' , 'Music' , 'Theater'] gpas = [ 3.12 , 4.0, 2.57, 3.33, 3.01, 2.22, 1.98] #print first member of the list list1 print list1[0] print list1[3] print gpas[2] print (gpas[0] + gpas[1])/2 #Number inside the [x] is known as the index print ...
true
770b0cf4eb77bf4f7985e94a0fe100cec45dd7db
Ash0492/Python
/practice8.py
1,771
4.375
4
import random #The Game of Rock, Paper and Scissors #Rules of the game print('Winning rules of the game are as follows:\n'+ 'Rock VS Paper => Paper wins\n' +'Rock VS Scissor => Rock Wins\n' +'Paper VS Scissor => Scissor wins') while True: print("Please enter one the below choices:\n"+ "1. Rock\n"+...
true
241690cbb760e66d91eee3d5aeb6ebcd0d0d82f8
mcorley1/Intro_Biocom_ND_319_Tutorial5
/Exercise_5_Challenge_Complete.py
1,667
4.1875
4
#Completing Part 1 import pandas #loading the pandas package to use data frames data = pandas.read_csv("wages.csv", header=0,sep=",") #loads the file gender_yrsexp = data.iloc[:,0:2] #subsets data by selecting the first two columns uniquegender = gender_yrsexp.drop_duplicates() #drops duplicates, like the ...
true
413a12a90d2a8675efdc6d0e5a45f8d076a4cc36
shanthanaroja/guessing_number
/number_guessing.py
451
4.25
4
import random number=random.randint(1,9) chance=0 while chance<=5: guess=int(input("Enter a number:")) if guess<number: print("Your guess is too low guess a number greater than",guess) elif guess>number: print("Your guess is too high guess a number less than",guess) else: print("...
true
51e5618900a8414c4cfb43eb8147c21e03db090f
markodevcic/codingbats-python
/string-1/extra_end.py
338
4.3125
4
# Given a string, return a new string # made of 3 copies of the last 2 chars # of the original string. The string # length will be at least 2. # # # extra_end('Hello') → 'lololo' # extra_end('ab') → 'ababab' # extra_end('Hi') → 'HiHiHi' def extra_end(str): if len(str) >= 2: return str[-2:] * 3 print(extr...
true
f92443dc59f296ed7f7380219b306eba3faf25a6
gaoxy123/Python001-class01
/week07/my_zoo.py
2,994
4.21875
4
''' 背景:在使用 Python 进行《我是动物饲养员》这个游戏的开发过程中,有一个代码片段要求定义动物园、动物、猫三个类。 这个类可以使用如下形式为动物园增加一只猫: 复制代码 if __name__ == '__main__': # 实例化动物园 z = Zoo('时间动物园') # 实例化一只猫,属性包括名字、类型、体型、性格 cat1 = Cat('大花猫 1', '食肉', '小', '温顺') # 增加一只猫到动物园 z.add_animal(cat1) # 动物园是否有猫这种动物 have_cat = getattr(z, 'Cat') 具体要求:...
false
4ee55da716a17407829b8e26482a779216789164
mdtitong/ITS320
/ITS320_CTA1_Option2.py
449
4.375
4
# Read two integers and print two lines. The first line should contain integer division, //, the second line # should contain float division, /, and the third line should contain modulo division, %. You do not need to # perform any rounding or formatting operations. num1 = int(input("First number: ")) num2 = int(input(...
true
8653611091f2f42ab7d3e5de445f04cd89532e57
abir-hasan/PythonGround
/scratch_files/scratch_section_2.py
1,351
4.15625
4
############### Section 2 Language Overview ################ # Example of import import platform version = platform.python_version() print('this is python version: {}'.format(version)) # Example with pre-formatted and format function name = "Abir" # pre-formatted f print(f"Hello worlds {name}") # with format functio...
true
a9377c53898eeaa064f6c0a0bbac1cce184a8462
abir-hasan/PythonGround
/course_python_essentials/Chap02/primes.py
441
4.15625
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ def isprime(n): if n <= 1: return False for x in range(2, n): if n % x == 0: return False else: return True # n = 5 # if isprime(n): # print(f'{n} is prime') # else: # print(f'{n} not prime') def ...
false
f09c256c36edcf414cc47fcddf8bed8e1d903f62
Smisosenkosi/mypackage
/mypackage-master/test/sorting.py
1,068
4.3125
4
def bubble_sort(items): '''Return array of items, sorted in ascending order''' for num in range(len(items)-1,0,-1): for i in range(num): if items[i]>items[i+1]: temp = items[i] items[i] = items[i+1] items[i+1] = temp ...
true
8c7dde5fa2a03661a3bcaae698f85ca9459dc325
felgun/BioinformaticsAlgorithms
/CountingDnaNucleotides.py
2,097
4.625
5
""" CountingDnaNucleotides.py """ import argparse import os.path def count_dna_nucleotides(sequence): """ Counts each nucleotide in the DNA sequence and prints them in the following order: A,C,G,T. Returns a dictionary with nucleotide as key and its count as value. Param: sequence {str} : The DNA sequence of ...
true
6fe338ba5908d977c7c2e263eeabc3ac9e2accd7
Qliangw/python_notes
/basic/ba_04_traverse_list.py
1,380
4.34375
4
from src import print_split_line # for循环的使用 magicians = ['alice', 'david', 'carolina'] print("使用for打印出数组元素:") for magician in magicians: print(magician) print_split_line.print_split_line('*', 20) for magician in magicians: print(magician.title() + ", that was a great trick!") print("I can`t wait to see you...
true
c9cb804afab2297f832d0adc83bd2ef19ab1ecd2
darkalejo14/Lab_8_Funciones
/punto5.py
740
4.15625
4
#Solicitar al usuario un número entero y luego un dígito. # Informar la cantidad de ocurrencias del dígito en el número, # utiliza para ello una función que calcule la frecuencia del dígito en el número ingresado. cond="si" def frecuencia(numero,digito): cantidad=0 while numero!=0: ultDigito=numero%10 ...
false
83ca048aef33eb2b726d35b24a6ecef3fa6047dd
AnfisaAnisimova/Geekbrains_student
/Введение в Python/Dz_11/Task_11_7.py
1,110
4.3125
4
""" Реализовать проект «Операции с комплексными числами». Создать класс «Комплексное число». Реализовать перегрузку методов сложения и умножения комплексных чисел. Проверить работу проекта. Для этого создать экземпляры класса (комплексные числа), выполнить сложение и умножение созданных экземпляров. Проверить корректно...
false
3165145b0c893d632c0c22163e0c36f05f52862d
PaulBStephens/python-challenge
/PyBank/.ipynb_checkpoints/main-checkpoint.py
2,325
4.21875
4
# Create dependencies import csv # file to load file_to_load = "budget_data.csv" # Read the csv and convert info into lists; the first and second columns are data given, the third to store data calculated from the second column with open(file_to_load) as revenue_data: reader = csv.reader(revenue_data) ...
true
04aa146e5dc7454a0176eb855472d19f97065021
RashikWasik/PythonDataStructures
/Python Data Structures/Week 3/Assignment 7.2.py
1,000
4.25
4
# 7.2 Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: # X-DSPAM-Confidence: 0.8475 # Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output # as shown b...
true
e1e450bf4bff900d9e12a290706f5308c8fb97cf
sargey18/rock-paper-sicssors
/main.py
921
4.3125
4
import random # 1) we need the random # 2) we will also need a function called play def play(): # 3) we will also need a variable to stor one of three inputs from the user user = input("What is your choice 'r' for rock, 'p' for paper, 's' for scissor\n") # 4) the computer also needs to choose , vatiable...
true
9d14085766c3a5a7a8099377970e8b843be8f665
tabo2659-cmis/Tabo2659-cmis-cs2
/cs2quiz3.py
1,698
4.46875
4
#Section 1: Terminology # 1) What is a recursive function? #A recursive function is a function that calls itself until it meets the requirments of the base case where it stops. #point # # 2) What happens if there is no base case defined in a recursive function? #It will recurse infinitly or about a 1000 times dependin...
true
cd0bfde949db56dc45822cfe6e06c57d3ce75bf5
mbutkevicius/100_Days_Of_Code
/day_2.py
2,196
4.1875
4
# Data Types # String print("Hello"[4]) print("123" + "345") # Integer print(123 + 345) # 123_456_789 # _ works as , # Float # 3.14159 # Boolean # True # False # num_char = str(len(input("What is your name?\n"))) # print("Your name has " + num_char + " characters.") a = str(123) print(type(a)) # 🚨 Don...
true
0c4b07f056aa9b12db0af708de3d397e4f0bcf73
mbutkevicius/100_Days_Of_Code
/day_10.py
2,194
4.1875
4
# def my_function(): # return 3 * 2 # # # output = my_function() # print(output) def format_name(f_name, l_name): """Take first and lsat name and format it to return the title case version of the name.""" if f_name == "" or l_name == "": return "You didn't provide valid inputs." formatted...
true
45b9a99f04ea8582a564a791458c66e8a67ff224
alexDavis28/udemy_python
/Python/5_36_usefull_operators_and_functions.py
1,750
4.625
5
#these didn't really fit into any other lecture, so are here #range function mylist = [1,2,3] for num in range(10): print(num) #prints every number from 0 to 10 for num in range(3,10): print(num) #prints every number from 0 to 9, not including 10 for num in range(0,10,2): print(num) #prints every number from 0...
true
c0da33ed657b52e4c56a4a20767f547efc1ae4b5
SaeedTaghavi/numerical-analysis
/python/02-interpolation/01-newton-forward/forward.py
1,185
4.25
4
# Python3 Program to interpolate using # newton forward interpolation # calculating u mentioned in the formula def u_cal(u, n): temp = u; for i in range(1, n): temp = temp * (u - i); return temp; # calculating factorial of given number n def fact(n): f = 1; for i in range(2, n + 1): f *= i; re...
true
30057b12944c5f5fe44228f8f24c47740bbe9d3d
andre23arruda/pythonCeV
/Aula7.py
2,183
4.15625
4
# =============== DESAFIO 5 ===================== # numero = int(input('Digite um numero: ')) ant_num = numero - 1 sus_num = numero + 1; print('O numero {} possui antecessor = {} e sucessor = {} '.format(numero,ant_num,sus_num)) # ============= DESAFIO 6 =================# numero2 = int(input('Digite um numero: ')) do...
false
1297cab42fa902af1f9be79bb25cf2f9f58aa037
merlose/Python-Calculator
/Basic_Calculator_v2.py
743
4.21875
4
while True: num1 = float(input("Input 1st number then hit ENTER: ")) mathType = ["Select function:","(add) +","(subtract) -","(multiply) *","(divide) /"] for type in mathType: print (type) mathFunction = input("then hit ENTER: ") num2 = float(input("Input 2nd number then hit ENT...
false
7c523ddce108b50a341473deaad70cef3076cef2
Lischero/Atcoder
/ARC044/q1.py
620
4.25
4
# -*- coding:utf-8 -*- import math def isPrime(num): if num == 2: return True if num < 2 or num%2 == 0: return False for tmp in range(3, math.floor(math.sqrt(num))+1, 2): if num%tmp == 0: return False return True def isPrime2(num): factor = list(map(int, list(str...
false
058d97564362edcd5c9c2c92cab229b617e6ee2d
sandeep9889/paint-app-using-python-turtle
/python_tutorial/if_else.py
294
4.25
4
#short hand if else a = int(input("enter a\n")) b = int(input("enter b\n")) print("a b se bda h") if(a>b) else print("b a se bda h bhai") #here it is called short handed because it is in one line code #we can write here firstly print statement and then we have to write conditional if statement
false
a5ea38f82eb0747c37cc0738c17817b4e6498e50
chawlaj100/pythoniffie
/prime_number_checker.py
398
4.15625
4
prime = int(input("What number do you wanna check?")) if prime > 1 : for i in range(2,prime): if (prime % i) == 0: print("Your number is not a prime number") print("Because "+str(prime)+" divided by "+str(i)+" is 0.") break else: print(prime,"is a pr...
true
aedb45d82ba6a352cc4898605794452debbd3d6c
asergeev79/GeekBrains
/python/lesson_3/03-01.py
1,214
4.21875
4
# Реализовать функцию, принимающую два числа (позиционные аргументы) и выполняющую их деление. # Числа запрашивать у пользователя, предусмотреть обработку ситуации деления на ноль. # def input_numbers(): """ Функция запроса данных от пользователя. :return: Вывод в виде кортежа 2-х действительных чисел...
false
db30b9cfd9b06bc9ed09689fc0644af96869146b
asergeev79/GeekBrains
/python/lesson_6/06-02.py
1,195
4.28125
4
# 2 """ Реализовать класс Road (дорога), в котором определить атрибуты: length (длина), width (ширина). Значения данных атрибутов должны передаваться при создании экземпляра класса. Атрибуты сделать защищенными. Определить метод расчета массы асфальта, необходимого для покрытия всего дорожного полотна. Использовать фор...
false
a3a1b1797558c68a7d46eee8f1132f53d1d04b98
Ameya-k1709/Object-Oriented-Programming-in-Python
/class.py
1,410
4.4375
4
# creating a class named programmers class Employee: company = 'Microsoft' # the company attribute is a class attirbute because every programmers is from microsoft number_of_employees = 0 def __init__(self, name, age, salary, job_role): # This is a constructor self.name = name ...
true
3834284ded0d2d975396b73b06440baf6d0d84b2
Roopa-palani-samy/DG-Python-Assignment
/Squarethevalue.py
397
4.25
4
# 8. Write a program which can map() to make a list whose elements are square of numbers # between 1 and 20 (both included). # using map def squared(n): return n * n numbers = (1, 2, 3, 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) result = map(squared, numbers) print(list(result)) # using lambd...
true
ab24679f7aa1e2a2e5e9d3417b3487230bfed20d
skoricky/algo
/hw02_2.py
823
4.1875
4
# 2. Посчитать четные и нечетные цифры введенного натурального числа. Например, если введено число 34560, # то у него 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5). print('Введите натуральное число:') num = input('Число = ') def sum_even_digits(num_string, ev_sum=0, od_sum=0, inx=0): if inx == len(num_s...
false
61377a9f9ace141983b2bb6bda6b48cff0661850
jaycoskey/IntroToPythonCourse
/PythonSrc/Unit1_HW_src/LoopExamples/1_capitalize.py
536
4.4375
4
#!/usr/bin/env python3 def print_with_capitalized_a(word): for letter in word: if letter == 'a': print(letter.upper(), end='') else: print(letter, end='') def print_with_capitalized_ends(word): for i in range(0, len(word)): letter = word[i] ...
false
9f2d4cc94b21fc2015b6be1243ed12048aab7ed5
hdgmemory/Data-structures-and-algorithms
/二叉树/二叉树反转.py
628
4.15625
4
#也叫二叉树的镜像 #递归实现 class Node(): def __init__(self, value=None, left=None, right=None): self.value = value self.left = left # 左子树 self.right = right # 右子树 def invertTree(root): if root == None: return None temp = root.left root.left = root.right r...
false
501a44392286a927a832ff513e8620de6c288c34
Sushil-Deore/Python-Challenges
/alphabetic_patterns.py
1,622
4.28125
4
""" Alphabetic patterns Description Given a positive integer 'n' less than or equal to 26, you are required to print the below pattern Sample Input: 5 Sample Output : --------e-------- ------e-d-e------ ----e-d-c-d-e---- --e-d-c-b-c-d-e-- e-d-c-b-a-b-c-d-e --e-d-c-b-c-d-e-- ----e-d-c-d-e---...
false
e09901378bbb935d2c4e12fd165334748f17f4ff
tungsys/FPU
/test_bench/num_gen/IEEE_number_gen.py
1,762
4.25
4
from sys import argv import struct import random def main(): """ This program takes two inputs, an op code and a number. OP Codes 1 - Convert number to IEEE 2 - Generate n random IEEE numbers and display them next to their decimal counterpart 3 - Generates and converts n random numbers and sav...
true
e7c92f95a044463f912fdc0879eb2c6fa7468dc1
shakerabady/Python-Exericises
/temp.py
1,161
4.1875
4
print ('{:5} {:10} {:15}' .format("hello\n","hello\n","hello\n")) print("orange\n"*20) x=float(1) y=float(2.8) z=float("3") w=float("4.2") print(x,y,z,w,sep='10') x=1 y=2.8 z=1j o="orange" A=True print(type(x)) print(type(y)) print(type(z)) print(type(o)) print(type(A)) x,y="Orange",1 X1,Y1=100,-10 print(x) print(...
false
22267ec505fe058a72993238db854bf2f149ed10
SteveEs25/SistemasExpertos_EjerciciosSA-B
/Calculadora/Index.py
1,276
4.1875
4
#Importamos la clase Calcu from Calculadora import Calcu #La variable recoge los datos de la clase Calcu calcu = Calcu() def Menu(): print(" ") print(" ") print("--CALCULADORA--") print(" ") print("Seleccione una opción") print("1 - Suma") print("2 - Resta") print("3 - Multiplicación") print...
false
16bbee2868d8d28bb4757ad8676ae08677d671e3
shailymishra/EulerProject
/euler4.py
1,469
4.375
4
# A palindromic number reads the same both ways. # The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. ## Also in recurrsive function return the function, otherwise it will show none ## Have a palindrome f...
true
01e3add9db5b09606cf11318a41aa8c39b46bb72
KzZe-Sama/Python_Assignment-III-1
/QnA/Bubblesort.py
658
4.28125
4
# bubble sort algorithm # the function sorts list of numbers in ascending order def sortList(data): for i in range(len(data)): for j in range(len(data)): if(j!=len(data)-1): if data[j]>data[j+1]: # creating temp var and storing before swapping ...
true
2d9308a0b0d941fbae26fba050313b8133f5ae83
l4nicero/learning_python
/at_seq.py
1,075
4.25
4
#!/usr/bin/env python3 import random #random.seed(1) # comment-out this line to change sequence each time # Write a program that stores random DNA sequence in a string # The sequence should be 30 nt long # On average, the sequence should be 60% AT # Calculate the actual AT fraction while generating the sequence # Rep...
true
31f6d146a867eec1ca797913e54e1e012726505c
TheHalfling/Py3ArcadeGameClass
/Calculator.py
2,239
4.15625
4
# -*- coding: utf-8 -*- """ Spyder Editor Calculator from Chapter 1 of Program Arcade Games with Pygame """ def mpg(): # miles per gallon print("This program calculates mpg.") # Get Miles driven from user miles_driven = float(input("Enter miles driven: ")) #get gallons used f...
true
e0996ed85bbb7753d9ade2645ea13b0ef81292e6
IlonaPelerin/CTI110
/M5HW2_RunningTotal_Pelerin.py
713
4.125
4
# CTI-110 # M5HW2 - Running Total # Ilona Pelerin # October 19, 2017 # def main(): # declaring and initializing the variables. number = 1.0 runningTotal = 0.0 # setting up the while loop to add numbers until a negative one is entered. while number >= 0: number = float(input('En...
true
2a7cf7af13a8bb8713938f7ee609077c5e9aae08
mundostr/adimra_introprog21_mdq
/sem3/azar.py
715
4.125
4
""" El uso de librerías es una práctica muy standard en todos los lenguajes de programación actuales. En el caso de Python, la cláusula import permite insertar la librería que se desee, para comenzar a utilizar sus métodos. """ # Se importa la librería random, incluída en la instalación predeterminada de Python3 # En ...
false
6a2ed364d4c4091a690f19d9cd19f787ba50471d
mundostr/adimra_introprog21_mdq
/sem8/clases2.py
1,266
4.21875
4
""" Introducción a POO (Programación Orientada a Objetos) Ejemplo de declaración de clases que HEREDAN características de otras, Perro y Gato en este caso, de Mascota. Recordar que una clase es esencialmente un molde que define las características de un objeto. """ class Mascota: def __init__(self, nombre, raza): ...
false
957ddea417c9ab85ca19acc451b73dacf714cf19
RocketHTML/holbertonschool-higher_level_programming
/0x06-python-classes/4-square.py
926
4.1875
4
#!/usr/bin/python3 class Square: def __init__(self, size=0): self.size = size @staticmethod def __check_size(size): if not type(size) == int: raise TypeError("size must be an integer") elif size < 0: raise ValueError("size must be >= 0") @property de...
true
f21e4386013fb02c8346175bc0987e272457f2c8
RocketHTML/holbertonschool-higher_level_programming
/0x06-python-classes/6-square.py
1,685
4.15625
4
#!/usr/bin/python3 class Square: def __init__(self, size=0, position=(0, 0)): self.size = size self.position = position @staticmethod def __check_size(size): if not type(size) == int: raise TypeError("size must be an integer") elif size < 0: raise Val...
true
d17c6d12f42b9125f5bf76fcb639b97b621f518d
idaln/INF200-2019-Exercises
/src/ida_lunde_naalsund_ex/ex_02/bubble_sort.py
813
4.28125
4
# -*- coding: utf-8 -*- __author__ = "Ida Lunde Naalsund" __email__ = "idna@nmbu.no" def bubble_sort(data): """Takes a list or tuple of numbers as input. Returns a copy of the list where the numbers are sorted in increasing order. :param data: List or tuple containing numbers. :return: Sorted li...
true
5b24fb3a6a665e4d0cc20c678d4a0a7fc2cb6dd5
idaln/INF200-2019-Exercises
/src/ida_lunde_naalsund_ex/ex01/letter_counts.py
669
4.25
4
# -*- coding: utf-8 -*- __author__ = 'Ida Lunde Naalsund' __email__ = 'idna@nmbu.no' def letter_freq(txt): """Function returns a dictionary with letters, symbols and digits from input "txt" as keys and counts as values. :param txt: Text written by user :return: freq """ freq = {} for e...
true
fbe73ec569ec7bc54dcd3dd0b8dabce4e17d1688
Gilbert-Adu/my_currency_converter
/proapp.py
598
4.40625
4
""" User interface for module currency When run as a script, this module prompts the user for two currencies and amount. It prints out the result of converting the first currency to the second. Author: Gilbert Adu Date: 7th February 2019 """ import pro currency_from=input('3-letter code for original currency: ') ...
true
2287cc941b4798589932e8fda8ea02b9e4f0803f
rajat3105/Algorithms
/babylonian.py
268
4.1875
4
def root(n): x=n y=1 e=0.001 # e difines the accuracy level while(x-y>e): x=(x+y)/2 y=n/x return x n= int(input("Enter the number whose square root you need to found : ")) print("Root is: ", round(root(n),3))
true
52c4a5cd2f042de57f62d6f675eab8ee2fff14b8
superleggera-21/BI-Class
/in-class hw.py
2,651
4.59375
5
# Define a function called hotel_cost with one argument days as user input. # The hotel costs $140 per day. So, the function hotel_cost should return 140 * days. def hotel_cost(x): return 140*x # Define a function called plane_ride_cost that takes a string, city, as user input. # The function sh...
true
4a4c95dd1c57f74fbc66f8552c3885a4c95d6bcb
MasonJoran/U4L4
/Lesson 4 (Turtle, L1)/Problem4.py
332
4.21875
4
from turtle import * turtle = Turtle() turtle1 = Turtle() turtle.pensize(8) turtle.color('red') turtle.shape('turtle') turtle.speed(9) turtle1.pensize(8) turtle1.color('blue') turtle1.shape('turtle') turtle1.speed(9) for x in range(3): turtle.forward(100) turtle.left(120) turtle1.backward(150) turtle1.circle(75)...
false
9a687191d6e4fba72658656287b9e86877a7ffe1
dchirag/Python
/a84.py
1,296
4.21875
4
''' This code is written to fulfil coursera assignment for the coursera Python Data Structures University Of Michigan, Prof. Charles Severance Aug 2016 It is written with my own efforts and settings. You are free to use it for non-coursera works. However, it is copywrighted mat...
true
1340b8cab54e2bf2a0ac75d27d164ce52258ea68
hyro64/Python_growth
/Chapter 10/Book Examples/pi_string.py
1,540
4.4375
4
"""# Ver 3.0 # this version check to see if the input appears in the data specified # After searching through the data it prints accordingly fileName = "pi_million_digits.txt" with open(fileName) as file_object: lines = file_object.readlines() pi_string = '' for line in lines: pi_string += line. strip() birthd...
true
6bdc6b3269beb139aa315d70fd8935fe316c79a8
Kondguleyashpal/python-programming-lab
/temperatue conversion.py
293
4.125
4
#Title:Temperature conversion # Name: Yashpal Kondgule M 31 x=int(input("Enter temperature:")) #input from user y=input("is it in 'celcius' or 'farenhite'") if y is 'celsius': #if-else statement f=9*x/5 + 32 print(f) else: c=5/9*(x-32) print(c)
false
2f8f258bbd76f62e4b06aec72dc0bb5e35be6e70
psmohammedali/pythontutorial
/loops/while2.py
664
4.28125
4
print("Hacker Rank Question") # Objective # In this challenge, we're going to use loops to help us do some simple math. Check out the Tutorial tab to learn more. # Task # Given an integer, # , print its first multiples. Each multiple (where # # ) should be printed on a new line in the form: n x i = result. # ...
true
738f91ab0bcd7175bca49186ec7558cca1ddab94
Shaunwei/CodingPractice
/CodeBooks/CodeRust/StarcksAndQueues/Stack.py
765
4.34375
4
#!/usr/bin/env python3 # Implementation of Stack using list class Stack(object): """docstring for Stack""" def __init__(self, size=0): self._stack = list() self._size = size def __len__(self): return len(self._stack) def push(self, item): # print('input item: %d' %item) self._stack.append(item) self....
false
74477f1d4aa19e88778c992678655b7f4d687cfe
Devika-Baddani/python-program
/amstrong.py
240
4.125
4
num = int(input("enter a number: ")) d_num = num s = 0 while num>0: r = num%10 s = s + r**3 num //= 10 if s== d_num: print(d_num, "is an amstrong number") else: print(d_num, "is not an amstrong number")
false
f7d181b4f92a97008675f96b740a7b1e3372fd09
henriquebafilho/PythonClasses
/045 GAME Pedra Papel e Tesoura.py
865
4.28125
4
'''Crie um programa que faça o computador jogar Jokenpô com você.''' import random usuário = int(input('''Insira o número que corresponde à sua escolha: 1 - pedra 2 - papel 3 - tesoura ''')) while usuário < 1 or usuário > 3: usuário = int(input("Erro! Insira um valor válido: ")) def objeto(numero): if numero =...
false
7e7524c2453c777f808f8db1a2cce2492d244edf
lenaurman/py
/2.py
2,243
4.125
4
# next step # import import turtle import random # color mode & screen color turtle.colormode(255) turtle.bgcolor(0,0,0) # background color - black def spirala(t): """ Draws a spiral with a given tartle object (t) Starting point is random Color is random blue Width is random """ t.penup() ...
true
2a65af6428836391762f57871a7fdc5ef5aee6cb
cliffjsgit/chapter-12
/exercise122.py
1,878
4.375
4
#!/usr/bin/env python3 __author__ = "Your Name" ############################################################################### # # Exercise 12.2 # # # Grading Guidelines: # - No answer variable is needed. Grading script will call function. # - Function "anagram_finder" should return a list of of all the sets of # w...
true
c117517faab9e23db4803f6ba0eba32fa8370031
shiva-adith/python_projects
/rock_paper_scissors/game.py
1,341
4.21875
4
import random while True: choice = input("Enter your choice or enter end to quit: ").lower() if choice == 'end': break choices = ['rock', 'paper', 'scissors'] # the args for randint set the range required for the output. # the end value is inclusive and hence one is subtracted to prevent...
true
2f8278d26e4a5cd3d5699b30c8988161bb977c8d
Utkarshrathore98/mysirgPythonAssignment_Solution
/Assignment_7_string/Q_4_count occurence.py
316
4.15625
4
'''s=input("enter string ") e=input("enter the element you want to search") for i in s: if i==e: print(e,"--",s.count(i)) break ''' #programs to count occurrence of all elements in string a=input("enter string ") y=0 for i in a: if a.index(i)==y: print(i,"--",a.count(i)) y+=1
false
0402d59e632e05bbf53d074d50a4feac6fd2863c
Utkarshrathore98/mysirgPythonAssignment_Solution
/Assignment_2/greatest among three.py
458
4.21875
4
num_1=int(input("enter the first number ")) num_2=int(input("enter the second number")) num_3=int(input("enter the third number ")) if num_1>num_2: if num_1>num_3: print("the greater number is",num_1) else: print("the greater number is ",num_3) elif num_1==num_2==num_3: print("all numbers a...
true
1a1713ecef84b1963a752e7ebe68491b5d71fd3c
cjc41042/Pig_Latin
/PygLatin.py
410
4.28125
4
import myfunctions input("Hello! Welcome to the English to PigLatin Translator! Hit Enter to begin!") word = input('Enter a word or phrase:') while len(word) > 0: print ("Your new word or phrase is:") print (myfunctions.pig(word)) print ("") print ("Hit Enter to end,") word = input('Or enter ano...
true
891a2b1a83f8e8b672ce299b6d5c8e56fc865139
anushanav/python_logical_solutions
/mirrormatrix.py
505
4.25
4
# Printing mirror image of the given matrix matrix = [[1,2,3], [4,5,6], [7,8,9]] mirror= [[0]*3 for i in range(3)] rows = 3 columns = 3 for i in range(rows): for j in range(columns): mirror[i][j]=matrix[i][columns-1-j] # printing a matrix that shows addition of the given matrix and i...
true
c7c88b39fd14b7dc4c7754df8e4dc2a601cc594f
dorakarkut1/Music-Weather
/get_location.py
764
4.125
4
"""Get location This script based on IP address gets and returns location of user. This script requires that `re, json, urllib` are installed within the Python environment you are running this script in. This file can also be imported as a module and contains the following function: * get_location - returns loc...
true
d3bc53895940522aa706ba220c9cef755896dfae
rishabhsam/Data-Science-Utils-
/unsupAlgoDistanceFunctions.py
2,442
4.5625
5
# -*- coding: utf-8 -*- """ Author : Rishabh Samdarshi Excercise set 2 for W P Carey MSBA 2019-2020 Cohort This code creates the functions for calculating multiple distances like manhattan, euclidean and minkowski """ a,b,c,d = [float (x) for x in input(" Enter coordinates (a,b) (c,d) separated by a space in form a...
false
0fcf6ad54dec3acfc1d4d7f8096f7f840a25298b
RodrigoMorosky/CursoPythonCV
/aula08.py
375
4.25
4
# aula 8 utilizando módulos import math num = int(input('Digite um número: ')) raiz = math.sqrt(num) print('A raiz de {} é igual a {:.2f}'.format(num, raiz)) # dá para importar só a função desejada e não a biblioteca inteira #from math import sqrt #num = int(input('Digite um número: ')) #raiz = sqrt(num) #print('A rai...
false
fd6311b20aa6851ac1dc53420d7faa529bf5d4ab
SuguruChhaya/python-exercises
/Hackerrank 30 days of code/binary.py
402
4.15625
4
print(0b000000001001) # ?binary numbers 0101 is 5, but I don't understand how a binary number can start with a 0 #!As you can see in the previous examples, the sequence between the first 1 and last 1 is what matters. #!No matter how many 0s you add before the first 1, the value wouldn't change #!Addionally, no matter h...
true
7c042db4f53e1b0cedcf889f8117859845705eea
Martondegz/python-snippets
/par.py
1,050
4.15625
4
# Write a function that return whether or not the input string has balanced parentheses # Balanced: # '((()))' # '(()())' # Not balanced: # '((()' # '())(' # use input for a string from pythonds.basic.stack import Stack def parChecker(symbolString): s = Stack() # stack method applied balanced = True...
true