blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9439673b825f15f9458670a3ad9eae3c619a6504
dcherry123/CDPythonWorkRepository
/Training/6 Dictionary/6-6_dictionary_polling.py
871
3.796875
4
# 6-6. Polling: Use the code in favorite_languages.py (page 104). # Make a list of people who should take the favorite languages poll. Include some names that are already in the # dictionary and some that are not. # Loop through the list of people who should take the poll. If they have already taken the poll, print a m...
d6f945717397e3e1a366e67aa84c2b24be7f521b
dcherry123/CDPythonWorkRepository
/Training/3 List/3-1_list_Names.py
240
4.625
5
# 3-1. Names: Store the names of a few of your friends in a list called names. Print # each persons name by accessing each element in the list one at a time. names_list = 'Peter', 'Jack', 'Eric' for name in names_list: print (name)
bdb7bd836ffba534e4b69a9e57bb27686ea3a65e
dcherry123/CDPythonWorkRepository
/Training/7 User Input and while Loops/7-1_UserInputAndWhileLoop_Rental Car.py
354
4.0625
4
# Write a program that asks the user what kind of rental car they # would like. Print a message about that car, such as Let me see if I can find you a Subaru. car_type = "Welcome to online car rental site!" car_type += "\nWhich model you are looking for? " car_name = raw_input(car_type) print("\nLet me see if I can ...
0a809d37bfbdc8a053016fd11cc25ef1f3f4d4bb
dcherry123/CDPythonWorkRepository
/Training/4 Working with Li sts/4-2_lists_animals.py
1,882
4.8125
5
# 4-2. Animals: Think of at least three different animals that have a common characteristic. # Store the names of these animals in a list, and then use a for loop to print out the name of each animal. # Modify your program to print a statement about each animal, such as A dog would make a great pet. # Add a line at the...
9b01b675b6181c096bf7d832c47c4e7a13846d73
dcherry123/CDPythonWorkRepository
/Training/XML Misc Exercise/01 XML Pursing.py
1,397
3.515625
4
from xml.etree import ElementTree # import os # from xml.etree import ElementTree # # file_name = 'BookData1.xml' # #full_file = os.path.abspath(os.path.join('Data', file_name)) # #print(full_file) # # dom = ElementTree.parse(file_name) # # print ("Title of the books available in the cata...
64c1710857268c0a32e3f17405b11adcff716960
Kayannsoarez/Generation_Random-Variables
/GaussianDistribution.py
1,780
3.671875
4
import random import math import matplotlib.pyplot as plt # inicialização das listas de valores e números aleatórios valor = [] num = [] cdf = [] # parâmetros da distribuição normal u = 2 g = 3 pi = math.pi soma = 0 total = 0 n = 10000 # Gerador de números aleatórios a partir de uma distribuição normal padrão def Ga...
5104e227a03bedc88f89d665f3475d27c4c48db7
linhlpv/Road-VIdeo-Highlighter
/compute_threshold.py
3,835
3.546875
4
import numpy as np import cv2 def abs_sobel_threshold(img, ora='x', threshold=(20, 100)): """ Apply sobel function in x or y and then takes abs value and apply a threshold """ if ora == 'x': abs_sobel = np.absolute(cv2.Sobel(img, cv2.CV_64F, 1, 0)) else: abs_sobel = np.absolut...
dfd3d8e6d03c61f6bb5b299528017ca42a13e8e6
codelurker/Game-of-Evolution
/game_of_evolution.py
7,371
3.859375
4
#Game of Evolution #Patrick Morgan #2011.01.29 from random import randint, choice, shuffle, random #initial settings board_size = 30 #default=15 max_level = 3 #default=3 creature_names = ['vegetation', 'herbivore', 'carnivore'] phase_order = ['consume','spawn','die'] #default = consume, spawn, die evolve_chance = .02...
1cecfeddc2499950d7d7635899fbe4a559e650cb
brazhenko/ft_ssl
/tests/des_tests/generate_random_password.py
300
3.578125
4
#! /usr/local/bin/python3 import random import string KEY_LEN=random.randint(1, 25) print(''.join(random.choices(string.ascii_lowercase + string.ascii_uppercase + string.digits, k=KEY_LEN))) #print(''.join(random.choices(string.ascii_lowercase + string.ascii_uppercase + string.digits, k=KEY_LEN)))
b3f20dfe4eeb6baf74ed9d0c21f419c2eb5990b8
1nsaNeDynamic/algorithms
/getOccurrence/main.py
239
3.71875
4
# Algorithm to find the occurence of a digit in a given range toFind = '1' rawData = [] count = 0 for x in range(1, 101): rawData.append(str(x)) for y in rawData: if toFind in y: count += y.count(toFind) print(count)
955e6733b75676d84d318145154aa8e1b9d87d75
melijov/course_python_generator
/convert_to_integer.py
445
4.1875
4
def convert_to_integer(numbers): integers = (int(n) for n in numbers) return integers # returns generator def unit_test(): #list of mixed format numbers numbers = [7, 22, 4.5, 99.7, '3', '5'] print(f'Calling "convert_to_integer(numbers)" returns: {convert_to_integer(numbers)}') print(f'Callin...
da09a48cb4e0cfc7d338c5ede2319ac9626a2746
rwerthman/citc
/3.3/python/stack_of_plates.py
1,590
3.90625
4
class SetOfStacks(object): def __init__(self, top, threshold): """ Initialize with a top stack """ self.top = top self.threshold = threshold def push(self, n): if self.top.size() >= self.threshold: # Create a new stack new_stack = Stack(n) n...
8ba5d71fa5a61018b25041fef75904539d709879
prashik856/Code
/py/prog68.py
281
3.671875
4
class Rectangle: def __init__(self,length,width): self.length=length self.width=width def cal_area(self): return self.length*self.width @classmethod def new_sq(cls,side_length): return cls(side_length,side_length) square=Rectangle.new_sq(6) print(square.cal_area())
559fa616d6b348d2ea9640418039ffb3f1af717e
prashik856/Code
/py/prog39.py
81
3.71875
4
def multiply(x,y): return x*y a=7 b=9 operation=multiply print(operation(a,b))
285752447c63fd072ab6bb1d414da499195e4f65
prashik856/Code
/py/calculator.py
1,078
4.375
4
while True: print('Options') print('Enter \'add\' to add two numbers') print('Enter \'subtract\' to subtract two numbers') print('Enter \'multiply\' to multiply two numbers') print('Enter \'divide\' to divide two numbers') print('Enter \'quit\' to exit') user_input=input(':') if user_input=='quit': break eli...
99e1ee50339249c7877f6dbdf453c7f73d5a4418
prashik856/Code
/py/prog4.py
46
3.59375
4
x=4 if x==4: print('yes') else: print('no')
d710988c4521c01b5f7c4f25af3858f6a24718ad
YuedaLin/python
/类和对象/01_体验类和对象.py
297
3.5625
4
# 1.定义洗衣机类 class Washer(): def wash(self): #这个函数即实例方法或对象方法 print("能洗衣服") # 2.创建对象 haier = Washer() # 3.验证结果 # 打印haier对象 print(haier) # 使用wash功能--实例方法/对象方法--对象名.wash() haier.wash()
16b55c452f711312e8eccba48b37165994deddbd
YuedaLin/python
/其他/03_修改类属性.py
351
3.9375
4
# 类属性只能通过类对象修改 # 1.定义类,定义类属性 class Dog(): tooth = 10 # 2.创建对象 wangcai = Dog() xiaohei = Dog() # 3.通过类修改属性 # Dog.tooth = 12 # print(Dog.tooth) # print(xiaohei.tooth) # 4.测试通过对象修改属性 xiaohei.tooth = 20 print(Dog.tooth) print(xiaohei.tooth) print((wangcai.tooth))
9d2fc4adb73bb4b89f3018afbfb44eb5909cd142
YuedaLin/python
/继承/03_多继承.py
709
4.125
4
# 多继承就是一个类同时继承了多个父类 # 注意:当一个类同时继承多个类时,默认使用第一个父类的同名属性和方法 # 1.师傅类 class Master(): def __init__(self): self.kongfu = '[古法煎饼果子配方]' def make_cake(self): print(f'运用{self.kongfu}制作煎饼果子') # 定义学习类 class School(): def __init__(self): self.kongfu = '[学校的煎饼果子配方]' def make_cake(self): ...
d116373d28571962a7378a84485bad8b5d40cd12
AryanSahu/PythonSnippets
/StringManipulation.py
853
4.25
4
a = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.""" print(a) #Slicing b = "Hello, World!" print(b[2:5]) #Negative Slicing b = "Hello, World!" print(b[-5:-2]) #Length a = "Hello, World!" print(len(a)) #The strip() method removes any...
54239642b3212ea5c75ff2e60f07b6cea5b8ba5e
Ganeshpy3/collegedatabase
/collegedatabase.py
5,423
3.75
4
import mysql.connector import sys host=input("Enter your host") user=input("Enter your mysql username") password=input("Enter your mysql password") try: db=mysql.connector.connect(host=host,user=user,passwd=password) cur = db.cursor() except Exception: print("please enter correct username pasword...
e297bbedfde182c9a4a5d972a929cec928560d23
Szyszuniec/100-zada-
/zadanie 7.py
369
4
4
# Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. # The element value in the i-th row and j-th column of the array should be i*j. X = int(input("podaj wartość X: ")) Y = int(input("podaj wartość Y: ")) lista = [] for j in range(Y): for i in range(X): lista.ap...
76d8123542ea777cf89a8eaa661939d2354fef4e
Szyszuniec/100-zada-
/zadanie 13 i 14.py
739
3.859375
4
# Write a program that accepts a sentence and calculate the number of letters and digits. # Write a program that accepts a sentence and calculate the number of upper case letters and lower case letters. dane = input("podaj zdanie zawierające liczby i litery: ") litery = 0 liczby = 0 wielkie = 0 małe = 0 for x ...
8481916ee2812ad6e3f32f0f4ea0789cc5d39cc5
Taylor4484/CS-313E---Elements-of-Software-Design
/Assignment 1/solution_hw1.py
2,186
4.21875
4
"""Given an input word file, select for output exactly those words meeting a given filtering criterion. For example, words of length k, words containing a "q", words that are palindromes, etc.""" def filter( word, f ): """This returns true or false depending on whether or not the word passes the filter....
d33fcb0c95583fd275c6b0a447decfb97849efbd
Taylor4484/CS-313E---Elements-of-Software-Design
/Assignment 2/Assignment2a.py
1,405
3.984375
4
# File: Assignment2a.py # # Description: Draws a house with one door, two windows and a # chimney using Turtle Graphics. # # Student's Name: Micheal Taylor McCaslin # # Student's UT EID: MTM2275 # # Course Name: CS 313E # # Date Created: 9/22/12 # # Date Last Modified: 9/24/12 from turtle import * fro...
aa5bc12206c77665479028d9afc94319341391b1
Taylor4484/CS-313E---Elements-of-Software-Design
/Assignment 0/Assignment0.py
4,849
4.15625
4
# File: Assignment0.py # # Description: Caesar Cipher Encoder. Takes a user inputted string, # shows it in uppercase, lowercase, counts the letter occurrence, # prints using the caesar cipher (1 letter) and then waits for # another input from the user. The user can type "exit" to end the # the program, where a thank yo...
ad9958d1b9e4bb7c0295cf0f2d95c3dbf40d1587
L00163466/week3
/data_sets/q2.py
1,030
3.5
4
""" # # File : q2 # Created : 08/10/21 11:00 AM # Author : R. Aravind # Version : v1.0.0 # Licencing : (C) 2021 Aravind Rajesh Kanna, LYIT Available under GNU Public License (GPL) # Credits : # Maintainer : # Description : Lotto players # """ import random if __name__ == '__...
fe5469ab7a85f754c895cd7214801d8d9e3ee9b2
SabbirAhamed007/object_introspection
/object_introspection.py
2,040
4.0625
4
class School: no_of_teacher = 200 no_of_student = 1500 no_of_classroom = 50 class Teacher: def __init__(self, t_fname, t_lname, t_salary, t_subject, t_dob): self.t_fname = t_fname self.t_lname = t_lname self.t_salary = t_salary self.t_subject = t_subject self.t_...
831eb50596066a0e0a128fe5de2b57bcad1bfad0
sinindra/algorithm_problem
/codility/CountDiv.py
258
3.546875
4
#!/usr/bin/python def solution(A, B, K): mb = int(B // K) ma = int(A // K) if A % K == 0: ans = mb - ma + 1 else: ans = mb - ma return ans A = 1 B = 2 K = 3 if __name__ == "__main__": print(solution(A, B, K))
09867296f7d97267a09cd600e353f7e0b1c9cdec
sinindra/algorithm_problem
/samsung/D4/7701_염라대왕의 이름 정렬.py
272
3.609375
4
T = int(input()) for test_case in range(1, T + 1): N = int(input()) nameList = {input(): 1 for _ in range(N)} sortedName = sorted(nameList.keys(), key = lambda x : (len(x), x)) print("#{}".format(test_case)) for name in sortedName: print(name)
fa1d7142fdc341dd001a7f8a15c87f43ebd4f74d
HomeAccessTracker/HACTrack--GPA-Calculator
/grade_scraper.py
2,804
3.59375
4
import bs4 as bs import urllib #import the connection class which takes care of the post request from connection import connect #finds the total loss of points for the class def get_minus(max_grade, grade): lost_points = (100-grade)*.1 if max_grade-lost_points < 0: return max_grade else: r...
a304e8a92579ebc145e7a5f25835b4e8a2a0c317
jacindaz/data_structures_and_algos
/week5_dynamic_programming1/4_longest_common_subsequence_of_two_sequences/lcs2_notes.py
3,296
3.65625
4
#Uses python3 import sys def construct_grid(sequence1, sequence2): grid = [] coordinates = [] # SMALLEST UNIT OF WORK # JUST MAKE GRID WORK, SEE LATER IF IT WORKS OR HOW TO OPTIMIZE for index1, number1 in enumerate(sequence1): row = [] for index2, number2 in enumerate(sequence2):...
f87fb0e7cbdd689372f2c7734aa6c877f54e2865
jacindaz/data_structures_and_algos
/week3_greedy_algorithms/1_money_change/change.py
340
3.734375
4
# Uses python3 import sys def get_change(money): total_coins = 0 for coin in [10, 5, 1]: if money/coin >= 1: num_tens = money//coin total_coins += num_tens money -= num_tens*coin return total_coins if __name__ == '__main__': m = int(sys.stdin.read()) p...
364c4d7ed2a0732c7340f1d5434e0d57d793fa4b
jacindaz/data_structures_and_algos
/week2_algorithmic_warmup/2_last_digit_of_fibonacci_number/fibonacci_last_digit.py
559
3.75
4
# Uses python3 import sys def get_fibonacci_last_digit_naive(n): if n <= 1: return n previous = 0 current = 1 for _ in range(n - 1): previous, current = current, previous + current return current % 10 def better_solution(n): results = [1] index = 1 for x in range(2...
c39567c5e13580dedefe084098f67192eeb7c706
Aazh/prog_alused
/3/yl2.py
208
3.65625
4
ringide_arv = int(input("Sisesta ringide arv: ")) porgand_arv = 0 i = 0 while i < ringide_arv: i += 1 if i % 2 == 0: porgand_arv += i print("Porgandite koguarv on " + str(porgand_arv) + ".")
acee2300fd1f7091753196f70d7434d99f616392
momina2/CS261F21PID25
/Driver.py
1,336
3.5625
4
import pandas as pd class SongsList(): def __init__(self, name, album, genre, artist, likes, timesPlayed, duration, comment, year): self.name = name self.album = album self.genre = genre self.artist = artist self.likes = likes self.timesPlayed = timesPlayed self.du...
8ad29476b8c7c96007af259031f538a5a3b310c1
kiribon4ik/Basics_python
/Lesson_8/Task_3.py
743
3.515625
4
class IntError(Exception): def __init__(self, txt=None): self.txt = txt @staticmethod def validator(some_el): try: some_num = int(some_el) return some_num except ValueError: print(IntError('Вы ввели не число!')) input_data = input('Введите число...
ff0a9ccc5cdff874a30345d79f4d9248bc1278d7
kiribon4ik/Basics_python
/Lesson_8/Task_7.py
436
3.859375
4
class ComplexNumber: def __init__(self, number): self.number = number def __add__(self, other): return self.number + other.number def __mul__(self, other): return self.number * other.number number_1 = complex(3, 2) number_2 = complex(4, 5) complex_num_1 = ComplexNumber(number_1)...
19dd4eca249cc4a316e6227b2e2adb219ab12a6e
kiribon4ik/Basics_python
/Lesson_6/Task_2.py
398
3.5
4
class Road: def __init__(self, length, width): self._length = length self._width = width def mass(self): mass = (self._length * self._width * 25 * 5) / 1000 return print( f'Длина дороги - {self._length} м, ширина - {self._width} м, масса асфальта - {mass} тонн') ro...
a18610da03fda790e051bedf4728f92ce6b9cd43
akira2nd/CODES
/Algoritmos e Lógica de Programação/lista 5 akira/questao02.py
389
3.8125
4
''' Questão B. Quantas vezes o trecho de pseudocódigo seguinte imprime 'oi'? (obs: na nossa pseudo-linguagem, o laço inclui os extremos, ou seja, 1 até 4 significa 1, 2, 3, 4.) para i = 1 até 9 se i != 3, então para j = 1 até 6 imprime 'oi' Resposta: 48 ''' x = 0 for i in range(9): if i != 3: for j in r...
d76d1134724e53955c252951b523137869d50d06
akira2nd/CODES
/Algoritmos e Lógica de Programação/desafio lista 3/questao04.py
780
3.71875
4
''' 4. Dado um número inteiro positivo, determine a sua decomposição em fatores primos calculando também a multiplicidade de cada fator. ''' print('Decomposição em fatores primos') n = int(input('Digite um número: ')) primo = [] a = 2 b = n while b != 1: if b%a == 0 and b!=a: b -= 1 elif b == a: ...
3c965aa7d4cbc4533b328864782887113ec31efa
akira2nd/CODES
/Algoritmos e Lógica de Programação/desafio lista 3/questao01.py
542
4.1875
4
''' 1. Dizemos que um número natural é triangular se ele é produto de três números naturais consecutivos. Exemplo: 120 é triangular, pois 4.5.6 = 120. Dado um inteiro não-negativo n, verificar se n é triangular. ''' print('Verificar se o número é triangular') numero = int(input('Digite um número: ')) x = 1 resp = 'O...
2ddb03fe7fae8a7c46bc7eafa0cca2f06bb64010
akira2nd/CODES
/Algoritmos e Lógica de Programação/paradecimal.py
662
3.625
4
print ("Lembre-se, octal vai de 0 a 7, binário 0 e 1, hexa de 0 a F") base = int(input("Base: ")) num = str(input("Número: ")) resultado = 0 n = len(num)-1 for x in num: if x in "0123456789": x = int(x) if x == "A" or x == "a": x = 10 elif x == "B" or x == "b": x = 11 e...
50f47f92b2f0b8553afb8dfd963ac160dbe79bdd
akira2nd/CODES
/Algoritmos e Lógica de Programação/lista 1 akira/questao08.py
277
4.25
4
#8) Faça agora o contrário, de Fahrenheit para Celsius print('Converter Fahrenheit(ºF) para Celsius(ºC)') print() tempF = float(input('Digite a temperatura e graus Fahrenheit:')) celsius = (tempF - 32)/1.8 print('A temperatura em graus Celsius é de: %.2fºC' %celsius)
4479ad19dd609a62e86bb4a3e22f238aeee10329
akira2nd/CODES
/Algoritmos e Lógica de Programação/lista 1 akira/questao07.py
316
4.25
4
#7) Converta uma temperatura digitada em Celsius para Fahrenheit. # F = 9*C/5 + 32 print('Converter temperatura Celsius(ºC) para Fahrenheit(ºF)') print() tempC = float(input('Digite a temperatura em graus Celsius: ')) fahr = 9* tempC /5+32 print('A temperatura convertida em Fahrenheit é de %.2f°F' % fahr)
373692048e2230a3b4bf67be62aa0ff381949223
DanielNghiem/Python-Files
/LMSR_main.py
3,586
3.5
4
from math import exp, log, floor from collections import defaultdict sensitivity=30 NO = 0 YES = 1 # addDicts: {key: value}, {key:value} -> {key:value} # output a new dictionary which contains all the keys in both # input dictionaries, and adds together the values when a key # is in both input dictionaries # # WARN...
9c403bba7398328e13a392ce3e8195e0b6cc72ee
laiqiqi/stm32-servomotor
/servocalc.py
931
3.53125
4
def head(): print("=============") print("TIMER REGISTERS CALCULATOR FOR STM32") print("This application is for calculating the PSC and ARR registers of the PWM generation timer for servomotor") print("by Filipe Chagas") print("v1.0.0") print("=============") def main(): apb_freq = int(inpu...
257f01af2442f2ffacc35d4fe2672eff27bb00b3
linvieson/json-navigator
/json_navigator.py
2,909
4.4375
4
''' This module gets the json file from the user. It asks a user, which part of the json object he or she wants to see and outputs its value. ''' import json def get_json() -> dict: ''' Make a get request on a server. Return json object as a python dictionary. ''' path = input('Enter a path to json fil...
b082ec3186ff4d41776a6f534f87d5b4f1d72bbd
kckotcherlakota/aialgo
/1Simple Linear Regression/simple.py
908
3.71875
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset = pd.read_csv('Salary_Data.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 1].values from sklearn.cross_validation import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 1/3, random...
414cb0c60ae51dbd56e33f370e1691d1bd564faa
4fuss/algorytmy
/algos/mergesort.py
646
4.25
4
# -*- coding: utf-8 -*- def mergesort(list): len_list = len(list) if len_list < 2: return list middle = len_list / 2 left = mergesort(list[:middle]) right = mergesort(list[middle:]) return merge(left, right) def merge(list_a, list_b): result = [] i, j = 0, 0 while len(lis...
7b4e5f29b9085ab97883b16c1613181619b3aeb5
gaoyaxing24/playPro
/str-01/str-01.py
554
3.984375
4
#!/usr/bin/env python # coding: utf-8 from __future__ import print_function """ Created by: Arthur - 黑小帅 Created on: 2016-10-23 str-01 逆转字符串——输入一个字符串,将其逆转并输出。[x] """ char = 'Arthur' # 方法1 python中最优, 最为推荐 _char = char[::-1] print(_char) # 方法2 因为python list的特性, 此方法是效率最低的. tmp = [] for el in char: tmp.i...
9cc58577d11803edaae10b6f84e115e4b273ed02
AlexALima/trabalho-4-cpd
/Lab_4 - Python/Lab_4_End_Fechado.py
3,050
3.59375
4
import math # Tamanho da tabela (modifique aqui para testar outros valores de M) # M = 200 # 200, 500 ou 1000 CHAVE = 0 DADO = 1 COLISAO = 0 TAXA_OCUPACAO = 1 def computeHash(chave): sPi = str(math.pi)*4 # Concatena a string da constante Pi 4 vezes para chegar aos 50 caracteres necessários en...
c62abf80556467b104957e3c653890488520364e
jsheng0722/Cpts_355_1
/pythonBasics2.py
4,992
4.21875
4
# Dictionaries: d1 = { 1 :'a', 2 :'b', 3 :'c'} d2 = {'a': 1 , 2 :'b', 3 :'c', 'c': 3 , 4 :'d'} d2['a'] d2[2] # d2[5] # error, if you try to get the value of a key that doesnt exist in the dictionary, it generates an error. d2.get(5) # no error. It returns none. d2.get(5,0) # no error. It returns the provided def...
2dc6afde537d17a3800d677efdcc45f496c7c74f
oskarmcd/kattis
/pet.py
411
3.53125
4
import sys list_of = [] for line in sys.stdin: list_of.append(line.strip().split(' ')) #print(list_of) highest = (0,0) current_highest = 0 iter = 1 for lists in list_of: counter = 0 for items in lists: counter += int(items) #print(counter) if counter > current_highest: current_highe...
a6fd8ea5778ad352e2b10359566bfad281ab2faf
Glengend/Refactoring
/hackershit.py
259
3.78125
4
for a in range(0, 10): for b in range(0, 9): for c in range(0 , 8): for d in range(0 , 7): print(str(a), end=' ') print(str(b), end =' ') print(str(c), end =' ')
03fcab98886e6606bb55b8deadeb183659b1c9bf
phamin2001/Texas-Hold-em-Poker
/tests/test_player.py
1,800
3.640625
4
import unittest from unittest.mock import MagicMock from poker.card import Card from poker.hand import Hand from poker.player import Player class PlayerTest(unittest.TestCase): def test_store_name_and_hand(self): hand = Hand() player = Player(name="Boris", hand=hand) self.assertEqual(play...
8a72c5504fd0ec377a3156df36dd9f283f0d2673
denis-beurive/agora
/src/agora/markdown_dumper.py
3,416
3.71875
4
import pandas as pd def data_top_btc_dumper(count: pd.DataFrame, average: pd.DataFrame, maximum: pd.DataFrame, total_sum: pd.DataFrame, reference: str, top_length: int = 10) -> str: """ Gene...
0073f3f9231419ff4d5af1f0ca536ef32fb5227d
denis-beurive/agora
/examples/boxplot.py
600
3.671875
4
from typing import List from random import randrange import pandas as pd import plotly.express as px def generate_abscissa() -> List[str]: result: List[str] = [] for x in range(200): result.append(chr(65 + randrange(25))) result.sort() return result def generate_ordinate() -> List[int]: ...
47396ec0286f547831af554b88312740c5f66a4e
vinuv296/luminar_python_programs
/pythonProject2/python collections/tuples/tuple_demo.py
338
3.578125
4
#tuples #tp=() #print(type(tp)) #tp1=tuple() # tp=(10,10.5,"vinu",True,10,1.5,True)#it support hetrogenous data # print(tp)#it support duplicate values # tp2=(1,2,3,4,5,6,7,8,8,1,8,40,9,3,11,1)#it preserves insertion order # print(tp2) # # tp[1]=100 # print(tp)#this will throw error ....tuples cannot be edited or up...
ea03023202d123ace9f50cec1a4ac15265ff3d47
vinuv296/luminar_python_programs
/Advanced_python/exception handling/pgm1.py
649
3.984375
4
# a=int(input("Enter a first number")) # b=int(input("Enter second number")) # try:#write code that might lead to exception # c=a/b # print(c) # except:#if exception occured except block will be called # print("Exception occured") #division by zero exception #Index out of bound exception #Invalid literal ...
546e2569548aa0ec5246295c275bb77aaf79e043
vinuv296/luminar_python_programs
/pythonProject2/flow_controls/looping/reverse number.py
104
3.71875
4
n=int(input("Enter a number")) s=0 num=0 while(n>0): s=n%10 num=s+num*10 n=n//10 print(num)
b69472ac661ab3272b781a99ff77cefaf8281df9
vinuv296/luminar_python_programs
/pythonProject2/flow_controls/second_largest_number.py
403
4.21875
4
num1=int(input("Enter 1st num")) num2=int(input("Enter 2nd num")) num3=int(input("Enter 3rd num")) if(num1>num2 & num1>num3): if(num2>num3): print(num2,"is second largest number") else: print(num3,"is second largest number") elif(num2>num1 & num2>num3): if(num1>num3): print(num1, "is...
05d8fc6b77509615f26a152266f65410870a400e
vinuv296/luminar_python_programs
/Advanced_python/work1.py
297
3.578125
4
class Employee: def __init__(self,name,age): self.n=name self.a=age def printv(self): print("name",self.n) print('age',self.a) f=open("student",'r') for l in f: data=l.split(",") name=data[0] age=data[1] ob=Employee(name,age) ob.printv()
2121f494399a4cfc1f0cdf840c0567e64cf3bd64
vinuv296/luminar_python_programs
/pythonProject2/flow_controls/looping/lower limit to upper limit.py
113
3.703125
4
n1=int(input("Enter a lower limit")) n2=int(input("Enter a upper limit")) while(n1<=n2): print(n1) n1+=1
b2f0c2e117c94d07ae148c1eaef20ecebb489272
vinuv296/luminar_python_programs
/pythonProject2/functions/sum_of_n_number.py
150
4.125
4
def sum_n_num(): n=int(input("Enter a number")) sum=0 for i in range(1,n+1): sum+=i print("sum of n numbers",sum) sum_n_num()
2d56d32ffd19a1ffd7edf4de5d5e623eef712eed
vinuv296/luminar_python_programs
/Advanced_python/test/pgm3.py
373
3.59375
4
class Book: def __init__(self,Library_name,book_name,author,pages): self.L_name=Library_name self.b_name=book_name self.author=author self.page=pages def printdetails(self): print(self.L_name) print(self.b_name) print(self.author) print(self.page) ...
45c677c4cdc6ecd5fb7a6ec08d1ea059fffe0034
vinuv296/luminar_python_programs
/pythonProject2/flow_controls/check_postive_or_negative.py
140
4.09375
4
num=int(input("Enter the number")) if(num>0): print("Postive number") elif(num<0): print("Negative number") else: print("Zero-")
3e15e018f1b600b198e76df97b545a9f79b91c72
vinuv296/luminar_python_programs
/Advanced_python/variable_argument/pgm1.py
1,021
3.578125
4
def print_person_details(**data): print(data) print_person_details(name="vinu",birthpalce="kottayam",workplace="ernakulam") def add(*args): sum=0 for num in args: sum+=sum return sum res=add(10,20,3,5,56,80) print(res) #............................................................... mployee={...
555d0b02838e963367448080e2d29081c3ff0359
meierjan/algorithm-design
/src/ueb/a/aufg05_merge.py
356
3.703125
4
def merge(a,b): a_i, b_i = 0,0 result_list = [] while a_i != len(a) and b_i != len(b): if(a[a_i]<=b[b_i]): result_list.append(a[a_i]) a_i += 1 elif(b[b_i]<a[a_i]): result_list.append(b[b_i]) b_i += 1 result_list += a[a_i:] result_lis...
58da687d232723a5c8a4375988614c2ca874e94a
meierjan/algorithm-design
/src/ueb/b/aufg09_bfs_queue.py
634
3.65625
4
from collections import deque def bfs_queue(G,s): # empty parent array parent = [None for _ in G] # is node x already reached? # (without: cant say if startnode or not reached) reached = [False for _ in G] # only start vertex is reached reached_v = {s} # add start vertex to deque q=...
a5ce3d6b7ccdf886934055ad38edb4e9bd7e4627
Stefan-H-H/Othello
/othello_game_starter/game_controller.py
10,893
3.578125
4
import re import os class GameController: """Maintains the state of the game.""" def __init__(self, WIDTH, HEIGHT, player, ai, board): self.WIDTH = WIDTH self.HEIGHT = HEIGHT self.player = player # Player object self.ai = ai # AI object self.board = board # Board obj...
907fb3cd21163ae0e0d4a24a63935b460699148e
sidharth6323/sprint-game
/game.py
343
3.5625
4
import msvcrt import time finish=10 count=0 print "press enter key to get started!" raw_input() s_time=time.time() while(1): key=msvcrt.getch() if key=='\xe0': count=count+1 print "-->", if count==finish: break time_elapsed=time.time()-s_time print "congrats you have finished the game" print "time taken ...
cfa9ec898119479a2820254d412002f13f455b71
menhuan/notes
/code/python/python_study/six/filter.py
705
3.765625
4
result = filter(lambda x: x > 5, [1, 2, 3, 6, 7, 8]) print(result) print(list(result)) result = filter(lambda x, y: x > y, [1, 2, 3, 5, 6, 7], [2, 3, 1, 4, 7]) print(list(result)) value = filter(None,[1,2,3,4,5]) print(list(value)) from functools import reduce result = reduce(lambda x,y:x*y,[1,2,3,4,5]) print(r...
edcb5eb4b44d1ed193cc867399ea04c607c5f21c
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Final-Exam/Final-Exam-Preparation/Final-Exam-09-August-2020/03_plant_discovery.py
1,760
3.734375
4
number_of_plants = int(input()) plants_data = {} for _ in range(number_of_plants): [plant, rarity] = input().split("<->") rarity = int(rarity) if plant not in plants_data: plants_data[plant] = {"rarity": rarity, "rating": []} else: plants_data[plant]["rarity"] += rarity while True: ...
62b740aa4c25dad40c5c3bc627cf7e8a355b03e8
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/BasicSyntax-ConditionalStatements/BasicSyntax-ConditionalStatements-Loops-Lab/05_patterns.py
139
3.640625
4
num = int(input()) for row_pos in range(1, num+1): print('*' * row_pos) for row_neg in range(num-1, 0, -1): print('*' * row_neg)
9d00c95688fbec10d5e08f2a83db7474a1c91b7c
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Dictionaries/Dictionaries-Exercise/09_force_book.py
1,429
3.578125
4
def add_user(forces_dict, side_to_join, user_to_add): for side, users in forces_dict.items(): if user_to_add in users: return forces_dict if side_to_join not in forces_dict: forces_dict[side_to_join] = [] forces_dict[side_to_join].append(user_to_add) else: if user...
6c6474fa900a931f51c2364bf0ba78a9edd896a8
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Functions/Functions-More-Exercise/01_data_types.py
295
3.875
4
data_type = input() data_input = input() def data_types(type, data): if type == "int": data = int(data) * 2 elif type == "real": data = f"{float(data) * 1.5:.2f}" elif type == "string": data = f"${data}$" print(data) data_types(data_type, data_input)
54f2396341d3fc16806ccd6fffbdd4981720d7f7
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/DataTypes-And-Variables/DataTypes-And-Variables-Exercise/01_integer_operations.py
148
3.625
4
num_1 = int(input()) num_2 = int(input()) num_3 = int(input()) num_4 = int(input()) result = (int((num_1 + num_2) / num_3) * num_4) print(result)
cb0059f031c583f0d9d182f1233d535cbd2cfe81
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Final-Exam/Final-Exam-Preparation/Final-Exam-15-August-2020/01_the_imitation_game.py
1,071
3.953125
4
encrypted_msg = input() def move(msg, num_ch): moved_msg, left_msg = msg[:num_ch], msg[num_ch:] result = left_msg+moved_msg return result def insert(msg, i, val): msg_before, msg_after = msg[:i], msg[i:] result = msg_before+val+msg_after return result def change_all(msg, sub_s, text): ...
ea73eed587a24d249e905279a34cbf1958c81e98
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/DataTypes-And-Variables/DataTypes-And-Variables-Exercise/04_sum_of_chars.py
148
4.0625
4
num_chars = int(input()) result = 0 for i in range(num_chars): letter = input() result += ord(letter) print(f'The sum equals: {result}')
f21fc56caf7b090c4137e525bbd9945f6ad511fd
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Dictionaries/Dictionaries-Exercise/10_softuni_exam_results.py
1,078
3.921875
4
exam_languages = {} exam_results = {} while True: command = input() if command == "exam finished": break exam_data = command.split("-") if len(exam_data) == 3: [user, language, points] = exam_data points = int(points) if user not in exam_results: exam_result...
4846d325b58f32a009730a9eae2b8e231e73dc77
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Lists-Advanced/Lists-Advanced-Lab/05_the_office.py
765
4
4
employee_happiness = [int(coefficient) for coefficient in input().split()] happiness_factor = int(input()) average_employee_happiness = sum([single_happiness * happiness_factor for single_happiness in employee_happiness]) / len(employee_happiness) happy_employee_list = [single_happin...
9461b10091fb0e1f6c106a8f854de1415cd4c8b3
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Functions/Functions-More-Exercise/05_multiplication_sign.py
964
4.09375
4
num1 = int(input()) num2 = int(input()) num3 = int(input()) def sign_check(n1, n2, n3): if n1 == 0 or n2 == 0 or n3 == 0: return "zero" elif (n1 > 0 and n2 > 0 and n3 > 0) or (n1 > 0 and n2 < 0 and n3 < 0) \ or (n1 < 0 and n2 > 0 and n3 < 0) or (n1 < 0 and n2 < 0 and n3 > 0): retur...
749fef9c51756f2554166f8324072aeab6813914
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/BasicSyntax-ConditionalStatements/BasicSyntax-ConditionalStatements-Loops-Exercise/06_next_happy_year.py
127
3.703125
4
year = int(input()) while True: year += 1 if len(str(year)) == len(set(str(year))): print(year) break
3ccb6120954bdde7ffa41f76d274fec01422f45e
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Dictionaries/Dictionaries-Exercise/03_legendary_farming.py
1,299
3.5
4
needed_items = {"shards": 0, "fragments": 0, "motes": 0} junk_items = {} stop_loop = False while True: if stop_loop: break items = input().lower().split(" ") for i in range(0, len(items), 2): key = items[i+1] val = int(items[i]) if key in needed_items: needed_ite...
796c25f7bcc893c88d60b73d80bd193588047023
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Functions/Functions-Exercise/02_add_and_subtract.py
305
3.921875
4
def add_sub(num_1, num_2, num_3): def add(num_1, num_2): result = num_1+num_2 return result def sub(): return add(num_1, num_2)-num_3 return sub() number_1 = int(input()) number_2 = int(input()) number_3 = int(input()) print(add_sub(number_1, number_2, number_3))
051b5a64edd4bc72215bcd4bc8dad4ceb6b1be06
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Text-Processing/Text-Processing-Exercise/07_string_explosion.py
1,028
3.625
4
# text = input() # field = text # bomb = 0 # count = 0 # # for el in range(len(text)): # if text[el] == ">": # count += 1 # if bomb > 0 and text[el].isdigit(): # field = field.replace(text[el], "", 1) # bomb -= 1 # elif text[el] == ">": # bomb += int(text[el+1]) # # [const, c...
cbc1b066a948d44f8472d45932f2a23e830b4000
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Functions/Functions-Exercise/03_characters_in_range.py
286
4.03125
4
def ascii_table(char_1, char_2): string_result = "" for i in range(char_1+1, char_2): string_result += chr(i) result = " ".join(string_result) return result character_1 = ord(input()) character_2 = ord(input()) print(ascii_table(character_1, character_2))
414eaa72dceb3663090896c0f2f5b17b1404872d
momchilantonov/SoftUni-Python-Fundamentals-September-2020
/Mid-Exam/Mid-Exam-Preparation/Mid-Exam-29-February-2020-Group1/02_mu_online.py
1,111
3.625
4
dungeon_rooms = input().split("|") initial_health = 100 initial_bitcoins = 0 room_counter = 0 is_alive = True for room in dungeon_rooms: [command, value] = room.split(" ") value = int(value) room_counter += 1 if command == "potion": needed_hp = 100-initial_health initial_health += value...
f64853d092fa5a96e23c56ffc81324f491675b6d
githubkannadhasan/kanna
/even-inlist.py
207
3.578125
4
def ListinEven(list1): list2 =[] for i in list1: if i%2 ==0: list2.append(i) print(list2) list1 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] ListinEven(list1)
e8db8f311af79706b8c8ff39ff2c1f3dc1407239
jacoblurye/lottery
/src/student.py
4,822
3.734375
4
"""Implements the student class """ from random import random, randint, sample from collections import defaultdict from numpy.random import normal import constants as const class Student(object): """ A student with course preferences. """ def __init__(self, year, courses, noise=const.NOISE): ...
23a92b379ab48439a3e64414b712ee2cb9918baf
nicolasuarez/Procesamiento-Distribuido-con-Map-Reduce
/reduce4.py
457
3.65625
4
import sys def reduce(lines): ObjContadorcito = [] for line in lines: line = line.split(",") city = line[0] price = line[1] year = line[2] if year =='2015' and city =='stamford': ObjContadorcito.append(price) ObjContadorcito.sort() return ObjContadorci...
787795334cb5e603899a4fda42e6a6f46dc5db63
weixinfree/leetcode
/setMatrixZeros.py
909
3.734375
4
class Solution: def setZeroes(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ if not matrix: return height = len(matrix) width = len(matrix[0]) def x_zeros(x): ...
162221a6819e18ffd53eaaf04b235002b65ca8d7
weixinfree/leetcode
/compareVersion.py
823
3.515625
4
class Solution: def compareVersion(self, version1, version2): """ :type version1: str :type version2: str :rtype: int """ v1stack = version1.split('.') v2stack = version2.split('.') while v1stack and v2stack: v1 = int(v1stack.pop(...
34990d7fe232971619cf79c4cc65ac27a85d805b
weixinfree/leetcode
/lengthOfLongestSubstring.py
718
3.75
4
class Solution: def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ if not s: return 0 def calcMaxLen(index): r = set() for i, c in enumerate(s[index:]): if c in r: return i ...
d0735a9e3f455434841cb5470444aee1e6fdbdf1
weixinfree/leetcode
/removeDuplicates.py
560
3.625
4
from typing import List class Solution: def removeDuplicates(self, nums: List[int]): """ :type nums: List[int] :rtype: int """ last = None for index, num in enumerate(nums): if num == last: nums[index] = None last = num ...
c978bfcff941958b6e173e4658d8eb6cc79b777d
weixinfree/leetcode
/generateParenthesis.py
1,355
3.953125
4
""" 给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。 例如,给出 n = 3,生成结果为: [ "((()))", "(()())", "(())()", "()(())", "()()()" ] """ class Solution(object): def generateParenthesis(self, n): """ :type n: int :rtype: List[str] """ n *= 2 def all(c, inde...
69d26531045aad3c6e167f9cb69844f6be3c1334
guyavrah1986/learnPython
/learnPython/questions/numOfBsToAddToStringSoNoTwoBsAreAttached.py
3,949
4
4
''' Given a string s that might contain "b"'s, find the maximum number of "b"'s that can be added to the string so that there won't be more than two consecutive b's in the final string ''' def get_num_of_b_that_can_be_added_with_having_three_consecutive(orig_str: str) -> int: """ Assumptions: a) orig_str ...
f35acbb33b5e3bfb5ab3812d49b1e85e1188d86f
guyavrah1986/learnPython
/learnPython/trainingNotes/exceptionHandling.py
1,581
4.15625
4
# The motivation behind exception handling is to be able to "gaurentee" that the # program will always finish "successfully". Note that it does not mean that it indeed # performed what it should have done correctly, but nevertheless, it indicated "back" to # it's "invoker" that it finished without any error (i.e. - its...
75236d47184fbbd6ab059e3682ea2557ea64f588
guyavrah1986/learnPython
/learnPython/trainingNotes/functionsDemo.py
2,032
4.53125
5
# this is an example for the "named argument" concept in Python. In case there are # several default arguments, then upon a call to it, it is possible to send only # some (one or more) specific values. # Note that this is also true for functions that do not have default arguments at all # --> this is usually very bene...