blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
c8af7a794f8074f9c803cd7ebb61ae00b509f475
Frigus27/Structure-Iced
/iced/game_object.py
2,130
4.1875
4
""" game_object.py -------------- The implement of the objects in the game. The game object is the minimum unit to define a interactive object in a game, e.g. a block, a road, a character, etc. In Structure Iced, you can easily define an object by simply inherit the class game_object. A game object requires the argum...
true
c28d9ede48b5c683d129d8f18c93f823fe72be38
artsyanka/October2016Test1
/centralLimitTheorem-Outcomes-Lesson16.py
1,088
4.125
4
#Write a function flip that simulates flipping n fair coins. #It should return a list representing the result of each flip as a 1 or 0 #To generate randomness, you can use the function random.random() to get #a number between 0 or 1. Checking if it's less than 0.5 can help your #transform it to be 0 or 1 import rand...
true
b579e7e4c50ed64154b48830b5d7e6b22c21dd64
Rogerd97/mintic_class_examples
/P27/13-05-2021/ATM.py
934
4.125
4
# https://www.codechef.com/problems/HS08TEST # Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction # if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction # (including bank charges). For each successful withdrawal the ...
true
5ff84a677d4a9595a5d05185a7b0aecacea9e3dd
Rogerd97/mintic_class_examples
/P62/12-05-2021/if_else_2.py
1,325
4.34375
4
# Write a program that asks for the user for the month number # your script should convert the number to the month's name and prints it # Solution 1 # month_number = input("Insert a month number: ") # month_number = int(month_number) # months = {"1": "enero", "2": "febrero", "3": "marzo"} # if month_number < 1 or m...
true
ba2cf9d99471af4cd757d84a0716d02a1f32ca20
Rogerd97/mintic_class_examples
/P27/25-05-2021/exercise_1.py
989
4.5
4
# Write a Python program to reverse a string # Sample String : "1234abcd" # Expected Output : "dcba4321" # def <name> (<arg_1>, <arg_2>, ... <arg_n>): # <algorithm> # [optional] return <result> def reverse_str(phrase): result = phrase[::-1] print(result) # my_str = input("Inserte la frase: ") # rever...
false
1c8ab3d7358c97399ee76c68896020d57f0a8a2a
Rogerd97/mintic_class_examples
/P27/12-05-2021/if_else_2.py
1,801
4.5
4
# Write a program that asks for the user for the month number # your script should convert the number to the month's name and prints it # month_number = input("Insert a month number: ") # month_number = float(month_number) # Solution 1 num= float(input("Ingrese el numero del mes : ")) # if num == 1: # print("Mes...
false
3b41d3051d166653385c7072bab3f1fc7bb3e462
Rogerd97/mintic_class_examples
/P62/26-05-2021/exercise_1.py
540
4.46875
4
# Write a Python script to display the various Date Time formats # a) Current date and time # b) Current year # c) Month of year # d) Week number of the year # e) Weekday of the week # f) Day of year # g) Day of the month # h) Day of week import datetime def print_dates(): date = datetime.datetime.now() print...
true
7d23f66decf7741002378f7895a5b49dd7d65d6c
Rogerd97/mintic_class_examples
/P47/26-05-2021/exercise_1.py
489
4.40625
4
# Write a Python script to display the various Date Time formats # a) Current date and time # b) Current year # c) Month of year # d) Week number of the year # e) Weekday of the week # f) Day of year # g) Day of the month # h) Day of week import datetime #a) date=datetime.datetime.now() print(date) #b) print(date.yea...
false
9d386d7dece46d9e947ae02c509e0ff10fa08be5
levi-fivecoat/Learn
/datatypes/strings.py
473
4.28125
4
my_str = "This is a string." my_str_2 = "I am a strings. I can contain numbers 12345" my_str_3 = "1390840938095" username = "levi : " # YOU CAN ADD STRINGS my_str = username + my_str my_str_2 = username + my_str_2 # YOU CAN SEE WHAT KIND OF DATA TYPE BY USING TYPE() print(type(my_str)) # UPPERCASES STRING my_str ...
true
1ec283d625a9d3c85d2800635f7fc2b6ab4adf7e
hklhai/python-study
/coll/tupleTest.py
552
4.125
4
# coding=utf-8 # 元组是不可变对象,元组支持嵌套 # 列表使用场景频繁修改的情况,元组对于不修改仅查询使用,查询效率高 a = (1, 2, "22") print(type(a)) for e in a: print(e) b = [x for x in a] print(b) # 生成器 b = (x for x in a) print(b) print(b.next()) print(b.next()) print(b.next()) # 元组的索引操作 print(a[1]) # 格式化输出字符串 print('abcd %d and %s' % (66, "hello")) b = (...
false
aa878f2bfc544a6ffdb642d6279faba0addc552c
Juxhen/Data14Python
/Introduction/hello_variables.py
1,333
4.25
4
# a = 5 # b = 2 # c = "Hello!" # d = 0.25 # e = True # f = [1,2,3] # g = (1,2,3) # h = {1,2,3} # # print(a) # print(b) # print(c) # # # How to find the type of variables # print(type(a)) # print(type(b)) # print(type(c)) # print(type(d)) # print(type(e)) # print(type(f)) # print(type(g)) # print(type(h)) # CTRL + / To ...
true
2869ab5cc0f73d29fb120418cd2dcb7f5ab41867
CrunchyPistacho/Algorithms
/data_structures/stack.py
1,760
4.125
4
class Stack: def __init__(self, Size = 5): self.__size = Size self.__stack = [] self.__i = -1 def is_empty(self): if len(self.__stack) == 0: return(0) def is_full(self): if len(self.__stack) == self.__size: return(len(self.__stack)) def...
false
c4b2d02cb02ff875450fc56f1b839cab49b85af6
SDBranka/A_Basic_PyGame_Program
/hello_game.py
718
4.15625
4
#Import and initialize Pygame library import pygame pygame.init() #set up your display window screen = pygame.display.set_mode((500,500)) #set up a game loop running = True while running: # did user click the window close button? for event in pygame.event.get(): if event.type == pygame.QUIT: ...
true
67cf549f5e3ad4935427432d9561de90a1b5e0c7
lauram15a/Fundamentos_de_programacion
/CUADERNOS DE TRABAJO/CUADERNO 5/ej 6 cuaderno 5 cuadrado.py
2,923
4.1875
4
#Laura Mambrilla Moreno #Ej 6 cuaderno 5 """ Implementa una estructura “Cuadrado” que incluya información sobre sus 4 vértices y sobre su punto central, todos los cuales seran del tipo Punto2D. """ #librerías import math #funciones class Punto2D : def __init__ (self, x, y): self.x = x self.y = y ...
false
6bdba93386d8b4f5b4d6662a0f6d774ea195792f
lauram15a/Fundamentos_de_programacion
/CUADERNOS DE TRABAJO/CUADERNO 3/ej 16 cuaderno 3 serie armónica.py
1,837
4.125
4
#LAURA MAMBRILLA MORENO #EJ 16 CUADERNO 3 """ . Escribe un programa que pida un número límite y calcule cuántos términos de la serie armónica son necesarios para que su suma supere dicho límite. Es decir, dado un límite introducido por el usuario (por ejemplo 50) se trata de determinar el menor número n tal que: 1 + 1...
false
fc819bc1fd471c362999ea00a80e78c87c84973b
lauram15a/Fundamentos_de_programacion
/CUADERNOS DE TRABAJO/CUADERNO 2/ej 13 cuaderno 2 distancia puntos.py
818
4.28125
4
#Ejercicio 13 - Cuaderno 2 #Escribe una función que a partir de las coordenadas 3D de dos puntos en el espacio en formato (x, y, z) calcule la distancia que hay entre dichos puntos.Prueba su función y el resultado por pantalla. import math def distancia (xA, yA, zA, xB, yB, zB): """ float, float, float --...
false
77eb5d2baa36b9b114940e8e7b9b8ae86ea36e60
lauram15a/Fundamentos_de_programacion
/CUADERNOS DE TRABAJO/CUADERNO 5/ej 5 cuaderno 5 distancia.py
859
4.21875
4
#Laura Mambrilla Moreno #Ej 5 cuaderno 5 """ Programa una función distancia_2D que calcule la distancia entre dos puntos. La función retornará un número real según la siguiente fórmula: d=((x2 - x1)**2 + (y2 + y1)**2)**(1/2) """ #librerías import math #funciones class Punto2D : def __init__ (self, x, y): ...
false
6e20e66735834d1dd5b8f94ecc6f091ee171374d
lauram15a/Fundamentos_de_programacion
/CUADERNOS DE TRABAJO/CUADERNO 3/ej 10 cuaderno 3 del 1 al 12 meses.py
1,803
4.3125
4
#LAURA MAMBRILLA MORENO #EJ 10 CUADERNO 3 """" Codifica un subprograma que reciba un número entero, y si es entre 1 y 12 escriba un mensaje por pantalla indicando el mes a que dicho número corresponde. En caso contrario deberá mostrar un mensaje de error. Valida las entradas utilizando la función del ejercicio 9. """ ...
false
ddd140fff48bea6af7ba893bfb4b64c5e4bff904
mtjhartley/data_structures
/pre_vertafore/old_python/reverse_list.py
297
4.125
4
test1 = [3,1,6,4,2] test2 = [3,1,6,4] def reverse_list(arr): end = len(arr) - 1 for idx in range(len(arr)/2): temp = arr[idx] arr[idx] = arr[end-idx] arr[end-idx] = temp #print arr return arr print reverse_list(test1) print reverse_list(test2)
false
311fba0777ef7a120c51436743d9ceb3e0fd3470
ArseniyCool/Python-YandexLyceum2019-2021
/Основы программирования Python/4. While-loop/Скидки!.py
550
4.125
4
# Программ считает сумму товаров и делает скидку 5 % на товар,если его стоимость превышает 1000 price = float(input('Введите цену на товар:')) cost = 0 while price >= 0: if price > 1000: cost = cost + (price - 0.05 * price) else: cost = cost + price price = float(input('Введите цену ...
false
0c8643ec77ec3a9702da7e8202650f7b70c2f486
ArseniyCool/Python-YandexLyceum2019-2021
/Основы программирования Python/9. Sets/Книги на лето.py
984
4.125
4
# Представьте, что Вам задали читать книги на лето # К счастью, у Вас на компьютере есть текстовый документ, в котором записаны # все книги из его домашней библиотеки в случайном порядке. # Программа определяет, какие книги из списка на лето у Вас есть, а каких нет. M = int(input('Введите кол-во книг на Вашем ком...
false
c19f01337bf12fea45fd094be225f74ef3625d28
ArseniyCool/Python-YandexLyceum2019-2021
/Основы программирования Python/10. Strings indexing/Игра в города — Альфа.py
612
4.28125
4
# Игра в города в один раунд: # Участники вводят поочередно 2 города(1 раз), # так чтобы каждая начальная буква города начиналась с конечной буквы прошлого города, # если второй участник ошибётся - он проиграет # # Города писать в нижнем регистре word_1 = input() word_2 = input() if word_1[len(word_1) - 1] =...
false
fc89779a2cf480512ac48b7a21c5d344a30e56d6
Seanie96/ProjectEuler
/python/src/Problem_4.py
1,154
4.34375
4
""" solution to problem 4 """ NUM = 998001.0 def main(): """ main function """ starting_num = NUM while starting_num > 0.0: num = int(starting_num) if palindrome(num): print "palindrome: " + str(num) if two_factors(num): print "largest number: " + str...
true
95eb8f40f40eed4eebfa1e13dcb0117b80cb6832
mamare-matc/Intro_to_pyhton2021
/week3_strings.py
1,347
4.5
4
#!/usr/bin/python3 #week 3 srting formating assignment varRed = "Red" varGreen = "Green" varBlue = "Blue" varName = "Timmy" varLoot = 10.4516295 # 1 print a formatted version of varName print(f"'Hello {varName}") # 2 print multiple strings connecting with hyphon print(f"'{varRed}-{varGreen}-{varBlue}'") # 3 print...
true
cd21e893b48d106b791d822b6fded66542924661
a12590/LeetCode_My
/100-149/link_preoder(stack)_flatten.py
1,798
4.1875
4
#!/usr/bin/python # _*_ coding: utf-8 _*_ """ 非递归先序遍历,注意rtype void要求 """ # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def flatten(self, root): """ :type root:...
true
56db6680ee71ac028d80721be24dff5e9c844f06
BrunoPessi/lista-exercicios-python
/ex7.py
897
4.1875
4
# 7 - Escreva um algoritmo que leia 10 números informados pelo usuário e, depois, informe o menor, número, # o maior número, a soma dos números informados e a média aritmética dos números informados. def maior (numeros): print("O maior numero digitado foi:",max(numeros)) def menor (numeros): print("O menor n...
false
8002e75ad6a2bddaf3ce57ca4a82e16bf0353339
BrunoPessi/lista-exercicios-python
/ex3.py
699
4.21875
4
# 3 - Crie uma classe calculadora com as quatro operações básicas (soma, subtração, multiplicação e divisão). O # usuário deve informar dois números e o programa deve fazer as quatro operações. (modifique para calcular tudo no # mesmo método, somando 1 ao resultado de cada operação). def calculadora (n1,n2): soma ...
false
9f12786f688abb908c333b2249be6fb18bdcd1d6
keyurbsq/Consultadd
/Additional Task/ex6.py
258
4.4375
4
#Write a program in Python to iterate through the string “hello my name is abcde” and print the #string which is having an even length. k = 'hello my name is abcde' p = k.split(" ") print(p) for i in p: if len(i) % 2 == 0: print(i)
true
d63d46c893052f76ea6f0906dd7166af5793a27b
keyurbsq/Consultadd
/Additional Task/ex4.py
245
4.3125
4
#Write a program in Python to iterate through the list of numbers in the range of 1,100 and print #the number which is divisible by 3 and is a multiple of 2. a = range(1, 101) for i in a: if i%3 == 0 and i%2==0: print(i)
true
da83ffdd1873d70f4f5321c09c0a3ff1fb1ffc85
r0meroh/CSE_CLUB_cpp_to_python_workshop
/people_main.py
1,580
4.25
4
from person import * from worker import * import functions as fun def main(): # create list of both types of objects people = [] workers = [] # prompt user answer = input("adding a Person, worker? Or type exit to stop\n") answer = answer.upper() while answer != 'EXIT': # if an...
true
e0058dfbb608836b24d131f6c92cabc1c551ad68
rjraiyani/Repository2
/larger_number.py
272
4.125
4
number1 = int(input('Please enter a number ' )) number2 = int(input('Please enter another number ' )) if number1 > number2: print('The first number is larger.') elif number1 < number2: print('The second number is larger.') else: print('The two numbers are equal.' )
true
84b13b5ca2d438daac8c08a6a4d339f0ee9eb653
rjraiyani/Repository2
/exercise2.py
266
4.375
4
x = int(input('Please enter a number ')) m = x % 2 n = x % 3 if m == 0: #Even number if n == 0: print('Even and Divisible by 2') else: print('Even') else: if n == 0: print('odd and divisible by 3') else: print('odd')
false
837e57d5a2751f378a6d51770a219754400b7197
Andchenn/Lshi
/day02/集合.py
1,021
4.21875
4
# 集合:以大括号形式表现的数据集合,集合里面的数据不可以重复 # 集合可以根据下标获取数据,也可以添加和删除 # 不可以以此种方式定义空的集合 # my_set = {} #dict字典 my_set = {1, 4, "abc", "张三"} print(my_set) # 删除数据(删除指定数据)(不能删除没有的数据) # my_set.remove("22") # print(my_set) # 增加数据 # 不可以添加重复的数据 my_set.add("5") my_set.add("5") my_set.add("5") print(my_set) # 删除集合里面的数据(删除没有的数据不会崩溃) # my_se...
false
edd5cf21f14675cf6a4af3d6f20a082bd48ab1ae
davidlkang/foundations_code
/shopping_list.py
1,423
4.125
4
def show_help(): print(""" Type 'HELP' for this help. Type 'CLEAR' to clear your list. Type 'DEL X' where 'X' is the number of the element you want to remove. Type 'SHOW' to display your list. Type 'DONE' to stop adding items. """) def add_to_list(user_input): shopping_list.append(user_input.lower()) prin...
true
7ca179a45c2136eb638a635b700909482a5376fb
davidlkang/foundations_code
/login_app.py
1,277
4.25
4
users = { "user1" : "password1", "user2" : "password2", "user3" : "password3"} def accept_login(users, username, password): if username in users: if password == users[username]: return True return False def login(): while True: if input("Do you want to sign in?\n(...
true
f02e6f8d9a81b072ab3582f1469a62cc25b0905b
takaakit/design-pattern-examples-in-python
/structural_patterns/flyweight/main.py
901
4.34375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from structural_patterns.flyweight.large_size_string import LargeSizeString ''' Display a string consisting of large characters (0-9 digits only). Large character objects are not created until they are needed. And the created objects are reused. Example Output ----- Pleas...
true
bad357e547032486bc7e5b04b7b92351148a2b19
21milushcalvin/grades
/Grades.py
1,649
4.25
4
#--By Calvin Milush, Tyler Milush #--12 December, 2018 #--This program determines a test's letter grade, given a percentage score. #--Calvin Milush #-Initializes variables: score = 0 scoreList = [] counter = 0 total = 0 #--Calvin Milush #-Looped input for test scores: while (score != -1): score = in...
true
3f2832d039f29ef99679e8c51d42f5fb08b1dcff
pullannagari/python-training
/ProgramFlow/contrived.py
425
4.21875
4
# con·trived # /kənˈtrīvd/ # Learn to pronounce # adjective # deliberately created rather than arising naturally or spontaneously. # FOR ELSE, else is activated if all the iterations are complete/there is no break numbers = [1, 45, 132, 161, 610] for number in numbers: if number % 8 == 0: #reject the lis...
true
7f9b228de7c12560ac80445c6b1a4d7543ddc263
pullannagari/python-training
/Functions_Intro/banner.py
1,312
4.15625
4
# using default parameters, # the argument becomes # optional at the caller def banner_text(text: str = " ", screen_width: int = 60) -> None: """ centers the text and prints with padded ** at the start and the end :param text: string to be centered and printed :param screen_width: width of the screen on...
true
232c40b3f47c42c8a33fcc5d7e4bde2719969080
Hemalatah/Python-Basic-Coding
/Practice2.py
2,684
4.125
4
#CRAZY NUMBERS def crazy_sum(numbers): i = 0; sum = 0; while i < len(numbers): product = numbers[i] * i; sum += product; i += 1; return sum; numbers = [2,3,5]; print crazy_sum(numbers); #FIND THE NUMBER OF PERFECT SQUARES BELOW THIS NUMBER def square_nums(max): num = 1; count = 0; while num < max: produ...
true
1ba2daae4ad916e06b92b9277ca113d64bbd3a84
miss-faerie/Python_the_hard_way
/ex3.py
507
4.25
4
hens = int(25+30/6) roosters = int(100-25*3%4) eggs = int(3+2+1-5+4%2-1/4+6) print() print("I will now count my chickens:") print("Hens",hens) print("Roosters",roosters) print("Now I will count the eggs:",eggs) print() print("Is it true that 3+2 < 5-7 ?",(3+2)<(5-7)) print("What is 3+2 ?",3+2) print("What is 5-7 ?",5...
true
55e136a4bc7dc3170e38564c14f8ffe09bd16bdd
achkataa/Python-Advanced
/Functions Advanced/5.Odd or Even.py
352
4.125
4
command = input() numbers = [int(num) for num in input().split()] def print_results(nums): print(sum(nums) * len(numbers)) def needed_numbers(nums): if command == "Odd": nums = [num for num in nums if num % 2 != 0] else: nums = [num for num in nums if num % 2 == 0] print_results(nums)...
false
16e176e7b1f43c5c78feea53472ad5cdf2949955
tsabz/ITS_320
/Option #2: Repetition Control Structure - Five Floating Point Numbers.py
1,321
4.25
4
values_dict = { 'Module 1': 0, 'Module 2': 0, 'Module 3': 0, 'Module 4': 0, 'Module 5': 0, } # first we want to have the student enter grades into set def Enter_grades(): print('Please enter your grade for Module 1:') values_dict['Module 1'] = int(float(input())) print('Please enter y...
true
f13d14609b6c98949dc2e70a7de24f4a5e443ca0
taeheechoi/coding-practice
/FF_mergeTwoSortedLists.py
1,061
4.1875
4
# https://leetcode.com/problems/merge-two-sorted-lists/ # Input: list1 = [1,2,4], list2 = [1,3,4] # Output: [1,1,2,3,4,4] def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]: #create dummy node so we can compare the first node in each list dummy = ListNode() #ini...
true
8786abcb461d20e104b4ca579bef7324c1924105
taeheechoi/coding-practice
/FB/208_062722-implement-trie-prefix-tree.py
1,053
4.21875
4
# https://leetcode.com/problems/implement-trie-prefix-tree/discuss/1804957/Python-3-Easy-solution class Trie: def __init__(self): self.children = {} self.is_end = False def insert(self, word): curr = self for w in word: if w not in curr.children: ...
false
2190f7f62adf79cd2ee82007132c9571e4f0e68b
Codeducate/codeducate.github.io
/students/python-projects-2016/guttikonda_dhanasekar.py
950
4.1875
4
#This program will tell people how much calories they can consume until they have reached their limit. print("How old are you") age = int(input()) print("How many calories have you consumed today?") cc = int(input()) print("Are you a male or female?") gender = input() print("Thanks! We are currently calculating your d...
true
98e78ab456a9b654f37b48fd459c6b24f2560b93
afmendes/alticelabs
/Programs and Applications/Raspberry Pi 4/Project/classes/Queue.py
595
4.1875
4
# simple queue class with FIFO logic class Queue(object): """FIFO Logic""" def __init__(self, max_size: int = 1000): self.__item = [] # adds a new item on the start of the queue def enqueue(self, add): self.__item.insert(0, add) return True # removes the last items of the q...
true
4881c26cd1491c9017017296ad830edb28653ae8
tvumos/dz4
/borndayforewer.py
1,200
4.46875
4
""" МОДУЛЬ 2 Программа из 2-го дз Сначала пользователь вводит год рождения Пушкина, когда отвечает верно вводит день рождения Можно использовать свой вариант программы из предыдущего дз, мой вариант реализован ниже Задание: переписать код используя как минимум 1 функцию """ # Дата рождения А.С Пушкина = 26 мая 1799 г. ...
false
eba5b2a0bceea1cc3848e70e0e68fc0f0607a677
tanishksachdeva/leetcode_prog
/9. Palindrome Number.py
1,083
4.3125
4
# Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. # Follow up: Could you solve it without converting the integer to a string? # Example 1: # Input: x = 121 # Output: true # Example 2: # Input: x = -121 # Output: false # Explanation: From left t...
true
3df720d5c88d4d4fca5f8ec14850f9697f737401
2000xinxin/pythonProject
/学习代码/flie_baseop.py
1,281
4.1875
4
# 将小说的主要人物记录在文件中 # file1 = open('name.txt', 'w') # 第二个参数 'w' 代表的是写入 # file1.write('诸葛亮') # file1.close() # 读取 name.txt 文件的内容 # file2 = open('name.txt') # print(file2.read()) # file2.close() # # file3 = open('name.txt', 'a') # 第二个参数 'a' 代表的是增加 # file3.write('刘备') # file3.close() # file4 = open('name.txt') # print(...
false
084a8d9a138e77eba923726e61c139b58170073d
femakin/Age-Finder
/agefinder.py
1,116
4.25
4
#Importing the necessary modules from datetime import date, datetime import calendar #from datetime import datetime #Getting user input try: last_birthday = input('Enter your last birthdate (i.e. 2017,07,01)') year, month, day = map(int, last_birthday.split(',')) Age_lastbthday = int(input("Age, as at las...
true
57249ecd6489b40f0ca4d3ea7dd57661b436c106
tjastill03/PythonExamples
/Iteration.py
343
4.15625
4
# Taylor Astill # What is happening is a lsit has been craeted and the list is being printed. # Then it is sayingfor each of the listed numbers # list of numbers numberlist = [1,2,3,4,5,6,7,8,9,10] print(numberlist) # iterate over the list for entry in numberlist: # Selection over the iteration if (entry %...
true
fee46693ff557202fba24ba5a16126341624fdd6
lepaclab/Python_Fundamentals
/Medical_Insurance.py
2,599
4.6875
5
# Python Syntax: Medical Insurance Project # Suppose you are a medical professional curious #about how certain factors contribute to medical #insurance costs. Using a formula that estimates #a person’s yearly insurance costs, you will investigate #how different factors such as age, sex, BMI, etc. affect the pr...
true
49f8b9cfb5f19a643a0bacfe6a775c7d33d1e95d
denvinnpaolo/AlgoExpert-Road-to-Cerification-Questions
/Recursion/NthFibonacci.py
713
4.34375
4
# Nth Fibonacci # Difficulty: Easy # Instruction: # # The Fibonacci sequence is defined as follows: the first number of the sequence # is 0 , the second number is 1 , and the nth number is the sum of the (n - 1)th # and (n - 2)th numbers. Write a function that takes in an integer "n" # and returns the nth ...
true
adffbd365423fb9421921d4ca7c0f5765fe0ac60
denvinnpaolo/AlgoExpert-Road-to-Cerification-Questions
/Arrays/ThreeNumSum.py
1,745
4.34375
4
# ThreeNumSum # Difficulty: Easy # Instruction: # Write a function that takes in a non-empty array of distinct integers and an # integer representing a target sum. The function should find all triplets in # the array that sum up to the target sum and return a two-dimensional array of # all these triplets. The...
true
e7499f4caab0fb651b8d9a3fc5a7c374d184d28f
akhileshsantoshwar/Python-Program
/Programs/P07_PrimeNumber.py
660
4.40625
4
#Author: AKHILESH #This program checks whether the entered number is prime or not def checkPrime(number): '''This function checks for prime number''' isPrime = False if number == 2: print(number, 'is a Prime Number') if number > 1: for i in range(2, number): if number % i ==...
true
4fe9d7b1d738012d552b79fb4dc92a3c65fa7e53
akhileshsantoshwar/Python-Program
/Programs/P08_Fibonacci.py
804
4.21875
4
#Author: AKHILESH #This program calculates the fibonacci series till the n-th term def fibonacci(number): '''This function calculates the fibonacci series till the n-th term''' if number <= 1: return number else: return (fibonacci(number - 1) + fibonacci(number - 2)) def fibonacci_without_...
true
3060667c2327aa358575d9e096d9bdc353ebedaa
akhileshsantoshwar/Python-Program
/Programs/P11_BinaryToDecimal.py
604
4.5625
5
#Author: AKHILESH #This program converts the given binary number to its decimal equivalent def binaryToDecimal(binary): '''This function calculates the decimal equivalent to given binary number''' binary1 = binary decimal, i, n = 0, 0, 0 while(binary != 0): dec = binary % 10 decimal = d...
true
c3e19b89c753c95505dc168514dd760f486dd4b9
akhileshsantoshwar/Python-Program
/OOP/P03_InstanceAttributes.py
619
4.21875
4
#Author: AKHILESH #In this example we will be seeing how instance Attributes are used #Instance attributes are accessed by: object.attribute #Attributes are looked First in the instance and THEN in the class import random class Vehicle(): #Class Methods/ Attributes def type(self): #NOTE: This is not a ...
true
74d0b16405a97e6b5d2140634f2295d466b50e64
akhileshsantoshwar/Python-Program
/Programs/P54_PythonCSV.py
1,206
4.3125
4
# Author: AKHILESH # In this example we will see how to use CSV files with Python # csv.QUOTE_ALL = Instructs writer objects to quote all fields. # csv.QUOTE_MINIMAL = Instructs writer objects to only quote those fields which contain special characters such # as delimiter, quotechar or any of the c...
true
0488727a912f98123c6e0fdd47ccde36df895fbd
akhileshsantoshwar/Python-Program
/Programs/P63_Graph.py
2,160
4.59375
5
# Author: AKHILESH # In this example, we will see how to implement graphs in Python class Vertex(object): ''' This class helps to create a Vertex for our graph ''' def __init__(self, key): self.key = key self.edges = {} def addNeighbour(self, neighbour, weight = 0): self.edges[neig...
true
8271310a83d59aa0d0d0c392a16a19ef538c749d
akhileshsantoshwar/Python-Program
/Numpy/P06_NumpyStringFunctions.py
1,723
4.28125
4
# Author: AKHILESH import numpy as np abc = ['abc'] xyz = ['xyz'] # string concatenation print(np.char.add(abc, xyz)) # ['abcxyz'] print(np.char.add(abc, 'pqr')) # ['abcpqr'] # string multiplication print(np.char.multiply(abc, 3)) # ['abcabcabc'] # numpy.char.center: This function returns an array of the requ...
true
384c45c69dc7f7896f84c42fdfa9e7b9a4a1d394
tobyatgithub/data_structure_and_algorithms
/challenges/tree_intersection/tree_intersection.py
1,392
4.3125
4
""" In this file, we write a function called tree_intersection that takes two binary tree parameters. Without utilizing any of the built-in library methods available to your language, return a set of values found in both trees. """ def tree_intersection(tree1, tree2): """ This function takes in two binary tre...
true
212ea767940360110c036e885c544609782f9a82
tobyatgithub/data_structure_and_algorithms
/data_structures/binary_tree/binary_tree.py
1,454
4.375
4
""" In this file, we make a simple implementation of binary tree. """ import collections class TreeNode: def __init___(self, value=0): self.value = value self.right = None self.left = None def __str__(self): out = f'This is a tree node with value = { self.val } and left = { se...
true
8e05603d65047bb6f747be134a6b9b6554f5d9cc
ganguli-lab/nems
/nems/nonlinearities.py
757
4.21875
4
""" Nonlinearities and their derivatives Each function returns the value and derivative of a nonlinearity. Given :math:`y = f(x)`, the function returns :math:`y` and :math:`dy/dx` """ import numpy as np def exp(x): """Exponential function""" # compute the exponential y = np.exp(x) # compute the fir...
true
f11cabe118d21fc4390c6dc84a85581f374a4e8f
liming870906/Python2_7Demo
/demos/D004_MaxNumber.py
323
4.125
4
number1 = int(input("number1:")) number2 = int(input("number2:")) number3 = int(input("number3:")) if number1 >= number2: if number1 >= number3: print("Max:",number1) else: print("Max:",number3) else: if number2 >= number3: print("Max:",number2) else: print("Max:",numbe...
false
4851bf916952b52b1b52eb1d010878e33bba3855
tusvhar01/practice-set
/Practice set 42.py
489
4.25
4
my_tuple = tuple((1, 2, "string")) print(my_tuple) my_list = [2, 4, 6] print(my_list) # outputs: [2, 4, 6] print(type(my_list)) # outputs: <class 'list'> tup = tuple(my_list) print(tup) # outputs: (2, 4, 6) print(type(tup)) # outputs: <class 'tuple'> #You can also create a tuple u...
true
37c28ad515026a3db91878d907f7d31e14f7e9a7
tusvhar01/practice-set
/Practice set 73.py
472
4.125
4
a=input("Enter first text: ") b=input("Enter second text: ") a=a.upper() b=b.upper() a=a.replace(' ','') b=b.replace(' ','') if sorted(a)==sorted(b): print("It is Anagram") # anagram else: print("Not Anagram") #An anagram is a new word formed by rearranging the letters of a word, usin...
true
bd50429e48eae21d7a37647c65ae61866c1e97cb
dviar2718/code
/python3/types.py
1,259
4.1875
4
""" Python3 Object Types Everything in Python is an Object. Python Programs can be decomposed into modules, statements, expressions, and objects. 1. Programs are composed of modules. 2. Modules contain statements. 3. Statements contain expressions. 4. Expressions create and process objects Object Type Example -...
true
1a7b97bce6b4c638d505e1089594f54914485ec0
shaner13/OOP
/Week 2/decimal_to_binary.py
598
4.15625
4
#intiialising variables decimal_num = 0 correct = 0 i = 0 binary = '' while(correct==0): decimal_num = int(input("Enter a number to be converted to binary.\n")) if(decimal_num>=0): correct = correct + 1 #end if else: print("Enter a positive integer please.") #end else #end...
true
294115d83f56263f56ff23790c35646fa69f8342
techreign/PythonScripts
/batch_rename.py
905
4.15625
4
# This will batch rename a group of files in a given directory to the name you want to rename it to (numbers will be added) import os import argparse def rename(work_dir, name): os.chdir(work_dir) num = 1 for file_name in os.listdir(work_dir): file_parts = (os.path.splitext(file_name)) os.rename(file_na...
true
f08a7e8583fe03de82c43fc4a032837f5ac43b06
bartoszmaleta/python-microsoft-devs-yt-course
/25th video Collections.py
1,278
4.125
4
from array import array # used later names = ['Bartosz', 'Magda'] print(names) scores = [] scores.append(98) # Add new item to the end scores.append(85) print(scores) print(scores[1]) # collections are zero-indexed points = array('d') # d stands for digits points.append(44) points.append(12...
true
9eb9c7ecf681c8ccc2e9d89a0c8324f94560a1f3
bartoszmaleta/python-microsoft-devs-yt-course
/31st - 32nd video Parameterized functions.py
878
4.28125
4
# same as before: def get_initial2(name): initial = name[0:1].upper() return initial first_name3 = input("Enter your firist name: ") last_name3 = input("Enter your last name: ") print('Your initials are: ' + get_initial2(first_name3) + get_initial2(last_name3)) # ___________________ def get_iniial(name...
true
2fb0f374d4b6e0b4e08b9dd6cdd324c903537832
MMVonnSeek/Hacktoberfest-2021
/Python-Programs/Reverse_Doubly_Linked_List_Using_Stack.py
1,291
4.21875
4
class Node: def __init__(self, data): self.prev = None self.data = data self.next = None class Doubly_Linked_List: def __init__(self): self.head = None def Add_at_front(self, new_data): new_node = Node(new_data) new_node.next = self.head ...
false
6544630135a7287c24d1ee167285dc00202cb9aa
MMVonnSeek/Hacktoberfest-2021
/Python-Programs/avg-parse.py
1,168
4.15625
4
# Total, Average and Count Computation from numbers in a text file with a mix of words and numbers fname = input("Enter file name: ") # Ensure your file is in the same folder as this script # Test file used here is mbox.txt fhandle = open(fname) # Seeking number after this word x x = "X-DSPAM-Confidence:" y = len(x) ...
true
6934e148c95348cd43a07ddb86fadc5723a0e003
MMVonnSeek/Hacktoberfest-2021
/Python-Programs/number_decorator.py
543
4.34375
4
# to decorate country code according to user defined countrycode # the best practical way to learn python decorator country_code = {"nepal": 977, "india": 91, "us": 1} def formatted_mob(original_func): def wrapper(country, num): country = country.lower() if country in country_code: ret...
true
dc882ac280f0b5c40cbc1d69ee9db9529e1ad001
Raviteja02/CorePython
/venv/Parameters.py
2,308
4.28125
4
#NonDefault Parameters: we will pass values to the non default parameters at the time of calling the function. def add(a,b): c = a+b print(c) add(100,200) add(200,300) print(add) #function address storing in a variable with the name of the function. sum=add #we can assign the function variable to any user ...
true
0f32a56ec557f7a68cbcf591e5d43b4ba8bd84a8
abiramikawaii/Python
/sum-of-multiples.py
265
4.21875
4
def sum_of_multiples(a,b, n): ans=0 for i in range (1,n): if(i%a==0 or i%b==0): ans=ans+i print("Sum of multiples of ", a,"and",b, "for all the natural numbers below ", n, " is ", int(ans)) # Driver Code sum_of_multiples(3,5, 20)
false
3b1bbf74275f81501c8aa183e1ea7d941f075f56
Tadiuz/PythonBasics
/Functions.py
2,366
4.125
4
# Add 1 to a and store it in B def add1(a): """ This function takes as parameter a number and add one """ B = a+1 print(a," if you add one will be: ",B) add1(5) print(help(add1)) print("*"*100) # Lets declare a function that multiplies two numbers def mult(a,b): C = a*b return C ...
true
b2c4bb3420c54e65d601c16f3bc3e130372ae0de
nfarnan/cs001X_examples
/functions/TH/04_main.py
655
4.15625
4
def main(): # get weight from the user weight = float(input("How heavy is the package to ship (lbs)? ")) if weight <= 0: print("Invalid weight (you jerk)") total = None elif weight <= 2: # flat rate of $5 total = 5 # between 2 and 6 lbs: elif weight <= 6: # $5 + $1.50 per lb over 2 total = 5 + 1.5 ...
true
b5dd5d77115b2c9206c4ce6c22985e362f13c15e
nfarnan/cs001X_examples
/exceptions/MW/03_input_valid.py
529
4.21875
4
def get_non_negative(): valid = False while not valid: try: num = int(input("Enter a non-negative int: ")) except: print("Invalid! Not an integer.") else: if num < 0: print("Invalid! Was negative.") else: valid = True return num def get_non_negative2(): while True: try: num = int(i...
true
c1d825716a2c9b68e5e247420ebd50cef03fef07
AnastasisKapetanis/mypython
/askhseisPython/askhsh9.py
260
4.1875
4
num = input("Give a number: ") num = int(num) def sum_digits(n): s = 0 while n: s += n % 10 n //= 10 return s while(len(str(int(num)))>1): num = num*3 + 1 num =sum_digits(num) print("The number is: " + str(num))
false
d0410d0788621701d56ad8b56e6f49cb048c227b
mhashilkar/Python-
/2.1if_statment.py
238
4.25
4
""" THIS IS A BASIC IF STATMENT IN PYTHON tuna = "fish" if tuna == "fish": print('this is a fish alright', tuna) """ tuna = "fish" if tuna == "fish": # IF THE STATMENT IS TRUE THE IT WILL PRINT THE STATMENT print('allright')
false
b862f9fd6aad966de8bd05c2bfcb9f9f12ba61f5
mhashilkar/Python-
/2.9.7_Variable-length_arguments.py
590
4.5
4
# When you need to give more number of arguments to the function # " * "used this symbol tho the argument that means it will take multiple value # it will be a tuple and to print that args you have to used the for loop def printinfo(args1, *vartuple): print("Output is: ") print(args1) for var in vartuple:...
true
d93ead75f6ee6fa3198d0a243b063a4a5795544b
OscarMCV/Monomials-Python
/main.py
2,954
4.125
4
"""Main program.""" from monomial import Monomial def test_monomial_string_representation(): """Prints monomials to test __str__ method.""" print(Monomial(0, 0)) print(Monomial(0, 1)) print(Monomial(0, 5)) print(Monomial(1, 0)) print(Monomial(1, 1)) print(Monomial(1, 5)) print(Monomia...
false
6f92d75468e99445c071c26daf00dc7392c95ba2
badilet/Task21
/Task21.py
251
4.15625
4
# Напишите функцию которая будет суммировать введенные три случайные цифры. def multiply(num1, num2, num3): answer = num1 * num2 * num3 return answer print(multiply(2, 2, 2))
false
b0c57e4bbcfa9a9e6283ebceeca1a0a5594a28c5
ramyashah27/chapter-8-and-chapter-9
/chapter 9 files are op/03write.py
382
4.15625
4
# f = open('another.txt', 'w') # f.write("this file is created through writing in 'w'") # f.close() # this is to make/open file and will add (write) all data in it, it will overright f = open('another.txt', 'a') f.write(' and this is appending') f.close() #this is to add data in the end # how many times we r...
true
b2c09cf42fa22404a0945b1746176a1b847bd260
dobtco/beacon
/beacon/importer/importer.py
974
4.125
4
# -*- coding: utf-8 -*- import csv def convert_empty_to_none(val): '''Converts empty or "None" strings to None Types Arguments: val: The field to be converted Returns: The passed value if the value is not an empty string or 'None', ``None`` otherwise. ''' return val if va...
true
31d79ed21483f3cbbc646fbe94cf0282a1753f91
OceanicSix/Python_program
/parallel_data_processing/data_parition/binary_search.py
914
4.125
4
# Binary search function def binary_search(data, target): matched_record = None position = -1 # not found position lower = 0 middle = 0 upper = len(data) - 1 ### START CODE HERE ### while (lower <= upper): # calculate middle: the half of lower and upper middle = int((lowe...
true
33e560583b1170525123c867bb254127c920737f
OceanicSix/Python_program
/Study/Search_and_Sort/Insertion_sort.py
840
4.34375
4
# sorts the list in an ascending order using insertion sort def insertion_sort(the_list): # obtain the length of the list n = len(the_list) # begin with the first item of the list # treat it as the only item in the sorted sublist for i in range(1, n): # indicate the current item to be posit...
true
9982e8d147441c02f3bc24a259105ae350477485
OceanicSix/Python_program
/test/deck.py
322
4.15625
4
def recursive_addition(number): if number==1: return 1 else: return recursive_addition(number-1)+number print(recursive_addition(4)) def recursive_multiplication(n,i): if n==i: return i else: return recursive_multiplication(n-1,i)*n print(recursive_multiplication(5,2...
false
f23588e2e08a6dd36a79b09485ebc0f7a59ed6b7
chiragkalal/python_tutorials
/Python Basics/1.python_str_basics.py
930
4.40625
4
''' Learn basic string functionalities ''' message = "it's my world." #In python we can use single quotes in double quotes and vice cersa. print(message) message = 'it\'s my world.' #Escape character('\') can handle quote within quote. print(message) message = """ It's my world. And I know how to save this ...
true
a267ce733dae7638beee46d181d5e4d81a81747e
YXY980102/YXY980102
/11,运算符-比较运算符.py
831
4.125
4
''' 运算符 描述 实例 == 等于 - 比较对象是否相等 (a == b) 返回 False。 != 不等于 - 比较两个对象是否不相等 (a != b) 返回 True。 > 大于 - 返回x是否大于y (a > b) 返回 False。 < 小于 - 返回x是否小于y。所有比较运算符返回1表示真,返回0表示假。这分别与特殊的变量True和False等价。注意,这些变量名的大写。 (a < b) 返回 True。 >= 大于等于 - 返回x是否大于等于y。 (a >= b) 返回 False。 <= 小于等于 - 返回x是否小于等于y。 (a <= b) 返回 ...
false
be83f2c448015ca8108ba665a057ce30ef3e7ed0
Lucchese-Anthony/MonteCarloSimulation
/SimPiNoMatplotlib.py
885
4.21875
4
import math import random inside = 1 outside = 1 count = 0 def inCircle(x, y): #function that sees if the coordinates are contained within the circle, either returning false or true return math.sqrt( (x**2) + (y**2) ) <= 1 while True: count = count + 1 #random.uniform generates a 'random' number betw...
true
209c616fe9c622b4269bddd5a7ec8d06d9a27e86
paula867/Girls-Who-Code-Files
/survey.py
2,480
4.15625
4
import json import statistics questions = ["What is your name?", "What is your favorite color?", "What town and state do you live in?", "What is your age?", "What year were you born?"] answers = {} keys = ["Name", "Favorite color", "Hometown","Age", "Birthye...
true
d3c5e30d763a1126c3075b37562a8c953c0102d7
damiras/gb-python
/lesson6/task2.py
1,215
4.3125
4
""" Реализовать класс Road (дорога), в котором определить атрибуты: length (длина), width (ширина). Значения данных атрибутов должны передаваться при создании экземпляра класса. Атрибуты сделать защищенными. Определить метод расчета массы асфальта, необходимого для покрытия всего дорожного полотна. Использовать формулу...
false
c2123be019eca85251fbd003ad3894bb51373433
jacobroberson/ITM313
/hw2.py
1,516
4.5
4
''' This program provides an interface for users to select a medium and enter a distance that a sound wave wil travel. Then the program will calculate and display the time it takes for the waveto travel the given distance. Programmer: Jacob Roberson Course: ITM313 ''' #Intialize variables selection = 0 medium ...
true
fd297908294c04f1aab9e4ac00fe2aab7b7cab03
GoldCodeSensen/python_exercise
/digui.py
680
4.125
4
#递归算法关键点:1.调用函数自身的行为 2.有停止条件 #下面举一个计算阶乘的例子 def factorial(x): if x>1: return x*factorial(x-1) else: return 1 print(factorial(10)) #递归举例,计算斐波那契数列 def fabo(x): if x > 2: return fabo(x-1)+fabo(x-2) elif x == 2: return 1 elif x == 1: return 1 print(fabo(20)) #用递归...
false
ff62ce4e5ae2d83bed1443584040f831ab8ca9f0
GoldCodeSensen/python_exercise
/oop_pool.py
1,246
4.4375
4
#类的组合:把类的实例化放在新的类中 class Turtle: def __init__(self,x): self.num = x class Fish: def __init__(self,x): self.num = x class Pool:#类Pool将Turtle类和Fish类实例化,作为自己的元素 def __init__(self,x,y): self.turtle = Turtle(x) self.fish = Fish(y) def print_num(self): print('There ar...
false
b927d3a715909e49b61a08a9e60390ce6e0f609a
DanielMoscardini-zz/python
/pythonProject/Curso Em Video Python/Mundo 3/Aula 16.py
1,363
4.59375
5
""" Listas são definidos por colchetes => [] Listas podem ser mutaveis Para adicionar valores a uma lista(ao final da lista), utilize o metodo .append(x) Para adicionar valores em alguma posição selecionada, utilize o metodo .insert(0, x) # 0 é a posição e x é o valor, nesse caso, os outros valores da lista iriam "an...
false