blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
bd2cb268a88a781f2c8c89acca8ea74a243674e9
d4n1elchen/machine-learning-study
/data-crawler/ptt/ptt-bbs-list-crawler/tree.py
693
3.671875
4
import csv tree = {} with open("board_list.csv", newline="") as csvfile: board_reader = csv.reader(csvfile, delimiter=',') next(board_reader) for row in board_reader: cls = row[0] board = row[1] clses = cls.split(">") N = len(clses) curr = tree for i, cls in...
553e6ef6ee6925807081e96f422988b826d8b819
LLx2/PythonBasics
/wordCnt.py
1,163
3.53125
4
#title = wrdCnt #import file, count qty of words and provide frequency of each occurence for each word. #open file, handle edge cases: fname = raw_input('Enter File Name: ') if len(fname) == 0: fname = 'words.tggxt' try: fhand = open(fname) except: print 'This', fname, 'did not work.' quit() #work spac...
b1fa735d622a15cd393b4345453ce046d8e61e05
artohidi/ToolBoxPro_TelegramBot
/python_base_test.py
2,525
3.75
4
list_set = [] numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] parameters = ["+/-", "%", "÷", "✕", "-", "+", "=", "."] active_parameters = ["+/-", "✕", "+", "-", "÷", "."] deactivate_parameters = ["%", "="] output = '0' output_plus = '' output_minus = '' param = '' show_list = '' calculator_keyboard = "AC\t+/-\t%\t÷\n1\t2\t3\t...
0d5a7d8a5491df8f23a9086079cb2b43f5bdc8a7
yogesh220/java_codes
/paython1stprogarm.py
267
4.21875
4
num=int(input("enter a number")) factorial=1 if num<0: print("sorry factorial does not exist for negative number") elif num=0; print("the factorial of 0 is 1") else for i in range(1,num+1); factorial=factorial*i print("the factorial of",num,"is",factorial)
184157bd4dca1574f32bab6d7fc106891c4cb711
matthaeusheer/playground
/path_planning/path_planning/geometry.py
732
3.515625
4
def intersects(segment_1: list, segment_2: list) -> bool: """Assumes line segments are stored in the format [(x0,y0),(x1,y1)]""" dx0 = segment_1[1][0] - segment_1[0][0] dx1 = segment_2[1][0] - segment_2[0][0] dy0 = segment_1[1][1] - segment_1[0][1] dy1 = segment_2[1][1] - segment_2[0][1] p0 = dy...
fd8739a663a25612bdb58e468451b8b66c4c3774
yueya2354478715/Crawler-douban
/python基础/demo1.py
850
3.546875
4
# -*- codeing =utf-8 -*- # @Time:2020/12/7 10:26 # @Author:青 # @File:demo1.py # @Software:PyCharm import random import keyword # print(len(keyword.kwlist),keyword.kwlist) # print("hello,world") ''' # 格式化输出 age = 18 print("我今年 %d 岁" % age) print("我的名字是 %s\n我的国籍是 %s" % ("moon", "中国")) print("www", "baidu", "com", sep="...
71d6d9ba71c44674d7eb45d25a81b25f21ddf7b3
yueya2354478715/Crawler-douban
/python基础/demo4.py
3,569
4
4
# -*- codeing =utf-8 -*- # @Time:2020/12/7 19:45 # @Author:青 # @File:demo4.py # @Software:PyCharm # 列表list # 列表中元素类型可以不同,支持数字,字符串甚至是列表嵌套 # 列表索引值从0开始,-1为末尾的开始位置 # +拼接 *重复 ''' namelsit = [] # 空列表 namelsit = ["小张", "小李", "小王"] print(namelsit[1]) print(namelsit[2]) testlist = [1, "测试"] # 列表中可以存储混合类型 print(type(testli...
c881bb0e5391a3330136a2ccd40fed054f26a73e
HughesyDev/SpaceBar
/src/core/formatting/ascii_greeter.py
868
3.609375
4
import os import sys import time def greeter(text, pause): for word in text.split(): print("\n" + word, flush=True) # without flush=True it all prints at once. time.sleep(pause) def greeting_ascii_art(): print( """ _____ ____ / ____| ...
7cd0778bca19e41f857793a557e1a12e18d8d5bf
alex-i-git/LearnPython-Diploma-Project
/dbot.py.bak
6,690
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Simple Bot to reply to Telegram messages # This program is dedicated to the public domain under the CC0 license. """ This Bot uses the Updater class to handle the bot. First, a few callback functions are defined. Then, those functions are passed to the Dispatcher and r...
0b2d291c76632542b2bcc8dac1144be0956c6d8f
Melnychuk17/lab7
/7.6b.py
1,355
3.859375
4
# Задача. Вивести дані про книги, в яких кількість сторінок більше 150. Поля # структури: Автор, Кількість сторінок, Тираж, Рік видання. # Мельничук Олена Костянтинівна 122В while True: while True: try: x = int(input('Enter number of pages 1 book: ')) y = int(input('Enter number of ...
4becb70b24199405850645af4fa2cc92b5ea0f74
Bietola/problems
/codechef/ROBOGAME/python/main.py
437
3.640625
4
def todigit(c): return int(ord(c) - ord('0')) def solve(robofield): ln = None d = 0 for c in robofield: if c == '.': d += 1 else: if ln != None: if d - todigit(c) < ln: return "unsafe" d = 0 ln = todigit...
2ddd56d95e39abed0c81078ba665a7251b5b5abe
Bietola/problems
/custom/python/1/1/tmp.py
582
3.71875
4
from itertools import dropwhile from sortedcontainers import SortedSet print(list(dropwhile(lambda x: x < 3, [1, 2, 5, 6, 7]))) print(list(dropwhile(lambda x: x < 3, [1, 2]))) def hello(): n = 0 for n in range(1, 10): print(n) print(n + 2) i = iter([1, 2, 3]) next(i, 2) list(i) def drop(n, ...
4c16521e8c505d78fd2be7027e1d017a84f78a7b
eugenius1/cracking-the-coding-interview-py
/4_2_graphs.py
1,624
4
4
# Eusebius N. # 4.2 # Find out if a route exists between two nodes in a directed graph # a dictionary with keys matching nodes, and # each value is a list of nodes on a key node's outgoing edges # this requires unique, hashable node identifiers g = {9: [98, 96, 90], 0: [0], 1: [19, 12], 2: [2, 20], 12: [123, 1], 2...
8786acdd88cb9407501c86b4f819e7411870df6b
uvshrivass/Python
/py_datatypes.py
1,231
4.53125
5
###Program to convert a tuple to list and vice versa. tuple1 = ("a", "b", "c") list1 = list(tuple1) print("The tuple1 is: ", tuple1) print("The list1 is: ", list1) list2 = [1,2,3] tuple2 = tuple(list2) print("The list2 is: ", list2) print("The tuple2 is: ", tuple2) ###Program to perform difference, intersection & un...
a3937b92ab241210ce9172295fd572255fffd559
vishush1701/result-scraper
/main.py
1,188
3.5
4
'''author:vishwanath hiremath date:03/02/2020 summary:gets the data from the webpage of dr.ait results''' from bs4 import BeautifulSoup import requests import pandas as pn value = {'get_ry': '<enter the date as displayed in result page>', 'get_usn': '<usn>'} response = requests.post(url='http://results.dra...
fe511ca7175a93b7bdc0102210a113adb3b98f5c
rafiksh/data-structures-py
/k_lowest_element.py
433
3.671875
4
def FirstKelements(arr, k): size = len(arr) minHeap = [] for i in range(k): minHeap.append(arr[i]) for i in range(k, size): minHeap.sort() if minHeap[0] > arr[i]: continue else: minHeap.pop(0) minHeap.append(arr[i]) for i in min...
2fef5ada040bbcf3288bf105ff0ac9f7230b70fb
rafiksh/data-structures-py
/perfect_number.py
250
3.625
4
def perfect_number(number): if number <= 0: return False total = 0 for x in range(1, number): if number % x == 0: total += x return number == total if __name__ == '__main__': print(perfect_number(5))
01987c544816719f0556d63b36d706e4eedd1919
acassio11/py-jules
/gen_nml_defs/check_s.py
307
3.75
4
# -*- coding: utf-8 -*- """ #---> Created on Thu Jan 30 11:54:05 2020 #---> @author: Murilo Vianna """ #--- Check whether a string s exist in file f_path def check_s(f_path, s, has_s = False): with open(f_path, "rt") as f: if s in f.read(): has_s = True return has_s
69bd01044345892b55a025cce000a999ca6bf494
Aalukis1/Basic-Python-programming
/OOP3.py
1,536
3.859375
4
# def sum(a,b): # c=3 # d=4 # print(c+d) # sumlist("e","f") # print(len ("geek")) # print(len([1,2,3,7,9,1,0])) # username = input("enter the username ") # if len (username) > 10: # print("incorrect!") # def add(x,y,z=0): # return (x+y+z) # print(add(2,3)) # print(add(2,3,4)) # class Employee...
fe07ca7de12e690fcfd0a060b54ab19768dab14a
megannguyen6898/dataminingcourse
/practice1-monty hall.py
2,650
4.03125
4
import random #Write a function that is a door not having a prize (the host knows) and is not the player choice so it will be opened def open_non_prize_door(host, player_choice, num_doors): i = 0 while i == host or i == player_choice: i = (i+1)%num_doors return i #Write a function what happens if ...
f14cb506c7b924e22e9720a7e913e5272327de06
paola-rodrigues/JogoAdivinhacao
/adivinhacao.py
1,777
3.984375
4
import random def jogar(): print("**********************************") print('Bem-vindo ao Jogo de Adivinhação!') print("**********************************") print ("Estou pensando no número entre 0 e 20") numero_secreto = random.randrange(1,21) total_de_tentativas = 0 rodada ...
5fff6c22cde1625839ad8ce60da3643d1e9549c1
ChristianMachniewicz/ZombieDice-em-Python
/ZombieDice.py
3,985
3.578125
4
import random from random import shuffle class cores(object): def __init__(self, cor, lados): self.cor = cor self.lados = lados def roll(self): return self.lados[random.randint(0,5)] class Player(object): def __init__(self, nome, pontos): self.nome = nome self.p...
be70e07d7ecf8479c7b1565107a5c62309ec57fb
tswr/ekbpy-contact-book
/modules/phone.py
2,777
3.828125
4
# -*- coding: utf-8 -*- import re def validate(phoneString): """ Проверяет, является ли переданная строка телефоном в формате +12345678901. Возвращает True, если является, False иначе. """ if phoneString[0]=='+': b=phoneString[1:] if len(b) <> 11: return False for s in b: if int(s...
132a895ec0d25972b0c51fe8997aff38fb5419d5
Gasan66/Coursera
/The Basics of Python Programming/solution16.py
383
3.75
4
from collections import namedtuple n = int(input()) participant = namedtuple('participant', ['surname', 'point']) participants = [] for i in range(n): t = input().split() participants.append(participant(t[0], int(t[1]))) participants.sort(key=lambda x: x.point, revers...
511b872859da97987a1a9b69c194114edc04fb52
chrismedrela/2019-04-24-pytdd
/srp/before.py
938
3.625
4
import re import unittest EMAIL_PATTERN = re.compile(r'^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$') class Person: def __init__(self, first_name, last_name, email): assert isinstance(first_name, str) assert isinstance(last_name, str) assert isinstanc...
4725536be9ca282d2a966768c4a4f2d86d9f9761
eduardoprograma/linguagem_Python
/Introdução à Programação com Python/Do autor/Códigi fonte e listagem/listagem/capitulo 07/07.43 - Formatação de números decimais.py
1,109
3.9375
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpressão - ...
0f46363336b85f3669cfa6e5c4e0843c5cf66018
eduardoprograma/linguagem_Python
/Introdução à Programação com Python/Do autor/Códigi fonte e listagem/listagem/capitulo 09/09.03 - Impressão dos parâmetros passados na linha de comando.py
996
4.28125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpressão - ...
ec3cafab8344c1cafc311602a95097da548fbc37
eduardoprograma/linguagem_Python
/Introdução à Programação com Python/Do autor/Códigi fonte e listagem/listagem/capitulo 09/09.04 - Gravação de números pares e ímpares em arquivos diferentes.py
1,088
4.125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpressão - ...
aa26264a25c43f814a301bcd7a89b8a27dd599c9
eduardoprograma/linguagem_Python
/Introdução à Programação com Python/Do autor/Códigi fonte e listagem/listagem/capitulo 06/06.50 - Obtenção do preço com um dicionário.py
1,206
4.28125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpressão - ...
4f49d78a6523dc210c0d49d8d2925734807ee638
eduardoprograma/linguagem_Python
/Introdução à Programação com Python/Do autor/Exercícios resolvidos/exercicios/capitulo 09/exercicio-09-18.py
1,381
3.8125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpressão - ...
2f27d148312fef3c4eda72b9415a43d8b2f37dc8
eduardoprograma/linguagem_Python
/Introdução à Programação com Python/Do autor/Exercícios resolvidos/exercicios/capitulo 11/exercicio-11-06.py
1,528
3.828125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpressão - ...
b71a091fa6030a07ddfbdf9db0bf89cf9f6c67aa
rakeshkedar181/Employee_Management_System
/Employee_Application/ExampleScript.py
1,479
3.8125
4
''' Created on Oct 22, 2019 @author: rakesh13575 ''' import sys def example_datatypes(): num_example = 20 list_example = [12,'Name',434,'Developer'] tuple_example = (23,44,66,900,23,944,['abc',45,98.87]) emp_dict_example = {'empno':13575 , 'name':'rakesh','salary':246588,32:'aaaaa'} ...
f0cfc7cafe0f854f34ce273befe2d869e3546ffb
MuhammedUlviOzkaya/Codes
/venv/Scripts/Functions.py
438
3.84375
4
def sum(firstNum, secondNum, third, forth): print(firstNum + secondNum + third*forth) sum(15, 20, 3, 2) print(sum(15, 20, 3, 2)) def multiply(firstNum, secondNum): return firstNum * secondNum a = multiply(8, 9) print(a) print("The answer is:", multiply(2,3)) def isTriangle(a,b,c): if a**2 + b**2 == c*...
fbc8ef17dbed7621b0f1b0b3c8e545c4ddaa90fb
bnb32/project_euler
/problem92.py
295
3.6875
4
def add_squared_digits(n): return sum([int(d)**2 for d in str(n)]) def main(): N=10**7 count=0 for n in range(1,N): num=n while num!=89 and num!=1: num=add_squared_digits(num) if num==89: count+=1 return count print(main())
292d5e5aaa5beb00a7f2443afc25b015dff01906
bnb32/project_euler
/problem53.py
464
3.765625
4
def factorial(n): val=1 for i in range(2,n+1): val*=i return val def binomial(n,k): return factorial(n)//(factorial(k)*factorial(n-k)) def main(): count=0 for n in range(1,101): for k in range(2,n//2+1): if binomial(n,k)>10**6: if n%2==0 and k==n//2...
a8cc341be256a40bc32c3cfd29fc0ba65782a0cc
bnb32/project_euler
/problem37.py
545
3.75
4
import math def isPrime(N): if N==1: return False for i in range(2,int(math.sqrt(N))+1): if N%i==0: return False return True def possPrimes(N): poss=[N] s=str(N) for i in range(1,len(s)): poss.append(int(s[:i])) poss.append(int(s[::-1][:i][::-1])) return poss def m...
a5e4ef973d62076be0cd05db3f5fc8d47dc6468f
bnb32/project_euler
/problem15.py
649
3.65625
4
import numpy as np import math def walks(Nx,Ny,stored): if Nx==0 or Ny==0: return 1 elif Nx==1: return 1+Ny elif Ny==1: return 1+Nx elif stored.shape[0]>Nx and stored.shape[1]>Ny and stored[Nx,Ny]!=0: return stored[Nx,Ny] else: return walks(Nx,Ny-1,stored)+wa...
99ba874ed7e44c770d7102405a8ed7d66878eb02
bnb32/project_euler
/problem71.py
616
3.640625
4
import euler_project as euler @euler.memoize def closest_fraction(n): numerator=(3*n-1)/7 if numerator % 1 != 0: return [] else: return ["%s/%s"%(int(numerator),n)] def all_close_fractions(n,m): nums=["3/7"] for i in range(m,n+1): nums+=closest_fraction(i) nums.sort(key=fraction_decima...
0ae594e04510de7fbd51002fd462f0b4bd32a49b
bnb32/project_euler
/problem69.py
463
3.515625
4
import euler_project as euler def isCoprime(m,n): return euler.__gcd(m,n)==1 def euler_totient(n): count=n for p in euler.prime_factors(n): count*=(p-1)/p#k**(v-1)*(k-1) return count def main(): N=10**6 max_val=0 max_n=0 for i in range(2,N+1): val=i/euler_totient(i...
7f367924f8f6216c6cfae4c02c3db6f5db944648
pooyamb/py-moneyed
/moneyed/money.py
8,073
3.6875
4
# -*- coding: utf-8 -*- from __future__ import division from __future__ import unicode_literals from decimal import Decimal import sys import warnings PYTHON2 = sys.version_info[0] == 2 # Default, non-existent, currency DEFAULT_CURRENCY_CODE = 'XYZ' def force_decimal(amount): """Given an amount of unknown ty...
650b4d391b502abf578fe93aef8f679185367081
yangchunluo/udacity-ai-robotics
/programming/12.19.planning.py
4,048
4.34375
4
# https://classroom.udacity.com/courses/cs373/lessons/48646841/concepts/486468400923 # ---------- # User Instructions: # # Implement the function optimum_policy2D below. # # You are given a car in grid with initial state # init. Your task is to compute and return the car's # optimal path to the position specified in...
6e3b23c76044d36d683a8d6b6f338a0dd4ebef6c
SethBrunwasser/PrivaCV
/database.py
1,264
3.578125
4
import sqlite3 import sys class UsersDB: def __init__(self): self.connection = sqlite3.connect('users.db', timeout=10) self.cursor = self.connection.cursor() self.cursor.execute("DROP TABLE IF EXISTS PERSON") self.cursor.execute(""" CREATE TABLE PERSON( USER_ID INTEGER PRIMARY KEY autoincrement, N...
2ae51e826f150b04bd3d08ee6ec9535e87e809ed
BereniceRamos/Ejercicios_Python
/countBits.py
309
3.71875
4
# def count_bits(n): # if n / 2 > 1: # return n % 2 # print(count_bits(9)) binary = bin(2) print(binary) # def count_bits(n): # return n / count_bits(n/2) # print(count_bits(2)) # def factorial(n): # if n == 1: # return 1 # return n * factorial(n-1) # print(factorial(3))
3a7aa7736b6c7fcd86ca5c273384f91716479583
lxtan16/Python
/codes/flask1/app.py
618
3.703125
4
from flask import Flask,request # we are creating a variable which is the Flask application app = Flask(__name__) @app.route('/') def helloworld(): return '<h1>Hello world!</h1>' @app.route('/greet/', defaults={'name':'nobody'}) @app.route('/greet/<name>') def greet(name): return 'Good morning, ' + name @a...
53b84066ad911d17e4ed14274b759a958dd305bc
sjay05/CCC-Solutions
/2017/J3.py
572
3.890625
4
""" author: sjay05 """ # a = input("a-value?") # b = input("b-value?") # c = input("c-value?") # d = input("d-value?") # t = input("t-value?") a,b = map(int, raw_input().split()) c,d = map(int, raw_input().split()) t = input() def find_distance(a, b, c, d): return (c - a) + (d - b) def can_drive(a, b, c, d, t): ...
61f5dff0c306b78d1667a3de00f51df9dc4b9ac4
sjay05/CCC-Solutions
/2016/J4.py
908
3.5
4
""" author: sjay05 """ # (9 / 15) - WA Code input = raw_input() min_from_hour = int(input[0]+input[1])*60 min_from_min = int(input[3] + input[4]) min = min_from_hour + min_from_min counter = 0 peakhours1 = range(420, 600) peakhours2 = range(900, 1140) if input == "07:00": print "10:30" elif input == "15:00": ...
25f2d36eca2c26c4ef898ba985391b7fe6d368cc
sjay05/CCC-Solutions
/2019/J2.py
226
3.5625
4
""" author: sjay05 """ main = input() c = 0 list = [] inp = "" while c < main: inp = raw_input() inp = inp.rsplit(" ") list.append(inp) c += 1 for i in range(len(list)): print list[i][1] * int(list[i][0])
172a9cbc33dca106f6c319080e4aca98f6e44e1a
sjay05/CCC-Solutions
/2003/J5.py
1,451
3.609375
4
""" author: sjay05 """ # CCC '03 - S3 / J5 - Floor Plan (GRAPH THEORY) from sys import stdin from Queue import Queue input = stdin.readline floor = [] rooms = [] t = int(input()) r = int(input()) c = int(input()) def make_pair(a, b): return a, b def getN(x, y): a, b, e, d = (x+1, y), (x-1, y), (x, y+1), (x...
57bd5a87b8da296e6cbdf3ed219d8cebfedd7e67
sjay05/CCC-Solutions
/2013/J1.py
131
3.75
4
""" author: sjay05 """ x = input() y = input() if x == y: print y elif y > x: print y + (y-x) else: print "Try again"
e410f20f3b25a5254787db0f23ee7f4e22ec6369
sjay05/CCC-Solutions
/2001/S3.py
1,286
3.65625
4
""" author: sjay05 """ from sys import stdin from Queue import Queue input = stdin.readline """ Algorithm Outline: - We want to check if we can get from A to B with edge (e) removed. If no, then this is a DISCONNECTING ROAD. We can use BFS or DFS to check if B exists in visited arr when DFS or BFS initiated from A. ""...
6a1bd157f612a236476eced96961fec06d9b58ab
joogvzz/dweb
/code/ner/build_vocab.py
4,113
3.5
4
""" ## Minería de textos Universidad de Alicante, curso 2020-2021 Esta documentación forma parte de la práctica "[Lectura y documentación de un sistema de extracción de entidades](https://jaspock.github.io/dweb/bloque2_practica.html)" y se basa en el código del curso [CS230](https://github.com/cs230-stanford/cs230-co...
12d9b95b492daadd9be11a16790b2a2999a19e5f
Ronarker/EGE
/INF-EGE/С2/complete/Task2907/solution.py
329
3.609375
4
N = 30 a = [] for i in range(N): a.append(int(input())) max_even = 0 max_odd = 0 for i in range(N): if a[i] % 2 == 0 and a[i] > max_even: max_even = a[i] elif a[i] % 2 != 0 and a[i] > max_odd: max_odd = a[i] print(max_even - max_odd) # Результат проверки - всё правильно
13ad6422e1447c583eef1740c68a3bc57edbbdda
FreyaRoberts/cp1404practicals
/prac_03/broken_score2.py
448
4.03125
4
def main(): """Get an input of a score and display its value""" score = float(input("Enter score: ")) result = score_check(score) print(score_check(score)) def score_check(score): """Determine type of result""" if score < 0 or score > 100: return "Invalid score" elif score >= 90: ...
030a6a04d110e5e2bbf16d1b4788b4e0480b1e6e
buerlee/Python-Exercises_Interview-questions
/简单算法题/计算1到100的值.py
209
3.8125
4
# -*- coding: utf-8 -*- # sum = 0 # for i in range(1, 101): # sum += i # print(sum) # sum = 0 # i = 0 # while i < 100: # i += 1 # # print(i) # sum += i # print(sum) print(sum(range(1, 101)))
43718724cdf04d7806ee051539d94d9d839884c9
thessaly/python_boringstuff
/7_phone_project.py
1,415
3.796875
4
#! /usr/bin/python3 # Use the pyperclip module to copy and paste strings. import pyperclip, re text = str(pyperclip.paste()) # Create two regexes, one for matching phone numbers and the other for matching email addresses. phone_regex = re.compile(r'''( (\d{3}|\(\d{3}\))? # area code (ddd or (ddd)), it's optional ...
242fc352da4d6ab1569691d91ab557cbd270c6e7
thessaly/python_boringstuff
/4_magicball.py
366
3.59375
4
import random messages = ['It is certain', 'It is decidedly so', 'Yes definitely', 'Reply hazy try again', 'Ask again later', 'Concentrate and ask again', 'My reply is no', 'Outlook not so good', 'Very doubtful'] # prints a message looking for a random index number between zero and the last index of the list print(me...
bbcda089c582384aa7b071ebe03af04760c5d947
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/list_advanced/the_office.py
646
4.15625
4
employees_happiness = input().split() happiness_improvement_factor = int(input()) increased_happiness = [int(num) * happiness_improvement_factor for num in employees_happiness] average_happiness = sum(increased_happiness) / len(increased_happiness) greater_than_average_happiness = [num for num in increased_happiness i...
06e98a05963e8ccf95d44f90419b07b4112f4f47
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/lists_basics/list_stats.py
314
3.90625
4
n = int(input()) positives = [] negatives = [] for i in range(n): integer = int(input()) if integer >= 0: positives.append(integer) else: negatives.append(integer) print(positives) print(negatives) print(f"Count of positives: {len(positives)}. Sum of negatives: {sum(negatives)}")
4e879082214a8743746dfe4201c68fcb7b7d834c
AssiaHristova/SoftUni-Software-Engineering
/Python Advanced/first_exam_preparation/taxi_express.py
724
3.6875
4
from collections import deque customers = [int(customer) for customer in input().split(", ")] taxis = [int(taxi) for taxi in input().split(", ")] customers_queue = deque(customers) total_time = 0 while customers_queue: if not taxis: break customer = customers_queue.popleft() taxi = taxis.pop() ...
b90e0f6d7d25f605518bb47957f5ed49534e618f
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/exams/change_bureau.py
369
3.515625
4
bitcoins = int(input()) yuans = float(input()) commission = float(input()) bitcoins_to_leva = bitcoins * 1168 bitcoins_to_euro = bitcoins_to_leva / 1.95 yuans_to_dollars = yuans * 0.15 yuans_to_leva = yuans_to_dollars * 1.76 yuans_to_euro = yuans_to_leva / 1.95 euro = bitcoins_to_euro + yuans_to_euro money = euro - e...
3dbe1db1a54ec987a09ed20301a77ab6e7f6ddae
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/text_processing/extract_person_info.py
271
3.6875
4
import re N = int(input()) pattern = r'(?<=@)(?P<name>.+)(?=\|).+(?<=#)(?P<age>.+)(?=\*)' for _ in range(N): line = input() data = re.finditer(pattern, line) for el in data: a = el.groupdict() print(f"{a['name']} is {a['age']} years old.")
8643f8266c0124310aacffade1396683e0be625d
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/final_exam_preparation/problem_3.py
1,129
3.9375
4
def add(emails, username): if username in emails: print(f'{username} is already registered') else: emails[username] = [] return emails def send(emails, username, email): if username in emails: emails[username].append(email) return emails def delete(emails, username): ...
6939bc3dc1e9223e04033f1ccaa81484f5fd43d4
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/while_loop/avg_num.py
146
4.03125
4
n = int(input()) number = 0 avg_num = 0 for i in range(1, n + 1): number = int(input()) avg_num += number / n print(f'{avg_num:.2f}')
fce3b9331292e6f0ca9d86566ea89f469335b185
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/list_advanced/even_numbers.py
297
3.78125
4
string = [int(el) for el in input().split(', ')] even_nums = [index for index in range(len(string)) if string[index] % 2 == 0] print(even_nums) nums = list(map(int, input().split(', '))) even_numbers = list(filter(lambda index: nums[index] % 2 == 0, range(len(nums)))) print(even_numbers)
ba99f3540c16ea80a46540953434ac0f20c5de02
AssiaHristova/SoftUni-Software-Engineering
/Python Advanced/first_exam_preparation/list_manipulator.py
1,662
3.828125
4
from collections import deque def list_manipulator(numbers, *args): commands = deque() nums = [] for el in args: if isinstance(el, str): commands.append(el) else: nums.append(el) while commands: first_command = commands.popleft() second_command...
522d8bb19af8b1fc34783acef2f2427c7c714349
AssiaHristova/SoftUni-Software-Engineering
/Python OOP/encapsulation/project_2/pizza.py
1,446
3.890625
4
class Pizza: def __init__(self, name, dough, toppings_capacity): self.__name = name self.__dough = dough self.__toppings_capacity = toppings_capacity self.__toppings = {} @property def name(self): return self.__name @name.setter def name(self, new_name): ...
8bfffaa49eb2ad351b95e9de356080a4a47d995f
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/mid_exam_preparation/array_modifier.py
717
3.5625
4
array = input().split() command = input() array_nums = [int(num) for num in array] while not command == 'end': command_list = command.split() if 'swap' in command_list: index_1 = int(command_list[1]) index_2 = int(command_list[2]) array_nums[index_1], array_nums[index_2] = array_nums[i...
4d34c27d91df4a865872dffb9920138cfa2e01e5
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/final_exam_preparation/password_reset.py
791
3.953125
4
password = input() word = input() new_password = '' while not word == "Done": command = word.split() if 'TakeOdd' in command: for i in range(1, len(password), 2): new_password += password[i] password = new_password print(password) elif 'Cut' in command: index = ...
6c0d7d90b22acaa3ca148f773094359219e37074
AssiaHristova/SoftUni-Software-Engineering
/Python Advanced/first_exam_preparation/list_pureness.py
754
3.734375
4
from collections import deque def best_list_pureness(nums, k): numbers = deque(nums) def list_pureness(numbers): pureness = 0 for i in range(len(numbers)): pureness += numbers[i] * i return pureness max_pureness = list_pureness(numbers) rotation = 0 max_rotati...
93d1bda0159031b630c949837be1c1cc5bf2403e
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/advanced_cond_statetments/new_house.py
953
3.90625
4
flowers = input() flowers_count = int(input()) budget = int(input()) price = 0.0 if flowers == 'Roses': price = 5 elif flowers == 'Dahlias': price = 3.80 elif flowers == 'Tulips': price = 2.80 elif flowers == 'Narcissus': price = 3 elif flowers == 'Gladiolus': price = 2.50 if flowers_count > 80 a...
dcaa20f0f556e6dfac357a6d52bfb857f42b9341
AssiaHristova/SoftUni-Software-Engineering
/Python Advanced/comprehensions/even_matrix.py
354
3.8125
4
rows = int(input()) matrix = [] for _ in range(rows): row = input().split(', ') matrix.append(row) even_matrix = [[int(x) for x in row if int(x) % 2 == 0] for row in matrix] def get_even(values): return [int(x) for x in values if int(x) % 2 == 0] even_matrix_2 = [get_even(row) for row in matrix] print...
78e0ff788322fa32bf9ee64923823fdeb5d8b904
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/for_loop/num_equals_sum.py
386
3.5625
4
import sys n = int(input()) sum_numbers = 0 number_max = -sys.maxsize for i in range(n): number = int(input()) sum_numbers += number if number > number_max: number_max = number if sum_numbers - number_max == number_max: print('Yes') print(f'Sum = {number_max}') else: print('No') ...
2397fb30986f4282622c0e123349c8e8986f890e
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/data_types_variables/triples_of_letters.py
240
3.5
4
n = int(input()) for i in range(n): letter_1 = chr(97 + i) for j in range(n): letter_2 = chr(97 + j) for k in range(n): letter_3 = chr(97 + k) print(f'{letter_1}{letter_2}{letter_3}')
c762a75080eed7b2fc48df2fb12b2900743fcc33
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/final_exam_preparation/mirror_words.py
729
4
4
import re text = input() mirror_words = [] count = 0 pattern = r'(?P<separator>[\#\@])[a-zA-Z]{3,}(?P=separator){2}[a-zA-Z]{3,}(?P=separator)' word_pairs = re.finditer(pattern, text) word_pairs = [word.group() for word in word_pairs] if len(word_pairs) == 0: print("No word pairs found!") else: print(f"{len...
fcbb8cee595d32fc1b90a2916bee2acb46d39506
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/lists_basics/easter_gifts.py
937
3.515625
4
gifts = input() command = '' gifts_list = gifts.split(' ') while not command == "No Money": command = input() command_list = command.split(' ') for word in command_list: if word == "OutOfStock": command_list.remove("OutOfStock") gift = str(command_list[0]) for i...
faa86263f89ff264176d35e410d67a7456ac552b
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/reg_expressions/match_dates.py
288
3.65625
4
import re data = input() pattern = r'\d{2}([\./-])[A-Z][a-z]{2}\1\d{4}' dates = re.finditer(pattern, data) for date in dates: m_object = date.group(0) day = m_object[:2] month = m_object[3:6] year = m_object[7:11] print(f'Day: {day}, Month: {month}, Year: {year}')
477a92d4deb8acfb5f7ecd32606474f4bd44383e
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/mid_exam_preparation/softuni_reception.py
335
3.65625
4
import math employee_1 = int(input()) employee_2 = int(input()) employee_3 = int(input()) students = int(input()) efficiency_per_hour = employee_1 + employee_2 + employee_3 hours = math.ceil(students / efficiency_per_hour) for hour in range(1, hours + 1): if hour % 4 == 0: hours += 1 print(f"Time needed:...
e3242656ac9e1950e58ce01296282f7e2da783ee
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/exams/family_trip.py
466
3.671875
4
budget = float(input()) nights = int(input()) price_per_night = float(input()) extra_expenses = int(input()) total_price = 0 if nights > 7: price_per_night = price_per_night * 0.95 price = nights * price_per_night total_price = price + budget * (extra_expenses / 100) money_out = budget - total_price if budget >...
32c6968ef4ae01ba3c08093a1f33d20ce640fcb0
AssiaHristova/SoftUni-Software-Engineering
/Python Advanced/multidimensional_lists/snake_moves.py
1,157
3.671875
4
from collections import deque def create_snake(snake): snake_queue = deque() for el in snake: snake_queue.append(el) return snake_queue def create_matrix(rows, columns): matrix = [] for _ in range(rows): row = [0] * columns matrix.append(row) return matrix def snake...
23b80d6189eafde1b49a9676aa195403c268a31b
AssiaHristova/SoftUni-Software-Engineering
/Python Advanced/multidimensional_lists/sum_matrix_columns.py
621
3.671875
4
def read_matrix(): rows, columns = map(int, input().split(', ')) matrix = [] for row in range(rows): row = list(map(int, input().split())) matrix.append(row) return matrix def column_sum(matrix): sums = [] rows_count = len(matrix) columns_count = len(matrix[0]) for i in...
2a1ad88781169dc12a46f981d07efc4247091047
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/exams/football_tournament.py
634
3.96875
4
team = input() matches = int(input()) points = 0 count_w = 0 count_d = 0 count_l = 0 for match in range(1, matches + 1): result = input() if result == 'W': points += 3 count_w += 1 elif result == 'D': points += 1 count_d += 1 else: count_l += 1 if matches == 0...
4867f25ca6bff8a7b52135f728ce3c086c67efe7
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/final_exam_preparation/emoji_detector.py
577
3.78125
4
import re text = input() cool_threshold = 1 pattern = r'(?P<separator>[\:\*]){2}[A-Z][a-z][a-z]+(?P=separator){2}' matches = re.finditer(pattern, text) emojis = [match.group() for match in matches] for el in text: if el.isdigit(): cool_threshold *= int(el) print(f'Cool threshold: {cool_threshold}') pri...
8c36468a2f75a50752eb9a94b39d57b36561aefe
AssiaHristova/SoftUni-Software-Engineering
/Python OOP/iterators_and_generators/generator_primes.py
845
3.84375
4
from math import sqrt def is_prime(number): for x in range(2, int(sqrt(number)) + 1): if number % x == 0: return False return True def primes_gen(max_number): number = 1 while number < max_number: if is_prime(number): yield number number += 1 class P...
a960aed96bf262e5126c6444b4c54d6e3552f1f8
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/advanced_cond_statetments/invalid_number.py
109
3.671875
4
number = int(input()) is_valid = 100 < number > 200 or number == 0 if not is_valid: print('invalid')
a731e4e3942ec7bca995bdc4b835e20b208ccfb1
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/functions/odd_and_even_sum.py
313
4.125
4
number = int(input()) def sum_odd_even(num): sum_even = 0 sum_odd = 0 for symbol in str(num): if int(symbol) % 2 == 0: sum_even += int(symbol) else: sum_odd += int(symbol) return f'Odd sum = {sum_odd}, Even sum = {sum_even}' print(sum_odd_even(number))
be5f667cc4072c1eb453dadbe393e32de8df53fa
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/exams/aluminium_joinery.py
1,352
3.9375
4
joyneries = int(input()) type = input() delivery = input() price_1 = 0 price_total = 0 if type == '90X130': price_1 = 110 if joyneries < 30: price_total = joyneries * price_1 elif 30 <= joyneries < 60: price_total = (joyneries * price_1) * 0.95 elif joyneries >= 60: price_total...
3a4d4d5eb4c93c5de9099998d01cde896ae4db27
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/dictionaries/force_book.py
993
3.734375
4
data = input() users = {} while not data == "Lumpawaroo": if '|' in data: data_list = data.split(' | ') user = data_list[1] side = data_list[0] if user not in users: users[user] = side elif '->' in data: data_list = data.split(' -> ') user = data_lis...
0b75f0bf9361da73e20faf5077378239a3918252
AssiaHristova/SoftUni-Software-Engineering
/Python OOP/testing/car_manager_tests.py
6,395
3.8125
4
class Car: def __init__(self, make, model, fuel_consumption, fuel_capacity): self.make = make self.model = model self.fuel_consumption = fuel_consumption self.fuel_capacity = fuel_capacity self.fuel_amount = 0 @property def make(self): return self.__make ...
9cc80a4a12a9f2afaea79f616452a8e9f9cddadf
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/text_processing/character_multiplier.py
517
3.625
4
data = input().split() result = 0 string_1 = data[0] string_2 = data[1] if len(string_2) > len(string_1): for i in range(len(string_1)): result += ord(string_1[i]) * ord(string_2[i]) for j in range(len(string_2)): if j >= len(string_1): result += ord(string_2[j]) else: for j in...
08636ca98b9143277e1985d4c5c81ee111499cab
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/exams/movie_stars.py
515
3.640625
4
budget = float(input()) actor = input() budget_left = 0 commission_all = 0 while actor != "ACTION": commission = 0 if len(actor) > 15: commission = budget_left * 0.20 else: commission = float(input()) commission_all += commission budget_left = budget - commission_all if budget_...
27cbaef6016eb78ee6d80c0a8ef9128479cc4143
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/for_loop/smart_lilly.py
490
3.5625
4
n = int(input()) washm_price = float(input()) price_per_toy = int(input()) money = 0 money_toys = 0 money_brother = 0 count = 0 for i in range(1, n+1): if i % 2 == 0: count += 1 money += count * 10.00 money_brother = money - count * 1.00 else: money_toys += price_per_toy mone...
b13376b2d0df4b5f952da98a0e02c7419f2f5321
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/final_exam_preparation/secret_chat.py
1,145
4.0625
4
def insert_space(message, index): result = '' result = message[:index] + ' ' + message[index:] print(result) return result def reverse(message, substring): result = '' if substring in message: result = message.replace(substring, '', 1) result += substring[::-1] print(re...
21fa88f1b8788bcc99ad054141bc9d1469a90c15
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/text_processing/letters_change_nums.py
491
3.71875
4
string = input().split() result = 0 total_sum = 0 for word in string: word.strip() letter_before = word[0] letter_after = word[-1] num = int(word[1: -1]) if letter_before.isupper(): result = num / (ord(letter_before) - 64) else: result = num * (ord(letter_before) - 96) if l...
14f01ba1f6aade4b98ef52963af8cf11515d13b2
AssiaHristova/SoftUni-Software-Engineering
/Python Advanced/first_exam_preparation/snake.py
2,623
4.03125
4
def create_matrix(): n = int(input()) matrix = [] for _ in range(n): row = [el for el in input()] matrix.append(row) return matrix def find_the_snake(matrix): for r in range(len(matrix)): for c in range(len(matrix[r])): if matrix[r][c] == 'S': re...
b78f8408bf563e406d73eac379b9ec3fe275657d
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/while_loop/letters_flow.py
1,036
3.671875
4
symbol = input() small_letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'f', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] capital_letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'F', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', '...
3b69841720e4b9020bbb25e3c31ce78d20379904
AssiaHristova/SoftUni-Software-Engineering
/Python OOP/polymorphism/abstract_classes.py
1,172
3.875
4
import math import json from abc import ABC, abstractmethod class Shape(ABC): def __init__(self): if type(self) == Shape: raise TypeError('Shape is abstract') @abstractmethod def perimeter(self): pass @abstractmethod def area(self): pass class Circle(Shape):...
555d607d128307d849fd36928ab8692115aefecb
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/text_processing/extract_file.py
171
3.546875
4
path = input().split("\\") file = path[-1].split('.') file_name = file[0] extension = file[1] print(f'File name: {file_name}') print(f'File extension: {extension}')
bdeb598574ecbaaf0303861d14873859d1faa9e5
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/exams/cinema_vaucher.py
761
3.71875
4
voucher = int(input()) purchase = input() count_tickets = 0 count_others = 0 price = 0 while purchase != "End": if len(purchase) > 8: count_1 = 0 for letter in purchase: symbol = ord(letter) count_1 += 1 price += symbol if count_1 == 2: ...
5f54ca1c7d5c45953165dc61e58c909ec0a3a786
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/exams/treking_mania.py
766
3.71875
4
groups = int(input()) climbers = 0 moussalla = 0 montblan = 0 kilimanjaro = 0 k2 = 0 everest = 0 for group in range(1, groups + 1): people_per_group = int(input()) climbers += people_per_group if people_per_group <= 5: moussalla += people_per_group elif 6 <= people_per_group <= 12: mon...
0b6413359607f17374ee0bbb25209f08c51377be
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/final_exam_preparation/need_for_speed.py
1,867
3.828125
4
def drive(cars, car, distance, fuel): if car in cars: if cars[car][1] > fuel: cars[car][1] -= fuel cars[car][0] += distance print(f"{car} driven for {distance} kilometers. {fuel} liters of fuel consumed.") if cars[car][0] >= 100000: cars.pop(ca...