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
f4ca6df422a0a992959037eb3862781d6d73345d
rescenic/Softuni-Python-v2
/python-advanced/ZZ - Exam - Prep/16 Dec 2020/01.py
1,815
3.546875
4
from collections import deque class Group: def __init__(self) -> None: self.males = None self.females = None self.matches_count = 0 def read_males(self): self.males = deque(int(x) for x in input().split()) def read_females(self): self.females = deque(int(x) for x ...
4817a912eeb218f5ec7ed8e23c1062b9d6453718
rescenic/Softuni-Python-v2
/python-advanced/01 - Lists as Stacks and Queues - Lab/04. Water Dispenser.py
758
3.78125
4
from collections import deque people = deque() liters_in_dispencer = int(input()) while True: command = input() if command == 'Start': break people.append(command) while True: command = input() if command == 'End': break if command.isnumeric() and len(people) > 0: lite...
e6461cd3e120547477f17e75287254d19369d4d0
rescenic/Softuni-Python-v2
/python-fundamentals/ZZ Final Exam Prep/01. Secret Chat.py
1,056
4
4
def insert_space(s: str, i: int) -> str: s = s[:i] + ' ' + s[i:] print(s) return s def reverse(s: str, substring: str) -> str: if substring in s: reversed_substring = substring[::-1] s = s.replace(substring, '', 1) s += reversed_substring else: print('error') ...
0329b734719584b484bd7102626bcc6a6bf84f97
rescenic/Softuni-Python-v2
/python-advanced/ZZ - Exam - Prep/24 October 2020/03.py
803
3.609375
4
def best_list_pureness(nums, k): from collections import deque def get_pureness(nums): return sum((i*n for i, n in enumerate(nums))) best_rotation = 0 best_pureness = get_pureness(nums) nums = deque(nums) k = min(len(nums), k) for rotation in range(k+1): current_pureness =...
22cfdbf1bcde834799522b82af23ccec03a45e7f
AmadiGui/caelum
/menu.py
368
3.703125
4
import jogo_adivinha import forca print('\n***********************') print('* MENU *') print('***********************\n') print("1. Adivinhacao") print("2. Forca") escolha = int(input("Qual jogo quer jogar. Digite um numero:")) if escolha == 1: #jogar adivinhacao jogo_adivinha.jogar() elif es...
8029501fe2ffd4db9d063992f2cfc8876d7345ec
mmikolajczak/adventofcode2018
/adventofcode_2018/solutions/d_2_2.py
885
3.609375
4
def chars_difference(str1, str2): assert len(str1) == len(str2) diff = 0 for c1, c2 in zip(str1, str2): if c1 != c2: diff += 1 return diff def common_sequence(str1, str2): assert len(str1) == len(str2) res = ''.join([str1[i] for i in range(len(str1)) if str1[i] == str2[i]])...
1af1a0b1608933e08e56b512498e8eb6fd94210d
jaddoueik1/masonite-project
/storage/public/sorting.py
3,328
3.78125
4
#liste=['name','total_cases','active_cases','recovered_cases','total-deaths'] def tri_selection(liste,croi_decroi,tri_par): """(liste=liste that you wish to sort , croi_decroi = 1 si croissant 0 sinon , tri_par= ('d' for death_rate)('t' for total cases)('a' for active cases)('r' for recovered cases)('n' for name...
5686f75c0268323808322ab85d0335580960679c
mau88258/pratice
/exercise/encrypt.py
830
4.0625
4
#基礎加密程式 import string def encrypt(text,encrydict): #加密函數 cipher=[] #建立空字串 for i in text: #將待加密文字一一加密後丟至串列中 ciphertext = encrydict[i] cipher.append(ciphertext) return ''.join(cipher) #將串列轉為字串 abc = string.printable[:-5] #建立全英文符文字元,不包括不可列印...
e5443c0a641b110e8acc89328df46787f1975660
nimve/BioSim_G27_Trude_Nina
/src/biosim/animals.py
10,505
3.5
4
# -*- coding: utf-8 -*- """ """ __author__ = "Trude Haug Almestrand", "Nina Mariann Vesseltun" __email__ = "trude.haug.almestrand@nmbu.no", "nive@nmbu.no" import numpy as np from math import exp class Animal: """Create animals with weight and age, and have them perform actions like eating, losing weight an...
72f6ecdabe68de3f216b47c50f029dbb20d634cb
KrisNguyen135/PythonSecurityEC
/PythonRefresher/01-control-flow/loops.py
829
4.5625
5
#%% While loops check for the conditions at each step. x = 1 while x < 10: print(x) x += 1 print('Loop finished.') #%% For loops are used to iterate through a sequence of elements. a = [1, 2, 3] for item in a: print(item) print() #%% range(n) returns an iterator from 0 to (n - 1). for index in range(len(a...
5e23af3a92fafcf8dfe0b3b038e6c8cbd99df6cd
shuvankarroy/graphics_python
/Circle Drawing Algorithm/Bresenham_circle_drawing_algorithm.py
3,305
4.3125
4
# Bresenham's circle drawing algorithm from graphics import * import time import ctypes user32 = ctypes.windll.user32 scrnWidth, scrnHeight= (user32.GetSystemMetrics(0)-100), (user32.GetSystemMetrics(1)-100) print("Circle drawing using Bresenham's algorithm : ") center = tuple(int(x.strip()) for x in input("...
4eede6f87615a8fd6e1395e24bd3fbb17aedcd43
garrettkinman/ECSE-325-Lab
/Lab_2/bits.py
7,011
4.34375
4
# This program calculates the number of bits necessary to represent the inputs and the output # of the MAC unit. # It takes ThuFrilab2-x.txt and ThuFrilab-y.txt as the inputs. # Author: Garrett Kinman import math import re # ~~~ FUNCTION DECLARATIONS ~~~ # function that takes in a file name and returns the list of ...
091d6039a4515cfa4e7e91eaac0e22a8ffa3a0d6
marykatefain/csv-db
/code.py
1,920
4.09375
4
import csv import sqlite3 from sqlite3 import Error def readFiles(filename): first_names = [] last_names = [] dob = [] favorite_colors = [] cat = [] with open(filename) as csvDataFile: csvReader = csv.reader(csvDataFile) for row in csvReader: first_names.append(row...
13de7ede93d8a340b1f72588b14b591f035b09ee
ml250271/test_23Jan
/models.py
491
3.78125
4
class Comment(object): def __init__(self, text, date): self.text = text self.date = date def __repr__(self): return "email: {}, first_name: {}".format( self.text, self.date ) comment1 = Comment("comment1", "2018-01-01") comment2 = Comment("comment2",...
e0c1afc5f7c05eaf3d56f7211c3003f4c95038d9
vishal28ap/python
/exceptionsAndFiles.py
2,163
3.9375
4
###EXCEPTIONS### #try/except block# try: num1=7 num2=0 print(num1/num2) print('Done') except: print('zerodivision error') try: num1=7 num2=0 print(num1/num2) print('Done') except ZeroDivisionError: print('zerodivision error') except ValueError: print('Value error') #finally# #bo...
690f4b747e02d8d90544fce1c92e03edd0ce4578
vishal28ap/python
/basics.py
1,757
3.953125
4
#high level programming language #processed at runtime by interpreter, not complined """ multi line comments for documentation mostly. Actually a DockSting """ #No indentation is used(;) #hello world program# print('Hello World!') #spaces around operators optional, but makes it easier to read 2+2 5 + ...
11de214bbe7ec70ef7bb1ce0a139d78b01c7ea02
scott45/checkpoint1-Amity
/amityapp/tests/test_amity.py
13,457
3.640625
4
__author__ = 'scotty' import os import unittest from amityapp.amity import Amity # tests all functionality of amity class in there defined methods class TestAmityFunctionality(unittest.TestCase): def setUp(self): self.amity = Amity() # tests that the class is clean and holds nothing at the time its...
6a19ce346d2c3a0f0524234f55085a4403fac96c
tzp-software/gamelib
/gamelib/cards.py
2,596
3.734375
4
''' __name__ = 'gamelib.cards.py' ''' import random ERR_SUIT = 'Need a suit' ERR_RANK = 'Need a rank' class Card(object): '''Represents a standard Playing card. h = hearts c = clubs d = diamonds s = spades A = ace = 1 2-10 = 2-10 J = jack = 11 Q = queen = 12 K = ...
741254a04667a53c0a22ed090f41af51894c6249
Armadillan/stispectrograph
/stispectrograph/visualisation.py
3,227
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt import matplotlib.colors def wavelength_to_rgb(wavelength, gamma=0.8): ''' Taken from http://www.noah.org/wiki/Wavelength_to_RGB_in_Python This converts a given wavelength of light to an approximate ...
ed92d1032a10a999c142c8c3986e3e05adde4e6b
BK-Kong/-
/basic1.py
4,899
3.71875
4
def Buymanual(Money, CurValue, MySto): # 정확한 숫자를 입력할 때까지 try -> except 예외구문 적용 while True: try: Amount = int(input("주식을 몇 주 구입하시겠습니까? : ")) # 입력받은 값이 본인이 가진 돈 보다 많은지 확인 if (Money - Amount * CurValue) >= 0: break # 본인이 가진 돈으로 충분히 살 수 있다면 구매 진행 ...
5bb9718a15136665cfe1bdbc5b4c9112377b668c
nimish1499/code
/hackerearth/basic of IO/Factorial.py
121
3.828125
4
num = int(input()) fact = 1 if 1 <= num <= 10: for i in range(1, num + 1): fact = fact * i print (fact)
7543d8a9ca98d9d179c2397386a135922e2d4548
nimish1499/code
/hackerearth/Basics of Implementation/Zoos.py
242
3.546875
4
s =input() if len(s) < 21: if (2*s.count('z')) == s.count('o'): print("Yes") else: print("No") else: print("No") #https://www.hackerearth.com/challenges/competitive/november-circuits-19/algorithm/is-zoo-f6f309e7/#
e0b92d6d98b67ecf5e09a43a769a238337d0f1db
dkrieger-personal/tkp
/python/sandbox/hangman-base code.py
1,450
4.09375
4
import random print("hangman!") #choose a word (display length) #guess a letter #determine whether it's right or wrong #insert the correctly guessed letters #count tbe incorrect guesses until it has exceeded its maximum #continue guessing and repeat def getword (): words= ["green", "yellow", "chicken","gentlemen"] ...
717304e407a26478a2149669f29fbda569074a92
abielak95/100Python-Mini-Projects
/8. LoveCalculator.py
1,132
3.90625
4
#LOVE calculator. #Type two names and compare them. firstName = list(input("Type first name: ")) secName = list(input("Type second name: ")) vowels = "aeiou" consonants="qrtpsdfghjklzxcvbnmy" points = 0 def counting(name, example): counter = 0 for i in range(len(name)): if name[i] in example: ...
6682fb706c6c9d27f73c232c7116dd631fd26109
drwhitfield/Python-Algorithms
/Binary Search Trees/basictree.py
332
3.53125
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None node = Node(10) node.left = Node(5) node.right = Node(15) node.left.left = Node(2) node.left.right = Node(6) node.right.left = Node(13) node.right.right = Node(10000) print(node.right.data) print(node.right....
bc467c013313da3148fd355abefd7f895e170deb
ShukurDev/Algorithms
/python_algorithms/#3 - Task/listlin.py
1,247
3.796875
4
class Node: def __init__(self,data): self.data = data self.next = None class linkedlist: def __iniy__(self): self.head = None def printlist(self): temp = self.head while temp: print(temp.data) temp =temp.nexta # def push(self,new_elemen...
e3609181fd3081de8d3fe99fb477c5a7bf958a8e
faryar48/practice_bradfield
/python-practice/learn_python_the_hard_way/ex01.py
4,143
3.90625
4
# print "Hello World!" # print "Hello Again" # print "I will now count my chickens", 30 / 2 # cars = 100 # space_in_cars = 4.0 # print "there are", cars, "cars available." # print "since there are", cars, "cars available, and", space_in_cars, "spaces in cars, we can take", cars * space_in_cars, "people to burning ...
d36fe85647e5b761c392d510b0227c48a40b6d38
faryar48/practice_bradfield
/python-practice/learn_python_the_hard_way/ex08.py
2,230
4.5
4
def break_words(stuff): """THis function will break up words for us.""" words = stuff.split(' ') return words def sort_words(words): """Sorts the words.""" return sorted(words) def print_first_word(words): """Prints the first word after popping it off.""" word = words.pop(0) print ...
f7a3a7f34ce3aca14fb915665c822c9001c9e25b
shubhendukr/trailer-tube
/media.py
933
3.65625
4
import webbrowser class Movie(): """ This class provides a way to store movie related information""" def __init__( self, movie_title, movie_storyline, poster_image, trailer_youtube): """ Inits a Movie object Args: title = a string of the movie's title storyline = a string...
9aa7d6b3d8d3d758dbe6f8621ed14a1eda857e4d
estebandelaf/leetcode
/Set Matrix Zeroes.py
1,138
3.828125
4
# Given a m x n matrix, if an element is 0, set its entire row and column to 0. # Do it in place. # https://leetcode.com/problems/set-matrix-zeroes/ class Solution: # @param {integer[][]} matrix # @return {void} Do not return anything, modify matrix in-place instead. def setZeroes(self, matrix): ...
8a6c3b1d9f196fca63e0ff2812262e7f19f9a1d0
mitrapiya25/python-challenge
/pybank/main.py
2,353
3.5
4
import csv import os import sys import getopt if len(sys.argv) == 1: print("enter the number of files you want to process as argument when calling the program") sys.exit() NumOfFiles = int(sys.argv[1]) months_revenue=[] for i in range(1,(NumOfFiles+1)): inputfile = "budget_data_" + str(i) +".csv" input_...
57e66a23f03ab0a3b8c56d3fdfe44f9ec15372aa
leanerr/sample-of-school-managment-platform
/Admin.py
1,140
3.6875
4
def admin() : fo = open('Courses.txt' , 'w') coursename = [] print('List of courses is empty :(') option = str(input('You want add the course in the list of courses (yes/no)? : ')) if option == 'yes': num = int(input('How many courses do you want to add: ')) for i in range(1, ...
3e8efd219fc80cca2b521dbaebf9ce9e3aa43d45
DevinTyler26/2018-practicing-algos
/selectionSort.py
292
3.9375
4
def selectionSort(arr): n = len(arr) for index in range(n): minIndex = index for j in range(index+1, n): if arr[minIndex] > arr[j]: minIndex = j arr[index], arr[minIndex] = arr[minIndex], arr[index] arr = [19,2,31,45,30,11,121,27] selectionSort(arr) print(arr)
65394a15478765ec1a41e914eb7ee5d5ff5f8156
DevinTyler26/2018-practicing-algos
/secondLargest.py
442
3.953125
4
import sys small = sys.float_info.min def findSecondLargest(list): length = len(list) secondLargest = small largest = small for i in range(length): curr = list[i] if curr > largest: secondLargest = largest largest = curr elif curr == largest: largest = curr elif curr > second...
6540c58ab3f3684646e188d974cec16aec8bc553
xiaqianru/api_test
/day2/day_requests_02.py
7,150
3.5
4
# 1.导入requests import requests import json # 组装 def get_01(): url = "http://115.28.108.130:5000/add/?a=3&b=5" res = requests.get(url=url) print(res.text) def get_02(): url = "http://115.28.108.130:5000/add/" params = {"a": 13, "b": 5} res = requests.get(url=url,params=params) print(res.t...
b75d9967b17d540209b2f3b00970c03b13536e30
tianlu102238612/Build-10-Applications-With-Python
/BookStore/bookstoregui.py
3,496
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jun 23 17:14:03 2020 @author: tianlu GUI interfaces of book store: Book entity:title,author,year,ISBN Functions: CRUD and search """ from tkinter import * import bookstorebackend def get_selected_row(event): try: #set it as global...
ab8267edfad601e1fb4035a869fa56fcbf2bc808
duyu/Merchant-s-Guide-to-the-Galaxy
/merchant_robot.py
4,687
3.65625
4
# define a MerchantRobot # * it should be able to build a dictionary for languages and prices # * words_book: a dictionary for numerals' translation # * prices: a dictionary for recording goods' prices from roman_numerals import RomanNumerals class MerchantRobot: words_book = {} prices_book = {...
14bfdcf34411cd7cf1fcfeb7c082e349648977f4
Alex-1-7/Inefficient-Compression-Algorithm
/SICS_AlexA.py
4,494
3.96875
4
import numpy as np #This solution uses a 2D array of size [128][2] to store the frequency of all ascii characters in the string. #Therefore this solution will only work for base 128 ascii characters since I use the 0-127 indices of the #array to corespond to the 128 ascii values. #This 2D array is then sorted, us...
4b3590dd08151bec78eef777171c1cf00131c23e
rakiasomai/holbertonschool-interview
/0x1F-pascal_triangle/0-pascal_triangle.py
505
3.5
4
#!/usr/bin/python3 '''def module''' def pascal_triangle(n): '''def pascal trinagle''' if n <= 0: return [] p = [[1]] if n == 1: return p for y in range(1, n): l = -1 r = 0 x = [] for _ in range(y+1): val = 0 if l > -1: ...
053d346a726c5036189637bbd674317d4bec0cef
SHKlarenbeek/BO
/HelloYou.py
30,613
3.78125
4
import random # Ik gebruik helaas globals dus alvast sorry money = 25 weapon = False parentsroad = False BFFLucy = False Yourself = False def playAgain(): global money global weapon global parentsroad global BFFLucy global Yourself print('Do you want to play again? (yes or no)') if input(...
fbfa8a3040fc10f13a593a4b4bc2661ccac37a81
farzanakhareem/Python-program
/fibonocci.py
411
4.46875
4
# Python program to display the Fibonacci sequence def recursive_fibo(n): if n <= 1: return n else: return(recursive_fibo(n-1) + recursive_fibo(n-2)) nterms =int(input("enter the value: ")) # check if the number of terms is valid if nterms <= 0: print("Plese enter a positive integer") else: ...
44f1516db4a25076cf141b193ebbe1f6e46bced2
erickbgc/Python-intro
/strings.py
1,113
4.25
4
#Formas de operar con un string myStr = 'Hola Mundo tarados' print('respuesta: ' + myStr) #Otras fornas de print(f'respuesta: {myStr}') #concatenar print('respuesta: {0}'.format(myStr)) """ -dir sirve para saber todo lo que se pueda hacer con una string """ # print(dir(myStr)) #El print es solo para m...
24b2897b11e76808b67ea608cc77d69f6e4bb6b4
ugene123/CS172
/lab2/item.py
430
3.53125
4
class Item: def __init__(self, name, price, taxable): self.__name = name self.__price = price self.__taxable = taxable def __str__(self): return self.__name + "________________________" + self.__price def getName(self): return self.__name def getPrice(self): return self.__price de...
dd68b40e77fb624ae7ec53241a0504977cb859d7
ugene123/CS172
/lab1/lab1.py
2,745
4.09375
4
# Yevgeniy (Eugene) Yakovlev # Jason Abraham # CS 171 - Lab 1 # Wednesday, June 26, 2019 # Your program must meet all the following requirements: ### Contains a function get_file() that reads a filename for the user. If the file cannot be opened, repeatedly ask the user until a valid file name is input. The funct...
a5ca68570c1a4d93a363218cbef9a4eca23db955
xfx1993/goto200
/test2.py
492
3.578125
4
def convertToTitle( n): """ :type n: int :rtype: str """ list ='' a =26 while n//a>26: a = a*26 while n>26: n1 = n//a if n%a ==0 or n%a ==26: n1=n1-1 if n1 ==0: n1=26 n = n-a if n1!=0: list+...
5fa37be770ba1359c0e9fd827aee790dc841932c
xfx1993/goto200
/test4.py
939
3.796875
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None left2 = TreeNode(2) right2 =TreeNode(4) left3 = TreeNode(1) left1 = TreeNode(-100) right1 = TreeNode(6) root = TreeNode(5) root.left = left1 root.right = right1 left1.left = left2 left1.right = ...
f7f7a7cbff430e12d3140ed1841cc4cbc1aa92bb
xfx1993/goto200
/test35.py
540
3.90625
4
class People(object): def __init__(self, name, age): self.name = name self.age = age return def __str__(self): return self.name + ":" + str(self.age) def __lt__(self, other): return self.name < other.name if self.name != other.name else self.age < other.age print("...
b611ee076dd15d33276ea180ac5ebc87b295f091
xfx1993/goto200
/test.py
912
3.890625
4
1,twosum class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def mergeTrees( t1, t2): """ :type t1: TreeNode :type t2: TreeNode :rtype: TreeNode """ if t1 and t2: t1.val = t1.val+t2.val def dfs(t1,t2): ...
d771770b2258bb0a92682be8ecd3ce9aa56b4aa2
kushsharma2727/ReviewSummarization
/Main/Classifier/nblearn.py
4,418
3.5
4
#!/usr/bin/python # -*- coding: utf-8 -*- import sys import json import glob if len(sys.argv) != 2: exit(0) stopWords = dict() # Beginning of getStopWords def getStopWords(): ''' Read stopwords from stopWords.txt in current directory. It creates a dictionary for faster reading. ''' fname = 'stopWo...
0661704fa5ca25d50ae62129d0eaf2ee5098782b
sitayebsofiane/cours-PYTHON
/script14TupleCour.py
510
4.0625
4
""" liste=range(1,7) for chose in enumerate(liste): print(chose) 2 raisons d'uliser les tuple: affectation multiple retour multiple de fonction """ #creation de tuple #un tuple avec une seul valeur <tple=(1233,)> my_tuple =1,2,3 print(type(my_tuple)) #accees au valeurs d'un tuple prin...
8dd07dc2bbe5ccf59b1fd478aed89526542ac35e
sitayebsofiane/cours-PYTHON
/script13ListCour.py
735
3.8125
4
liste=list() liste.insert(1,1) liste.insert(0,"zero") liste.insert(2,"deux") liste.insert(3,"trois") try: i=int(input("entrez la postion : ")) except TypeError: print("error") print(liste[-len(liste):i-len(liste)]) #modifier les 2 premier element liste[:4]=["modif"]*4 print(liste) #transfomer liste en chaine ...
b4a99faf842f9117606ce2294de8983f5e8923aa
Littlemansmg/pyClass
/Week 2 Assn/Project 6/6-4.py
730
3.75
4
# created by Scott "LittlemanSMG" Goes on DD/MM/YYYY def math(sales): total = 0 # total for i in sales: total += i # average average = round(total / 4, 2) print("Total: \t\t\t{}\n" "Average Quarter: {}\n" "Lowest Quarter: {}\n" "Highest Quarter: {}".form...
1a03b67a872cd4d6f58eb9ce2c0db9399e76ad91
Littlemansmg/pyClass
/Final Project/section 3/Classes.py
5,244
3.640625
4
# created by Scott "LittlemanSMG" Goes on DD/MM/YYYY from random import shuffle, randint, choice class Deck: def __init__(self): cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack", "Queen", "King", "Ace"] suits = ['Spades', 'Diamonds', 'Clubs', 'Hearts'] self.deck = [] # Create deck of ...
3cf6d3646a5351c0641a638124536bc2e1e20d15
Littlemansmg/pyClass
/Week 5 Assn/Project 15/15-1.py
2,255
3.96875
4
# created by Scott "LittlemanSMG" Goes on DD/MM/YYYY class Rectangle: def __init__(self, height, width): self.height = height self.width = width def area(self): return self.height * self.width def perimeter(self): return (self.height + self.width) * 2 def __str__(sel...
763542d6763c676d15ae33a2c6b6e849e6b3e221
Littlemansmg/pyClass
/Week 2 Assn/Project 4/mods.py
676
3.8125
4
# created by Scott "LittlemanSMG" Goes on 11/05/2019 def get_total(): running_total = 0.0 sales_tax = .06 print("Enter Items (Enter 0 to end)") while True: item = float(input("Cost of item: ")) if item != 0: running_total += item else: break final_t...
4bb152b990e86c9032072f399e94817fa140cf83
Littlemansmg/pyClass
/Week 2 Assn/Project 4/4-2.py
343
4.1875
4
# created by Scott "LittlemanSMG" Goes on 11/05/2019 def miles_to_feet(miles): feet = miles * 1520 return int(feet) def main(): miles_input = input("How many miles did you walk?: ") miles_input = float(miles_input) print("You walked {} feet.".format(miles_to_feet(miles_input))) if __name__ == ...
bb69c5b4c27306ae1b6f0a83a18d24ab95d6feb1
Littlemansmg/pyClass
/Week 5 Assn/Project 13/13-2.py
621
3.8125
4
# created by Scott "LittlemanSMG" Goes on DD/MM/YYYY def display_branch(branch): if branch == 0: pass else: display_branch(branch - 1) print("*****" * branch) display_branch(branch - 1) def main(): print("Tree Pattern") branches = 1 while True: try: ...
5a2cddcc650faae788a7af06ae3949218395e42b
Michael-W-Yu/Word2vec-Neural-Network-and-Self-Organizing-Map
/word2vec.py
14,131
3.546875
4
'''word2vec.py Implements the Skip-gram Word2vec neural network CS343: Neural Networks YOUR NAMES HERE Project 5: Word Embeddings and SOMs ''' import re import numpy as np import network import layer def tokenize_words(text): '''Transforms a string sentence into words. Parameters: ----------- text: s...
274aa6ea1cfbd8ee039e87c2f718beb5c881d941
iPotapenko/python-laboratory
/labaratory1/task2.py
226
3.796875
4
print("Потапенко Іван Валентинович; Група КМ-92; Завдання №2") x = int(input("Число пелюсток:")) if(x%2 ==0): print("Не любить.") else: print("Любить.") input("Press any key to leave.")
eaa399715aef6aaa92829b88270bd136cd9de075
manjushriprao/USN1BG16IS030
/internship/inheritance.py
434
3.71875
4
class Bird: def __init__(self): print("bird is ready") def whoisthis(self): print("bird") def swim(self): print("swims fast") class penguin(Bird): def __init__(self): super().__init__() print("penguin is ready") def whoisthis(self): print("Pengui...
c119cf284f9e9afe49e906b8f4b1ff771eee66c9
ddh/codewars
/python/range_extraction.py
1,817
4.625
5
""" A format for expressing an ordered list of integers is to use a comma separated list of either individual integers or a range of integers denoted by the starting integer separated from the end integer in the range by a dash, '-'. The range includes all integers in the interval including both endpoints. It is not c...
14390a2ae3b6ad53a988c321de9df62ad7110e00
ddh/codewars
/python/basic_mathematical_operations.py
1,478
4.34375
4
""" Your task is to create a function that does four basic mathematical operations. The function should take three arguments - operation(string/char), value1(number), value2(number). The function should return result of numbers after applying the chosen operation. Examples basic_op('+', 4, 7) # Output: 11 bas...
d99d5b3aea3e07e811996402c46afea113c0d584
junyechen/PAT-Advanced-Level-Practice
/1010 Radix.py
4,983
3.921875
4
""" Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair of positive integers N​1​​ and N​2​​, your task is to find the radix of one number while that of the other is given. Input Specifica...
160c7cb9ab9719c4d0573ce90bb4c9e70ba1ca9b
junyechen/PAT-Advanced-Level-Practice
/1108 Finding Average.py
2,573
4.34375
4
""" The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−1000,1000] and is accurate up to no more than 2 decimal places. When you calculate the average, those i...
f58436e45bcc7580a12f64f5a0cb2db66fc6ee9f
junyechen/PAT-Advanced-Level-Practice
/1068 Find More Coins.py
4,812
3.90625
4
""" Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for each bill, she must pay the exact amount. Since she has as many...
c02eefbecf90f4d6cb77a2205a5fef5255b07626
junyechen/PAT-Advanced-Level-Practice
/1147 Heaps.py
2,925
3.65625
4
""" In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (in a max heap) or less than or equal to (in a min heap) the key of C. A common implementation of a heap is the binary...
a968642f9a2662b287d6061905a5de81d23d558e
junyechen/PAT-Advanced-Level-Practice
/1055 The World's Richest.py
3,858
3.640625
4
""" Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the people in a certain range of ages. That is, given the net worths of N people, you must find the M richest people in a giv...
39ca6338a0983096b1e803a74235873d0ff0c7eb
junyechen/PAT-Advanced-Level-Practice
/1102 Invert a Binary Tree.py
3,220
3.53125
4
""" The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off. Now it's your turn to prove that YOU CAN invert a binary tree! Input Specification: Each input file contains one test case. For each ...
5c2300b9fe7fc070685b4c9d3d88afb742ebd6b9
junyechen/PAT-Advanced-Level-Practice
/1104 Sum of Number Segments.py
1,262
4.09375
4
""" Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4) (0.3) (0.3, 0.4) and (0.4). Now given a sequence, you are s...
c99b8de0386959b5a30226339348c5b4a540dec6
junyechen/PAT-Advanced-Level-Practice
/1029 Median.py
1,499
4.0625
4
""" Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is 15. The median of two sequences is defined to be the median of the nondecreasing sequence which contains all the el...
c9903d131f04bfc8cba5b27b456962835abb569b
junyechen/PAT-Advanced-Level-Practice
/1124 Raffle for Weibo Followers.py
1,918
3.75
4
""" John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him generate the list of winners. Input Specification: Each input file co...
c912862eb13c53ec1bfa4a13107f98a4793cf113
junyechen/PAT-Advanced-Level-Practice
/1009 Product of Polynomials.py
1,652
3.859375
4
""" This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N​1​​ a​N​1​​​​ N​2​​ a​N​2​​​​ ... N​K​​ a​N​K​​​​ where K is the number of nonzero terms ...
471d2edc35936987492655c1b9b42910da056d03
junyechen/PAT-Advanced-Level-Practice
/1063 Set Similarity.py
1,815
3.890625
4
""" Given two sets of integers, the similarity of the sets is defined to be N​c​​/N​t​​×100%, where N​c​​ is the number of distinct common numbers shared by the two sets, and N​t​​ is the total number of distinct numbers in the two sets. Your job is to calculate the similarity of any given pair of sets. Input Specifica...
d3e2e3110d7817d9efb25d3c20d1eeb391396820
junyechen/PAT-Advanced-Level-Practice
/1030 Travel Plan.py
3,739
4.1875
4
""" A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path between his/her starting city and the destination. If such a shortest path is not unique, you are supposed to output ...
ec36b4f871aa0b3de95cf1e376778caeeae722eb
junyechen/PAT-Advanced-Level-Practice
/1017 Queueing at Bank.py
2,684
3.609375
4
""" Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow line, until it is his/her turn to be served and there is a window available. It is assumed that no window can be occup...
b43d00661e3408a11662f6e5a72b7e0821193306
junyechen/PAT-Advanced-Level-Practice
/1130 Infix Expression.py
2,771
3.859375
4
""" Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (≤ 20) which is the total number of nodes ...
99add688c155e906fbf683f59c314fdde8cca013
junyechen/PAT-Advanced-Level-Practice
/1090 Highest Price in Supply Chain.py
4,025
4.21875
4
""" A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer. Starting from one root supplier, everyone on the chain buys products from one's supplier in a price P and sell or distribute them in a price that is r% higher than...
bf8d933496744161657153ab9bfba4a549b583d1
junyechen/PAT-Advanced-Level-Practice
/1143 Lowest Common Ancestor.py
4,848
3.609375
4
""" The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants. A binary search tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node's key. ...
fc4059ffe382d5db24389e267bc18201431dfd8d
junyechen/PAT-Advanced-Level-Practice
/1144 The Missing Number.py
1,034
3.75
4
""" Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (≤10​5​​). Then N integers are given in the next line, separated by spaces. All the numbers a...
57b09375d75919214cd994056c2b4013bde55e90
hrishigadkari/Hackerrank
/staircase.py
394
4.15625
4
#!/bin/python3 import math import os import random import re import sys # Complete the staircase function below. def staircase(n): for i in range(0,n): for j in range(0,n-1-i): print(" ",end="") for j in range(0,i+1): print("#", end ="") print(end="\n...
21e9f1d369ad8a549b36709616ce8bed3897731e
amallya1/python-masterclass
/python-dir/print_linklist.py
399
3.875
4
class node: def __init__(self, next_node): self.value = next_node self.next = None def add_node(self, node_value, new_node): self.value = node_value self.next = new_node def iterate(self): while(self.next != NULL): print node.value self.next = nex...
63e4a78a90f138ff8d470cc6131ee84220de9b32
blindzeppeli/exerciciosPythonicos
/ex004.py
496
4.0625
4
a = input('Digite algo: ') print('\n{}, é do tipo primitivo :'.format(a), type(a)) print('{}, só espaço?'.format(a), a.isspace()) print('{}, è um alfanúmerico?'.format(a), a.isalnum()) print('{}, è um númerico?'.format(a), a.isnumeric()) print('{}, è um alfabético?'.format(a), a.isalpha()) print('{}, está em maiúsculo?...
2d58903f3d752cc5aa25dc8c14839310ea1ffd19
kylechenoO/investigate-texts-and-calls
/Task2.py
1,665
3.5
4
""" 下面的文件将会从csv文件中读取读取短信与电话记录, 你将在以后的课程中了解更多有关读取文件的知识。 """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ 任务2: 哪个电话号码的通话总时间最长? 不要忘记,用于接听电话的时间也是通话时间的一部分。 输出信息: "<telephone number>...
e1d5076c5e4fdccf4161b641cb0212b58000582c
fredo09/Ptyhon-Started
/Operaciones_cadenas/operaciones.py
528
4.09375
4
## OPERACIONES BASICAS CON STRINGS # len(cadena) muestra el numero de caracteres unacadena = "hola mundo" print (len(unacadena)) # index(cadena) muestra la ubicacion del primer caracter que cumple print (unacadena.index("l")) # cadena[valor:valor] imprime un rango de caracteres print(unacadena[3:7]) # upper() y l...
b7334619203ede00db110e50a91bbe327b1d2629
EdmondWang/studypy
/c4-loop.py
130
3.90625
4
''' Task Read an integer . For all non-negative integers , print N * N. ''' a = int(input()) for i in range(0, a): print(i * i)
26fc8de4c4b89feae25fecf94932208642dcb772
vRoussel/advent-of-code-2020
/02/02.py
1,179
3.625
4
#!/usr/bin/python3 import re r = re.compile(r'^(\d+)-(\d+) (\w+?): (\w+)$') def check_first_policy(line): res = r.match(line.rstrip()) try: _min, _max, _char, _pattern = res.groups() _min = int(_min) _max = int(_max) count = _pattern.count(_char) if _min <= count and ...
ae209112dc17b7999e0613f60eac2a40ceba019e
Here2Huynh/Thirteen-Card-Game
/Player.py
2,112
3.890625
4
""" player class player class structure: ID Hand Points class Player: def __init__(self,ID,Hand): self.ID = ID self.Hand = Hand def getID(self): return self.ID def getHand(self): return self.Hand def showHand(self): print self.Hand Points are in increments of th...
8463394e2372bc73aaff33f4fe6ac262323970c0
Here2Huynh/Thirteen-Card-Game
/gameState.py
2,849
3.625
4
#game_state module # this module will hold: # -current round and its moves # -which player is locked out # -which player is choked out / do it in player moduel?? # -player's move # might need a executor file to execute the calls class game_state: def __init__(self): self.Turn = int #current playe...
119ca1df2c18d20318a227dd4d861bedf0b2fc54
slawektestowy/bootcamp_d3
/zjazd2_wszystko/03_funkcje/fibonacci.py
317
3.90625
4
def fibonacci(n): jedna_temu = 1 dwie_temu = 1 if n == 1 or n == 2: return 1 for i in range(3, n + 1): wynik = jedna_temu + dwie_temu dwie_temu = jedna_temu jedna_temu = wynik return jedna_temu # return fibonacci(n - 1) + fibonacci(n - 2) print(fibonacci(1000))
47fb78d18ec44e05a4af1c351967a67138935875
slawektestowy/bootcamp_d3
/dzien4/zadanie4.py
726
3.5
4
#print("asasa\nsasasa") # def nasza_funkcja(a, b="hopsasa", *args, **kwargs): # print(a) # print(b) # print(args) # print(kwargs) # # #nasza_funkcja(3) # nasza_funkcja(3, 5,6,8,9,10, end='koniec') # def nasza_funkcja1(a, b, *args, **kwargs): # zle, nie dziala # suma = (a +b + (*args + **kwargs)) ...
f8a6bacf223ecf2cdbda579df209c38be1946730
slawektestowy/bootcamp_d3
/Prog_obiektowe/zadanie5.py
2,257
3.5625
4
#Zaimplementuj klase CashMachine umozliwiajaca wpłacanie i # wypłacanie pieniedzy. Zadbaj o to aby stan bankomatu # przetrzymywany był w zmiennych prywatnych. # Przykład uzycia: # >>> cash_machine = CashMachine() # >>> cash_machine.is_available() # False # >>> cash_machine.put_money([200, 100, 100, 50]) # >>> cash_mach...
036ec1276db461d3d3152fc2bb5be3d9e69586ca
slawektestowy/bootcamp_d3
/zjazd2_wszystko/01_podstawy/zad7.py
422
3.78125
4
x = int(input("podaj liczbę:")) print(f'czy warunek: {not x % 2 != 0 and x % 3 == 0 and x > 10 or x ==7}') print( True and True or False and False) # hipoteza 1: or jest silniejszy # True or False => True # True and True and False => False # hipoteza 2: and jest silniejszy # True and True => True # False and False =...
db4bcb1b1bc1eb8a24315dbcd5c7a206cc445e22
slawektestowy/bootcamp_d3
/zjazd2_wszystko/03_funkcje/zadanie1.py
366
3.5
4
from math import sqrt def czy_podzielne_przez_7(x): if x % 7 == 0: return True else: return False def czy_pierwsza(x): if x == 1: return False for i in range(2, int(sqrt(x)) + 1): if x % i == 0: return False return True print(czy_pierwsza(17)) print(cz...
bdbb54e1f11ca90339005f50cf003701800e44c9
slawektestowy/bootcamp_d3
/Prog_obiektowe/zadanie6.py
1,188
4
4
# Zaimplementuj klase Vector dostarczajaca funkcjonalnosc wektora # swobodnego na dwuwymiarowej płaszczyznie. Wektory powinny # miec mozliwosc dodawania, odejmowania, mnozenia (przez liczbe), # porównywania (po długosci) oraz powinny posiadac czytelna # reprezentacje napisowa. # Przykład uzycia: # vector_1 = Vector(x=1...
d597826adc400ace047c1f48f499cd2286d22d57
slawektestowy/bootcamp_d3
/01_podstawy/zad7.py
459
4
4
x = float(input('Podaj liczbe: ')) #if x == 7: # print ('Ta liczba to 7') #else: # print ("Ta liczba jest podzielna przez 3: ", x % 3 == 0) # print ("Ta liczba jest nieparzysta: ", x % 2 != 0) # print("Ta liczba jest wieksza od 10: ", x > 10) print ('Ta liczba to 7', x==7,'\n' "Ta liczba jest podzi...
b215cdfe80d98cf56dd945b993b538e0c32e9e80
slawektestowy/bootcamp_d3
/zjazd2_wszystko/03_funkcje/dekoratory.py
788
3.65625
4
from time import time def fib(n): if n < 3: return 1 return fib(n - 1) + fib(n - 2) def czas(func): def wrapper(*args, **kwargs): start_time = time() func(*args, **kwargs) stop_time = time() print(f"Wywołanie funkcji zajęło {stop_time - start_time}s") return wra...
b03ff7d99594cf29c27dbe554734327b9b931c4b
rshopa/data_sci_introduction
/assignment3/code/join.py
912
3.53125
4
import MapReduce import sys mr = MapReduce.MapReduce() # ============================= # Do not modify above this line def mapper(record): table_name = [record[0]] order_id = record[1] value = record[2:] int_val = table_name + value # emit hash with table name mr.emit_intermediate(orde...
4af9bb1988349c0ae5b10f9e1da5a75e0fe3b840
AIMLCamp/python-mini-projects
/projects/Solver_linear_equations/linearEquations.py
1,313
3.609375
4
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm print('The 3 equations are entered individually, each value of the equation is entered separated by a space, for example: \ninput = 6 5 -3 4 \nThis will be equal to 6x + 5y- 3z = 4') print('Enter value...
fea24161ad148a1cb56238e522b9c9bce61ca4cb
AIMLCamp/python-mini-projects
/projects/Speaking_Dictionary/SpeakingDictionary.py
3,145
3.515625
4
import pyttsx3 from PyDictionary import PyDictionary import speech_recognition as spr from gtts import gTTS import os #Speaking class class Speak: def SpeakWord(self, audio): #Having initial constructor of pyttsx3 pSpeakEngine= pyttsx3.init('sapi5') pVoices= pSpeakEngine.getProperty('voices...
51b07e757cc4a665549173cf23577e8ba3c73e51
antoniojsp/string_especial
/string_mu.py
1,939
3.90625
4
class linea: def __init__(self, string): self.word = list(string) # replace a char according to the index provided def replace_index(self, index, char): self.word[index] = char # looks for all the old char present and change for new def replace_char(self, old, new): for index...