blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
019386c8b2cd72a2616360727be11bc4e5977ae4
Beyamor/seng440
/scripts/cos-values.py
778
3.59375
4
from math import * #join_point = 0.50474 #join_point = 0.818999999999 join_point = 0.7380999999999518 #join_point = pi/4 #join_height = cos(join_point) join_height = 0.8097483720555431 print "section 1:" slope = (0 - join_height) / (-pi/2 - -join_point) print str(0 + -1 * slope * -pi/2) + " + " + str(slope) + " * an...
4f02e58d239e590a6cdb9848857174e45f894511
momchilantonov/SoftUni-Python-Advanced-January-2021
/Exam-Preparation/Python-Advanced-Exam-27-June-2020/Solutions/03_list_manipulator.py
1,697
4.09375
4
from collections import deque def list_manipulator(nums_queue, command, position, *args): if command == "add" and position == "beginning": nums_queue = deque(nums_queue) nums_to_add = [*args] while nums_to_add: nums_queue.appendleft(nums_to_add.pop()) return list(nums_q...
97f57b7a85415887239864f9b3bc3a50be58c36c
momchilantonov/SoftUni-Python-Advanced-January-2021
/Comprehension/Comprehension-Lab/03_even_matrix.py
679
3.734375
4
# def read_matrix(r): # matrix = [[int(x) for x in input().split(", ")] for _ in range(r)] # return matrix # # # def get_even_row(row): # result = [x for x in row if x % 2 == 0] # return result # # # def get_even_matrix(matrix): # result = [get_even_row(row) for row in matrix] # return result # ...
ab1a6120bdbb988578f2a1e1db529fd4acd55f3a
momchilantonov/SoftUni-Python-Advanced-January-2021
/Tuples-And-Sets/Tuples-And-Sets-Exercise/07_battle_of_names.py
752
3.515625
4
import pypandoc def input_lines(num): even = set() odd = set() for idx in range(1, num+1): name = input() data = sum(ord(ch) for ch in name) // idx if data % 2 == 0: even.add(data) else: odd.add(data) return even, odd def result(data): sum_...
2df591b9649659509473761bc5f954976b557aed
momchilantonov/SoftUni-Python-Advanced-January-2021
/Tuples-And-Sets/Tuples-And-Sets-Exercise/02_sets_of_elements.py
363
3.703125
4
def input_lines(num): lines = set() for _ in range(num): lines.add(input()) return lines def intersection(a, b): return a.intersection(b) def print_result(res): for r in res: print(r) len1, len2 = input().split(" ") line1 = input_lines(int(len1)) line2 = input_lines(int(len2))...
dc157a6c6c0ddcb3613aa9e9d978384291e48414
momchilantonov/SoftUni-Python-Advanced-January-2021
/Exam-Preparation/Python-Advanced-Exam-27-June-2020/Solutions/01_bombs.py
1,761
3.828125
4
from collections import deque DATURA_BOMBS = 40 CHERRY_BOMBS = 60 SMOKE_DECOY_BOMBS = 120 def read_bomb_effects(): return deque(int(x) for x in input().split(", ")) def read_bomb_casings(): return [int(x) for x in input().split(", ")] def mix_bombs(effects, casings): datura_counter = 0 cherry_cou...
1e684fab34b1acdc6b77168ebfb390f18c9e829c
momchilantonov/SoftUni-Python-Advanced-January-2021
/Lists-As-Stacks-And-Queues/Lists-As-Stacks-And-Queues-Exercise/07_robotics_.py
1,353
3.53125
4
from collections import deque from datetime import datetime, timedelta data = input().split(";") time = datetime.strptime(input(), "%H:%M:%S") robots = [] available_robots = deque() products = deque() for el in data: robot_data = el.split("-") robot = {} robot["name"] = robot_data[0] robot["speed"] = ...
a8311fb5540b18a4e0a74355284a0d368bb5dac2
momchilantonov/SoftUni-Python-Advanced-January-2021
/File-Handling/File-Handling-Exercise/04_directory_traversal.py
1,508
4.09375
4
import os def take_all_files_from_dir(path): all_files = [file for file in os.listdir(path) if os.path.isfile(file)] return all_files def separate_files_by_type(files_list): files_by_type = {} for file in files_list: file_name, file_extension = os.path.splitext(file) if file_extensio...
af6738491c07ca694b971116f9c5a0d72ff5b189
momchilantonov/SoftUni-Python-Advanced-January-2021
/Lists-As-Stacks-And-Queues/Lists-As-Stacks-And-Queues-Exercise/10_cups_and_bottles_.py
1,477
3.53125
4
from collections import deque cups = deque(int(el) for el in input().split(" ")) bottles = [int(el) for el in input().split(" ")] wasted_water = 0 def pour(water): if spillway["cups"] <= spillway["bottles"]: water += spillway["bottles"]-spillway["cups"] return water else: spillway["cu...
9faf3f68f17434d5ff78ae0e62c988f61fc5cd83
momchilantonov/SoftUni-Python-Advanced-January-2021
/Tuples-And-Sets/Tuples-And-Sets-Exercise/04_count_symbols.py
440
3.5625
4
def input_lines(in_line): line = tuple(ch for ch in in_line) return line def count_chars(val): val_count = {} for v in val: if v not in val_count: val_count[v] = 0 val_count[v] += 1 ord_val = sorted(val_count.items(), key=lambda x: x[0]) return ord_val def print_r...
1069ff30d47b81cedf03fa22b007dc8d4a281561
momchilantonov/SoftUni-Python-Advanced-January-2021
/Exam-Preparation/Python-Advanced-Exam-24-October-2020/Solutions/03_list_pureness.py
651
3.515625
4
from collections import deque def best_list_pureness(*args): numbers_list = deque(int(num) for num in args[0]) rotate_numbers = int(args[1]) counter = 0 best_counter = 0 best_pureness = 0 for _ in range(rotate_numbers+1): curr_pureness = sum(numbers_list[i] * i for i in range(len(numb...
253bfe689d7414ec2744ff451ca6b8cb4278a4e2
lesyuk/learning_python
/pythontutor/input/school_desks.py
369
3.75
4
student_number_1 = int(input()) student_number_2 = int(input()) student_number_3 = int(input()) number_of_desks_1 = (student_number_1 // 2) + (student_number_1 % 2) number_of_desks_2 = (student_number_2 // 2) + (student_number_2 % 2) number_of_desks_3 = (student_number_3 // 2) + (student_number_3 % 2) print(number_of...
a85d61fc5927b5204f26f4a62a17d70c8631cb6a
lesyuk/learning_python
/automation_school/lesson_3/calculator.py
2,160
3.75
4
def number_input(): number = input('Введите число: ') if type(number_validation(number)) == float: return number_validation(number) def number_validation(number): if number != 'close': try: return float(number) except ValueError: print('Не похоже на число. П...
7e9a406b6f6c44ac7e5b9b991ced200ce503e7e9
lesyuk/learning_python
/automation_school/alternating_caps.py
405
4
4
def alternating_caps(s): l = list(s) letter_counter = 0 for i in range(len(l)): if letter_counter % 2 != 0 and l[i] != ' ': l[i] = l[i].lower() letter_counter += 1 elif letter_counter % 2 == 0 and l[i] != ' ': l[i] = l[i].upper() letter_counter...
7b764c175792cb69453489c1425ac4cfbf8eaed1
lesyuk/learning_python
/stepik/course_1/2.5_2.py
873
3.90625
4
''' Напишите программу, на вход которой подаётся список чисел одной строкой. Программа должна для каждого элемента этого списка вывести сумму двух его соседей. Для элементов списка, являющихся крайними, одним из соседей считается элемент, находящий на противоположном конце этого списка. Если на вход пришло только одно...
8b616c29591f312f2855ed9318f329fab5c79a30
lesyuk/learning_python
/algorithms/logical_expressions.py
751
3.9375
4
# Пример: если хотя бы одно числоделится на 10, то flag = True N = int(input()) flag = False for i in range(N): x = int(input()) flag = (x % 10 == 0) or flag print(flag) """ Последняя строчка заменяет выражение if x % 10 == 0: flag == True """ # Обратный пример: если все из чисел делятся на 10, то fl...
c11ede7a688d0002ae05fc4b2b893b10027cc6b9
lesyuk/learning_python
/pythontutor/functions/capital_letters.py
230
3.953125
4
def capitalize(word): l = list(word) for i in range(len(l)): if i == 0: l[i] = l[i].upper() if word[i] == ' ': l[i + 1] = l[i + 1].upper() print(*l, sep='') capitalize(input())
65f0f1d5149063bbd6d6cd939ee2719bd25f9d65
lesyuk/learning_python
/pythontutor/for_loop/factorials_sum.py
129
3.640625
4
sum = 0 n = 1 for i in range(1, int(input()) + 1): for j in range(1, i + 1): n *= j sum += n n = 1 print(sum)
3612441a9a643d3a843423277c55e9eac4f65795
lesyuk/learning_python
/pythontutor/common/convert_types.py
97
3.75
4
# int to str a = 2 b = '34' print(str(a) + b) # float to str c = 7.8 b = '23' print(str(c) + b)
0b5d9157446ff51a4ec7e3405474c798afb699c8
lesyuk/learning_python
/automation_school/hanoi_towers.py
1,423
4.0625
4
steps_number = 0 # n — количество колец, start — начальный колышек, finish — колышек, на который нужно переместить все кольца def move(n, start, finish): global steps_number steps_number += 1 # у всех вызванных в стеке функций по мере вычета из n единицы n станет равно 1 # как только у какой-то функци...
e64368a2da1354a52febbacf3b401acb3f207927
lesyuk/learning_python
/pythontutor/calculations/motor_rally.py
95
3.625
4
n = int(input()) m = int(input()) if m % n == 0: print(m // n) else: print(m // n + 1)
cb0ebe812b093c99ef1a1744853241d35c0a1f5d
lesyuk/learning_python
/pythontutor/while_loop/second_max.py
176
3.8125
4
max = 0 second_max = 0 n = int(input()) while n != 0: if n > max: max = n if max > second_max < n: second_max = n n = int(input()) print(second_max)
1eb96eb4829ec316475c1bd61ae8bdeaba8cedf0
graduter/Pytorch-demo
/Gradient/MyLinear.py
638
3.734375
4
#coding=utf-8 # written by yidi on 2019.2.13 import numpy as np import matplotlib.pyplot as plt x_data=[1.0,2.0,3.0] y_data=[2.0,4.0,6.0] def forward(x, w): return x*w def loss(y_predic, y): return (y_predic - y) * (y_predic-y) w_list=[] loss_list=[] for w in np.arange(0,4.1,0.1): sum_loss = 0 for ...
bf3ea6048172a67bc93dd5e22cb9810a3590f1d8
coder-flag/algorithm
/test5.py
1,920
3.515625
4
# 以二叉树对应的完全二叉树为参照,空白节点处使用#字符填充,使用层次遍历表示二叉树,节点间使用空格分割,如4 2 7 # 3 6 9, # 输出其镜像 """ way1 暴力美学 1.空白节点用#填充,因此可以把它当作完全二叉树 2.完全二叉树除叶节点所在层外,每层节点数满足2**n,n是所在高度高度减1, 如第一层有2**0个节点,第二层有2**1个节点 3.计算层数 sum = 0 ,i = 0 循环:last_sun = sum ,sum += 2**i, i += 1 退出循环: sum >= length 则树的高度为 height = i,叶节点数: leaf_nodes = ...
b597b870b64b27c22f3cbcdd25586f58b054deb8
ema-rose/wordnik-repl
/practice/lists_and_dictionaries/ex4.py
196
3.515625
4
animals = ["aardvark", "badger", "duck", "emu", "fennec fox"] duck_index = animals.index("duck") print duck_index # prints 2 animals.insert(duck_index, "cobra") # will insert at 2 print animals
02f338e66fd548d6b0e2c1ff450d28f90fa2b627
ema-rose/wordnik-repl
/practice/advanced_topics/ex7.py
135
3.71875
4
my_list = range(1, 11) # A negative stride progresses through the list from right to left. backwards = my_list[::-1] print backwards
fd0c7c6d7f6a746e548d305f0756185c0688659c
ema-rose/wordnik-repl
/practice/advanced_topics/ex1.py
279
4.0625
4
my_dict = { "Dad": 1, "Mom": 2, "Jason": 4 } print my_dict.keys() print my_dict.values() # The .keys() method returns a list of the dictionary's keys, and the .values() method returns a list of the dictionary's values. print my_dict.items() #verses .items() which does both
43d3f92b9c2e7961d930e5103f3fe48f260e3eda
ema-rose/wordnik-repl
/practice/bitwise_operations/ex8.py
262
3.921875
4
# A bit mask is just a variable that aids you with bitwise operations # It should check to see if the fourth bit from the right is on... def check_bit4(input): mask = 0b1000 desired = input & mask if desired > 0: return "on" else: return "off"
8de9909921ea21a7af4e90ebf946a8ac3d9d46fa
ema-rose/wordnik-repl
/practice/datetime/ex2.py
179
4.125
4
from datetime import datetime now = datetime.now() print now current_year = now.year current_month = now.month current_day = now.day print now.year print now.month print now.day
b6e5aadb790a693e709fb616056202015a060e77
hisnameispum/DayDate-Generator
/day_generator.py
894
3.765625
4
class DayGenerator: def generate(self, starting_date, starting_day): days = ['Mon', 'Tue', 'Wed', 'Thu','Fri', 'Sat','Sun'] index = 0 for i in range(0,7): if ( days[i] == starting_day): index = i if (starti...
241f1314808b46e63e9e8e8922906d05553cadb3
Daniyal963/Programming-LAB-04
/Question no.6.py
383
3.75
4
print("Daniyal Ali - 18b-096-CS(A)") print("Lab-4 - 09/Nov/2018") print("Question no.6") #Code row_num = int(input("Input number of rows: ")) col_num = int(input("Input number of columns: ")) multi_list = [[0 for col in range(col_num)] for row in range(row_num)] for row in range(row_num): for col in range(c...
f777c7721bd23b2ce699bc1bf067aeba39ca8a02
Sneha-1005/DS
/All Practical/Practical_6.py
1,259
3.6875
4
#NAME : Sneha.S #ROLL_NO : 4073 #CLASS : SYCS nums = [5,4,4073,-1] a = str(input("enter the string i for insertion sort , b for bubble sort , s for selection sort : ")) if a=='i' or a =='I': def insertion_sort(nums): for i in range(1, len(nums)): j = i-1 nxt_ele...
2a16fdad1db1448826fa1a9ead1e8eacc8f7ceb9
ckddbs6991/changyun527
/gameFunction.py
591
3.703125
4
# 모듈 (Module) # 입력을 받는 기능을 하는 함수 def ret_input(): print("1. 만난다 / 2. 안만난다") inp = int(input("입력 : ")) return inp # 선택에 대한 분기하는 함수 def if_show(inp): if inp == 1: print("해피 엔딩") elif inp == 2: print("새드 엔딩") else: print("게임 오버") # 돈 복사 함수 def ret_inputCash(): cash =...
dff8367263ee46866a30dd2fcb8e241d07968d21
chsclarke/Python-Algorithms-and-Data-Structures
/coding_challenge_review/array_practice.py
885
4.28125
4
def mergeSorted(arr1, arr2): #code to merge two sorted arrays sortedArr = [None] * (len(arr1) + len(arr2)) i = 0 j = 0 k = 0 #iterate through both list and insert the lower of the two while(i < len(arr1) and j < len(arr2)): # <= allows function to support duplicate values i...
ad06bbe703fb1d04b12940565dc4721b046fc5d6
chsclarke/Python-Algorithms-and-Data-Structures
/data_structures/open_chaining.py
4,542
4.1875
4
# -*- coding: utf-8 -*- """ This is an example of open chaining implemented with a doubly linked list in python 3. Copyright 2018 Chase Clarke cfclarke@bu.edu """ class Node: def __init__(self,val): self.val = val self.next = None self.prev = None class LList: def __init__(...
775db125f2f01cbfaebc5f493f984062f09989bb
walshmryan/tweet-reader
/tweet-reader.py
2,899
3.796875
4
''' tweet-reader.py Author: Ryan Walsh Version: .11 A script using tweepy.py that analyzes tweets of a given twitter account and identifies most commonly used words ''' import tweepy # number of tweets script searches through numTweets = 500 ''' Gets the auth and access codes for Twitter API codes.txt is organize...
ecf6e1163096db72a175a54d4593c970ac68d8ca
mgaitan/one
/one.py
1,083
3.9375
4
from __future__ import print_function # noqa def one(iterable, cmp=None): """ Return the object in the given iterable that evaluates to True. If the given iterable has more than one object that evaluates to True, or if there is no object that fulfills such condition, return False. If a callabl...
589ff4948bafda92c5f6007c693dd42b4ec5853c
Abel237/automate-boring-stuffs
/automate_boring_stuffs/automate.py
1,384
4.15625
4
# This program says hello and asks for my name. # print('Hello, world!') # print('What is your name?') # ask for their name # myName = input() # print('It is good to meet you, ' + myName) # print('The length of your name is:') # print(len(myName)) # print('What is your age?') # ask for their age # myAge...
c26c1e771e0a5bccaa4dcd2962402297b5f2e502
ValeriyMotornyy/Exercise
/python/sort.py
3,226
4.3125
4
from common import swap """ Functions Map """ def sortingAlgorithms(): return [ ('Bubble Sort', 'bubbleSort'), ('Selection Sort', 'selectionSort'), ('Insertion Sort', 'insertionSort'), ('Merge Sort', 'mergeSort'), ('Quick Sort', 'quickSort'), ('Head Sort',...
b634bd8dad0396c08428d16b5d8d80357f2d070a
jasonding1108/test
/ctof.py
195
4.09375
4
#user input C transfer to F #F = C * 9/5 + 32 temp_c = input ('please input temperature (degree c):') temp_c_float = float(temp_c) temp_f = temp_c_float * 9/5 + 32 print('degree f is', temp_f)
85465a1ea9d18a5fa0e35555ae03871d7dfa88b5
winfr34k/python-tdd-excercises
/excercises/string-calculator/string_calculator.py
1,277
4.0625
4
import functools def add(numbers: str) -> int: delimiter, string_numbers = _extract_delimiter_and_numbers_from_input(numbers) numbers_without_newlines = string_numbers.replace("\n", delimiter) integer_numbers = [int(number or 0) for number in numbers_without_newlines.split(delimiter)] negative_number...
664b3505d4a47d9f899dc5242c7f4e6a0e3e2369
oscar-cortez/python-guess-number
/Proyecto1.py
1,824
4.0625
4
#coding: utf-8 import random print "*"*70 print "*"*70 print "Bienveido al menu principal" print """Intruccciones : El juego consiste en adivinar un numero generado aleatoriamente y solo tendras 3 intentos pasaras por 3 niveles que son : * Facil * Medio en el nivel facíl el numero que se genera esta en el r...
9249bc4e398bef1b9031782229c12ba63a12be71
huihui7987/suanfa
/gfhgfh.py
1,696
3.734375
4
# -*- coding:utf-8 -*- ''' def upstairs(): n = int(input()) for i in range(n): m = int(input()) if m <= 0: return 0 elif m==1: return 1 elif m>=2: a = 0 b = 1 a,b = b,a+b return b def jump(n): #递归 if n <= 3: return n-1 el...
db31469c2a0a7810db6d65c47229d489188687db
evgeniikotliarov/python_example
/method_user_add.py
1,161
4.21875
4
# pizza = ['pipperoni', 'chilli', 'mozarella'] # print(pizza) # for piz in pizza: # print(piz + " I like it") # # for pis in pizza: # print("Do you like " + pis.title() + ".\n") # print("Bla bla bla") # # for value in range(1,21): # print(value) # # for value in range(1,9): # print(value) # # numbers = ...
cf637d6d43925d8078ab75ecaea02db403f86c2b
saikirankondapalli03/pythonmath
/chapter 4/HW04-practise2.py
736
3.640625
4
from sympy import Symbol, pprint, init_printing def print_series(n): # Initialize printing system with reverse order init_printing(order='rev-lex') x = Symbol('x') series = x for i in range(2, n+1): series = series + (x**i)/i pprint(series) from sympy import simplify from sympy import Symb...
3ff3f10ea73afba3d28f0fe60aab194cddbc1ed0
saikirankondapalli03/pythonmath
/chapter 5/HW05-02.py
1,601
3.859375
4
''' @author Sai File name: HW05-02.py Date created: 7/22/2019 Date last modified: 7/22/2019 Python Version: 3.1 This file is all about proof of law of large numbers in python for law of large numbers please refer to a) https://en.wikipedia.org/wiki/Law_of_large_numbers b) https://en.wikipedia.org/wiki/Law_of_large_nu...
699a0acecc6c9d4416d9137aab020493d581334c
saikirankondapalli03/pythonmath
/chapter 1/HW01-05.py
806
4.09375
4
''' @author Sai File name: HW01-05.py Date created: 7/10/2019 Date last modified: 7/10/2019 Python Version: 3.1 This file is for giving exit power to the user for odd numbers ''' import sys initial_value= 0 offset= 9 def print_odd(): lst= [] global initial_value global offset while initial_value < o...
6ca89b84df84a17e38824bb63ac96b566fbde8eb
jw2633/Python-Coursework
/Labs/Blackjack.py
336
4.03125
4
hand = [] while True: card = eval(input("Please enter a card value: ")) hand.append(card) if sum(hand) >= 21 or len(hand) == 3: break print("Your final hand is:", hand, "\nIts value is: ", sum(hand)) if sum(hand) > 21: print("Too high!") elif sum(hand) == 21: print("Good!") else: pr...
ae67021336a700fd27b1756b7ab4b3d632bcbf77
jw2633/Python-Coursework
/Homework/HW5.py
1,310
3.90625
4
#James Wang #I210 #HW5 #5.29 # Returns a list of all first names (in a list) and all last names (in a list) def lastfirst(lst): lastNames = [] firstNames = [] for x in lst: indx = int(x.index(',')) lastNames.append(x[indx + 2: ]) firstNames.append(x[0:indx]) print([lastNames, f...
d02c05af44fa400ef4421819237b90e9376b924a
macwascdv/zadania-python-1
/zadanie 3.py
927
3.828125
4
print("Ten program zamień temperaturę na inna skale") decyzja="t" while(decyzja=="t"): try: temperatura = input("Wybierz skalę początkową - f/c: ") if (temperatura=="f"): x= int(input("wpisz temperaturę: ")) y=(x-32)*(5/9) print("Twoja temperatura w Celsjuszach wynosi: ") ...
a43b03a426a7d436e4eb2cf2eb172d9c7b4b3631
macwascdv/zadania-python-1
/przelicznik predkosci.py
566
3.828125
4
def km_ms(vk): return vk*1000/3600 def ms_km(vm): return vm*3.6 print("Ten program sluzy do przeliczenia km/h na m/s, oraz m/s na km/h") decyzja=input("Wybierz predkosc, jaka chcesz uzyskac - kmh/ms: ") if (decyzja=="kmh"): x=int(input("wpisz wartosc predkosci m/s: ")) x1=ms_km(float(x)) print("Twoj...
47df09037c3487f3da005af9bb4b414f986a1bd3
SivaCn/small.codes
/Python/reverse_list_of_strings.py
571
3.984375
4
#! /usr/bin/python ############################################################################## ## ## A program to perform the following ## ## inp = ['abcd', 'efgh', 'ijkl'] ## ## out = ['lkji', 'hgfe', 'ccba'] ## ############################################################################## inp = ['abcd', 'efgh',...
1d6c27c708d5eeef4301f55804886353d170eb84
SivaCn/small.codes
/Python/stack_complete.py
1,761
3.625
4
class StackError(Exception): pass class MyStack(object): def __init__(self, sequence=None, max_size=-1): self.stack = list(sequence) if sequence else list() self.MAX_LIMIT = max_size if max_size > 0 and max_size != -1 else None def push(self, item): if self.MAX_LIMIT and len(...
d63e7b864e9737056f9795f0ae7380ca16cdecad
SivaCn/small.codes
/Python/binary_search.py
1,308
3.625
4
#! /usr/bin/python """ testlist = [0, 1, 2, 8, 13, 17, 19, 32, 42,] """ # -*- coding: utf-8 -*- __author__ = "Siva Cn (cnsiva.in@gmail.com)" __website__ = "http://www.cnsiva.com" class Binary: def __init__(self, _list): self._list = _list self.indices = [] self.temp_list...
a9ed334e298a813e91ad05a499bdaf347259f534
carlosmaestro/uri-online-judge
/1018/1018.py
250
3.828125
4
# -*- coding: utf-8 -*- default_notas = [ 100, 50, 20, 10, 5, 2, 1 ] value = int(input()) print(value) for nota in default_notas: count = int(value / nota) print("{} nota(s) de R$ {},00".format(count, nota)) value -= count * nota
18580ebee3cc7defeea8d27c2586ffaa3147a706
lonely-harry/test
/classmodule/classex2.py
679
3.796875
4
#!/usr/bin/env python #encoding=UTF-8 import sex as sex class Person(object): total_person=0 def __init__(self,name,sex,province): print "init the class" self.name=name self.sex=sex self.province=province Person.total_person +=1 def get_name(self): return s...
f554c5e9030b45d35845db1a18f3586072a8b846
lonely-harry/test
/liaoxuefeng/demo1.py
432
3.859375
4
#!/usr/bin/env python #encoding=UTF-8 h=input('请输入身高(cm):') w=input('请输入体重(KG):') height=float(h) weight=float(w) bmi = weight/((height/100)**2) if bmi<18.5: print ('过轻') elif (bmi >=18.5) and (bmi<25): print ('正常') elif (bmi >=25) & (bmi<28): print ('过重') elif (bmi >=28) and (bmi<32): print ('肥胖') elif bmi >...
7ba5482e8063e9a3760f10b8d45f2cc1ca764a8b
DevHosts/WebScraping
/Testes_python-master/Testes_python-master/python_avancado/modulo2/remove_inicio_fim.py
208
3.75
4
texto = ' python ' print(texto.strip()) texto2 = '-----python2-----' print(texto2.strip('-')) texto3 = '-------python3' print(texto3.lstrip('-')) texto4 = 'python4-----' print(texto4.rstrip('-'))
49cdf0343db02e0350386a897639010b2c4566d2
v-alan-m/OpenCV_image_and_video_processing
/load and resize image/load_image.py
979
3.765625
4
import cv2 # Load the image # import in color (2nd arguement: 0=black and white, 1=color, -1:alpha transparency) img = cv2.imread("galaxy.jpg",1) # The image is turned in a numpy array print(type(img)) # The numbers in the first array denote the greyscale intensity of the pixels # Along the rows and the columns ...
da3d206159e97dbb0641a699e5efbe1613f20217
Rachit1606/PythonMiniProjects
/EmailSender.py
443
3.515625
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 22 02:18:30 2020 @author: HP """ import smtplib to = input("Enter the email of the recipitant :- ") content = input("Enter the content for the mail :- ") def sendEmail(to,content): server = smtplib.SMTP('smtp.gmail.com',587) server.ehlo() server.starttls(...
5c106e29b7354c2ad3f1d06044a6f48979205163
xianyu2hao/pythonProject4Inheritance_polymorphism
/07.图例实现.py
1,260
3.90625
4
# 设计一个game类 # 1.设计属性:定义一个类属性top_score记录游戏的历史最高分;定义一个实例属性play_name记录当前游戏玩家姓名。 # 2.设计方法:类方法show_top_score显示最高分;静态方法show_help显示游戏帮助信息;实例方法start_game开始当前玩家游戏。 # 3.主要程序步骤:1)查看帮助信息;2)查看历史最高分;3)创建游戏对象,开始游戏 class Game: """游戏类""" # 类属性,记录游戏的历史最高分 top_score = 0 def __init__(self,player_name): self.player_...
de40984bdbfc7910345d1073bedfda50adc1e27c
xianyu2hao/pythonProject4Inheritance_polymorphism
/06.探究_实例对象.py
363
3.796875
4
class Person(object): def __init__(self,name): self.name = name def eat(self): print("%s爱吃美食"% self.name) xiao_ming =Person("小明") # 由类创建的对象在内存空间中实际存在,故称为 实例对象 print(xiao_ming) # 其属性称为 实例属性 print(xiao_ming.name) xiao_ming.eat() # 其方法成为 实例方法
737f0e03cbb4312d31c10d6bcf1ac4fdf212794c
hariprasadonline/test
/src/inputTest.py
125
3.625
4
''' Created on Aug 6, 2015 @author: hmadas ''' #import prompt #x = prompt.for_inp("enter number") #print("Answer:"+str(x))
4834112cb80465450bcc7fa9931a078ce17622dd
sdomala/Animal-Survival
/Fruit.py
1,045
3.5
4
# Fruit class for Term Project # Name: Saisiddarth Domala # andrewID: sdomala # Section: O # Last modified 12/5/18 # Citation: Got image from # http://clipart-library.com/transparent-fruit-cliparts.html import pygame import random import math # Fruit class with properties class Fruit(pygame.sprite.Sprite): # Con...
99baf42fd94c6b3efc7d33836c02664ff522f9d7
zLordelo/pythonExercise
/ex008 - MEDIDAS.py
165
3.9375
4
num = float(input('Digite um valor em metros: ')) cm = num * 100 mm = num * 1000 print('O valor de {}m é igual a {:.2f}cm e {:.2f}mm.'.format(num, cm, mm))
9fcbf60f815ef8c9ac415eccd2faaeadaad35005
zLordelo/pythonExercise
/ex080 - LISTA ORDENADA SEM REPETIÇÕES.py
864
4
4
print('=' * 50) print(f'\033[1;31m{"LISTA ORDENADA SEM REPETIÇÕES":^50}\033[m') print('=' * 50) '''Exercício Python 080: Crie um programa onde o usuário possa digitar cinco valores numéricos e cadastre-os em uma lista, já na posição correta de inserção (sem usar o sort()). No final, mostre a lista ordenada na te...
c47a9b6c24b6298de5becdc463595cfe927d2672
zLordelo/pythonExercise
/ex005.1 - CALCULO COM NÚMEROS.py
469
4.0625
4
x = int(input("Digite um número inteiro: ")) y = int(input('Digite outro número inteiro: ')) s = x + y sub = x - y m = x * y d = x / y e = x ** y di = x // y r = x % y print("Olá, os valores digitados foram {} e {}.".format(x, y)) print('A soma é {}, a subtração é {}, o produto é {} e a divisão é {} e a p...
a5a3cd67d11723756678235d2edeaeb9be5e6ba9
zLordelo/pythonExercise
/ex075 - ANÁLISE DE DADOS EM UMA TUPLA.py
758
3.8125
4
print('=' * 50) print('\033[1;31mANÁLISE DE DADOS EM UMA TUPLA\033[m'.center(60)) print('=' * 50) par = 0 valores = (int(input('Digite um número: ')), int(input('Digite um número: ')), int(input('Digite um número: ')), int(input('Digite um número: '))) print(f'O número 9 apareceu \033[1m{valores.count(9)} VEZ...
64bcc5f7bad601be52f49e61df6f00d88dcd3720
zLordelo/pythonExercise
/ex062.py
631
3.75
4
print('=' * 50) print('\033[1;31mPROGRESSÃO ARITMÉTICA V2.0 - WHILE\033[m'.center(60)) print('=' * 50) primeiro = int(input('Digite o primeiro termo da PA: ')) razao = int(input('Digite a razão da PA: ')) termo = primeiro cont = 1 total = 0 mais = 10 while mais != 0: total = total + mais while cont...
46527afa666929fd45c8712bba528a5a656411b1
zLordelo/pythonExercise
/ex095 - APRIMORANDO OS DICIONÁRIOS.py
1,986
3.734375
4
print('=' * 50) print(f'\033[1;31m{"APRIMORANDO OS DICIONÁRIOS":^50}\033[m') print('=' * 50) '''Exercício Python 095: Aprimore o desafio 93 para que ele funcione com vários jogadores, incluindo um sistema de visualização de detalhes do aproveitamento de cada jogador.''' time = list() player = dict() gols = list...
a8ebb83b88b4953aa7202d518f11b9e854400811
zLordelo/pythonExercise
/ex027 - USO DO SPLIT.py
263
3.765625
4
nome = str(input('Digite seu nome: ')).strip() n = nome.split() print('=' * 80) print('Olá {}, muito prazer em te conhecer!'.format(n[0])) print('O seu primeiro nome é {}.'.format(n[0])) print('O seu último nome é {}.'.format(n[-1])) print('=' * 80)
05d493a9cf266a4fe5718f03b860584f376fec05
zLordelo/pythonExercise
/ex104 - VALIDANDO ENTRADA DE DADOS EM PYTHON.py
670
4.03125
4
print('=' * 50) print(f'\033[1;31m{"VALIDANDO ENTRADA DE DADOS EM PYTHON":^50}\033[m') print('=' * 50) '''Exercício Python 104: Crie um programa que tenha a função leiaInt(), que vai funcionar de forma semelhante ‘a função input() do Python, só que fazendo a validação para aceitar apenas um valor numérico. Ex:...
956f955aa2a8b762b313867a67d73055568119cd
zLordelo/pythonExercise
/ex057.py
398
3.765625
4
print('=' * 50) print('\033[1;31mValidação de dados\033[m'.upper().center(60)) print('=' * 50) sexo = str(input('Digite seu sexo [M / F]: ')).strip().upper()[0] while sexo not in ('MmFf'): sexo = str(input('\033[1;31m[ERRO] Sexo inválido, digite apenas opções sugeridas!\033[m\nDigite seu sexo [M / F]: '))....
5f27828605ac9c12c3fc964dfce6a69422b8e324
zLordelo/pythonExercise
/ex082 - DIVIDINDO VALORES EM VÁRIAS LISTAS.py
880
4
4
print('=' * 50) print(f'\033[1;31m{"DIVIDINDO VALORES EM VÁRIAS LISTAS":^50}\033[m') print('=' * 50) '''Exercício Python 082: Crie um programa que vai ler vários números e colocar em uma lista. Depois disso, crie duas listas extras que vão conter apenas os valores pares e os valores ímpares digitados, respectiva...
0799aa9f0d5d689d1f45bdeb2c490bfc9aa367a7
zLordelo/pythonExercise
/ex015 - ALUGUEL DE CARRO.py
293
3.8125
4
dias = int(input('Por quantos dias o carro foi alugado? ')) km = float(input('Digite a quantidade de quilometros (Km) rodados? ')) total = (dias * 60) + (km * 0.15) print('O carro foi alugado por {} dias e rodou {:.2f}Km. O valor total a pagar é de R$ {:.2f}.'.format(dias, km, total))
ab1a332dbec4515e41517180fb368ca170e15032
zLordelo/pythonExercise
/teste-dev media.py
1,787
3.984375
4
'''Enunciado da questão: Faça um algoritmo para ler um número que é um código de usuário. Caso este código seja diferente de um código armazenado internamente no algoritmo (igual a 1234) deve ser apresentada a mensagem "Usuário inválido!" e o sistema será encerrado. Caso o código seja correto, deve ser lido outro va...
ed85bcc015579ff9d50a86596b81982c94249fc9
zLordelo/pythonExercise
/ex081 - EXTRAINDO DADOS DE UMA LISTA.py
835
4.03125
4
print('=' * 50) print(f'\033[1;31m{"EXTRAINDO DADOS DE UMA LISTA":^50}\033[m') print('=' * 50) '''Exercício Python 081: Crie um programa que vai ler vários números e colocar em uma lista. Depois disso, mostre: A) Quantos números foram digitados. B) A lista de valores, ordenada de forma decrescente....
61199d9b5c8a1bf99c3d0482ebfb71cec6fff2aa
jonathan-ship/SimPy
/assignment/carwash.py
7,531
4.15625
4
""" Carwash example. Covers: - Waiting for other processes - Resources: Resource Scenario: A carwash has a limited number of washing machines and defines a washing processes that takes some (random) time. Car processes arrive at the carwash at a random time. If one washing machine is available, they start t...
3f839a04f66c2d50bdf64949186b7cb6b4c64a90
jonathan-ship/SimPy
/exam/2019-15824_prob4.py
5,797
3.53125
4
""" Jiwon Baek Topics in Ship Production Engineering Final Exam Problem 4 """ import simpy import numpy as np import pandas as pd import matplotlib.pyplot as plt class Part: def __init__(self, id, enter_time): self.id = id self.enter_time = enter_time class Source: def ...
46604d92158dda9b994a98c88b1b8771bdba8962
jonathan-ship/SimPy
/exam/2019-15824_prob1_2.py
6,197
3.5
4
""" Jiwon Baek Topics in Ship Production Engineering Final Exam Problem 1-Numerical Soulution """ import simpy import numpy as np import math import pandas as pd import matplotlib.pyplot as plt RANDOM_SEED = 42 WEEKS = 4 # Simulation time in weeks SIM_TIME = WEEKS * 7 * 24 * 60 # Sim...
76db68e7e421fbd3a80e5c3ccde3b86a2f34c4d4
onyb/cpp
/HackerRank/Domains/Data_Structures/Arrays/sparse-arrays.py
275
3.59375
4
#!/usr/bin/env python3 N = int(input()) memory = [] for each in range(N): memory.append(input()) Q = int(input()) for each in range(Q): query = input() if query not in memory: print(0) else: print( memory.count(query) )
334775d9984dec0a41a64507bf47a335d0441a4d
onyb/cpp
/DSATP/LinkedList/CH3_S6_Single_Linked_Lists.py
6,810
4.375
4
class Node: """ Node of a single linked list """ def __init__(self): """ Constructor for a linked list node :return: None """ self.data = None self.next = None def set_data(self, data): """ Method for setting the data field of the nod...
d8326d7dd0f2ea05957104c482bacf2776968aff
optionalg/HackerRank-8
/time_conversion.py
987
4.125
4
''' Source: https://www.hackerrank.com/challenges/time-conversion Sample input: 07:05:45PM Sample output: 19:05:45 ''' #!/bin/python import sys def timeConversion(s): meridian = s[-2] time = [int(i) for i in s[:-2].split(':')] # Converting each time unit to integer and obtaining # each unit by split...
a7bb74ca88969bec57d281f73647742472dd4ab0
optionalg/HackerRank-8
/compare_the_triplets.py
903
3.90625
4
''' Source: https://www.hackerrank.com/challenges/compare-the-triplets ''' #!/bin/python import sys def solve(a0, a1, a2, b0, b1, b2): # Complete this function alice_scores = 0 bob_scores = 0 alice_scores, bob_scores = score_comparer(a0, b0, alice_scores, bob_scores) alice_scores, bob_scores = ...
4969df917b1c1a2ab20badef8d0300ce5b06fcd4
opent03/random_semi-interesting_stuff
/Linear Regression/linreg-ana_and_bgd--final.py
4,646
3.671875
4
""" Basic linear regression, optimization using analytical method or gradient descent Tested on sklearn's simplified boston dataset """ from sklearn.datasets import load_boston from sklearn.model_selection import train_test_split from sklearn import preprocessing import pandas as pd import math import matplotlib matpl...
2a3793c138775124b4ffc3fa8fb6bf3195e4247b
skyaiolos/python.performence.optimize
/python_performance_optimize_skill/1.2_quick_sort.py
1,069
4.03125
4
__author__ = "Jianguo Jin (jinjianguosky@hotmail.com)" # !/usr/bin/python3 # -*- coding:utf-8 -*- # Created by Jianguo on 2017/7/14 """ Description: 排序,快速排序 对应的库函数 : 排序, sorted """ from python_performance_analysis.timer import Timer def quick_sort(lists, left, right): ...
537f9a187dce6991812518c7dd2bef2df5d3e4f2
skyaiolos/python.performence.optimize
/python_performance_analysis/1.2_time_demo.py
489
3.53125
4
__author__ = "Jianguo Jin (jinjianguosky@hotmail.com)" # !/usr/bin/python3 # -*- coding:utf-8 -*- # Created by Jianguo on 2017/7/13 """ Description: 1.2 Python 自带模块 time. """ import time print(time.time()) print(time.asctime(time.localtime(time.time()))) print(time.asctime(time.localtime(0))) # 1499925...
d152517ac6f396adabfa325f368a8eb31f953b53
dennisnderitu254/Mathematics-Hackerrank-Solutions
/sherlockPermutations.py
703
3.546875
4
#!/bin/python3 import os import sys import math def factorial(n): if(n==0): return (1) else: return (n*factorial(n-1)) # Complete the solve function below. def solve(n, m): #x = m+n-1 #y = factorial(x) #z = factorial(m-1) #w = factorial(n) #return ((y//(z*w))%(10**9 + 7)) ...
4afa187e619f62487455e1c065165c496678a24b
sarahkorb/PythonProjects
/Lab2_Map_Visualisation/city.py
737
3.96875
4
#City Class #Author: Sarah Korb #Oct. 16th, 2018 #Profesor Cormen, CS1 from cs1lib import * class City: def __init__(self,code,name,region,population,latitude,longitude): #initialize all instance variables with their CORRECT formats (i.e integers, floats etc) self.code = str(code) ...
125c6d55eaeb703badcfa81d6550c7dd49f6e1bd
sarahkorb/PythonProjects
/Lab2_Map_Visualisation/checkpoint.py
2,028
3.984375
4
#Lab 2 CHECKPOINT #program to write world cities with their population,langitude, longitude in a text file #Author: Sarah Korb #Oct. 16th, 2018 #Professor Cormen, CS1 from cs1lib import * from city import * #import methods from City class in_file = open("world_cities (1).txt") #open the text file with the i...
9b621623659799af22445bef36ab23b29bd27a25
sarahkorb/PythonProjects
/Lab2_Map_Visualisation/extra_credit.py
5,213
3.828125
4
from cs1lib import * from sort_cities import world_city_list img = load_image("world.png") #save reference retunred by load_image to be used as paramter in draw_image function i = 0 draw = True WINDOW_WIDTH= 720 #Window width and height are constants t...
28e3c71810879d45591952b1460ba74aac9f3847
LEKSHMI1996/project-staff-management-
/face tracking .py
1,741
3.828125
4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 # draw an image with detected objects def draw_image_with_boxes(filename, result_list): # load the image data = pyplot.imread(filename) # plot the image pyplot.imshow(data) # get the context for drawing boxes ax = pyplot.gca() # plot each b...
7e8cb8e7a633e5579381001d454342893005a423
Jodav9/RadMap_Scripts
/USGSelev.py
4,913
3.5
4
import os import sys import urllib, urllib2 # simple XML parsing from xml.dom import minidom from math import radians, cos, sin, asin, sqrt def haversine(lon1, lat1, lon2, lat2): """ Calculate the great circle distance between two points on the earth (specified in decimal degrees) """ # convert de...
cb2e13c09bc1cda020fcc271d1acd12537533812
shubhanshu-gupta/2015lab1
/House price prediction.py
1,698
3.84375
4
# coding: utf-8 # In[23]: import matplotlib.pyplot as plt import numpy as np import pandas as pd from sklearn import datasets, linear_model # In[24]: def get_data(file_name): data = pd.read_csv("C:\Users\Shubhanshu\Desktop\houserate.csv") X_param = [] Y_param = [] for single_square_feet, single_pr...
ed39f7a1fc5b1314cdd7e9790347c8fd87b53820
harrowschool/intro-to-python
/lesson6/task4.py
528
3.515625
4
''' Homework Task - Calculator - Define four subroutines - add, subtract, multiply, divide that add multiply etc two numbers and return the result. Each should have two integer number arguments. - The user is asked to input two numbers. These numbers will be passed as arguments into one of the subroutines. - The ...
bc4ef10553a6ee41e419056de9fabadc535fafe5
harrowschool/intro-to-python
/lesson2/task1.py
258
3.875
4
# Task 1a - Add comments to this code to predict what it will do. print(8 + 2) print( 8 - 2) print(8 * 2) print(8 / 2) print(8 // 2) # Task 1b - Write code that calculates and outputs the following numbers as answers to a calculation: 2001, 1024, 42, 15
9bc2d5011ccdacbf7e172ab4c0245c8b5f437f3f
harrowschool/intro-to-python
/lesson3/task2.py
620
4.3125
4
# Task 2a # Add comments to the code to explain: # What will be output when the code is run? # In what circumstances would the other output message be produced num1 = 42 if num1 == 42: print("You have discovered the meaning of life!") else: print("Sorry, you have failed to discover the meaning of life!") ...
208e90cf529acd633dd9dcf5b623f3b042640ed1
PrinceRios2000/CST205-Projects
/webscrape/taskX.py
1,128
3.5
4
# #Authors: Prince Rios and Alex Espinoza # #Last modified: 13 March 2020 # #Description: This code uses multiple libraries to import necessary classes. A variable raw is created to hold the text of the code for the website. # #Then, soup is created to hold the html of the website. Finally, the code uses the find_all()...
a9973f504e95865e620ae4a14992bc1c221cd84a
PrinceRios2000/CST205-Projects
/lab3/task2.py
496
3.859375
4
color_dictionary = { "Red":(250, 50, 7), "Green":(0, 255, 0), "Blue":(0, 0, 250), "Magenta":(250, 0, 250), "Cyan":(0, 250, 250), "Yellow":(250, 250, 0) } print(f'The Blue channel of Magenta has a value of {color_dictionary["Magenta"][2]}.') print(f'The Green channel of Yellow has a value of {color_dictionar...
48e5fe743d1634a33c7d75067bb19ff0587bf286
PrinceRios2000/CST205-Projects
/lab/task1.py
229
3.515625
4
from PIL import Image im = Image.open('image.png') def negative_image(pixel): return tuple(map(lambda pixels: 255 - (pixels//2), pixel)) negative_list = map(negative_image, im.getdata()) im.putdata(list(negative_list)) im.show()