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
ee8f13283143cc895953b8c63bf7e7bc845aff2c
bpriddy83/Python-Labs
/Lab1B-Car.py
204
3.953125
4
acceleration = 0.0 time = 0.0 print("How much time does it take the car to go 0 MPH to 60 MPH? ") time = float(input("TIME>")) acceleration = (60.0-0.0)/time print("OUTPUT ", acceleration)
44a762ef8f1221139b7625c4f979625c5813d611
RadioFreeZ/Python_October_2018
/python_OOP/product.py
1,014
3.625
4
class Product: def __init__ (self,price,name,weight,brand): self.price = price self.name = name self.weight = weight self.brand = brand self.status = "for sale" def sell(self): self.status = "sold" return self def tax(self,rate): return self.pr...
05aa5bd36eba8a10f25800c4d61829f1e5710a67
RadioFreeZ/Python_October_2018
/python_fundamentals/function_basic2.py
1,655
4.34375
4
#Countdown - Create a function that accepts a number as an input. Return a new array that counts down by one, from the number # (as arrays 'zero'th element) down to 0 (as the last element). For example countDown(5) should return [5,4,3,2,1,0]. def countdown(num): return [x for x in range(num, -1,-1)] print(cou...
c66d2eee8c1f791675ff980e8c4e284c7b75b4ca
RadioFreeZ/Python_October_2018
/python_OOP/car.py
868
3.703125
4
class Car: def __init__ (self,price,speed,fuel,mileage): self.price = price self.speed = speed self.fuel = fuel self.mileage = mileage if self.price > 10000: self.tax = 0.15 else: self.tax = 0.12 def display_all(self): print("Price:...
b8da11200b9a2cfa01966ca24d05cd9c8f9b1014
Abiaina/Cracking_Coding_Interview
/1.7.py
1,091
3.96875
4
def forward_rotate (matrix): # Rotates square matrix by +90 degrees in place. # Time: O(n^2) axis = 0 # Time: O(n^2) for r_i, row in enumerate(matrix): for c_i, col in enumerate(matrix): if c_i > axis: # Transpose column and row: tmp_top = matrix[...
1ffd4a7da4d91c9afb391d249f7a05f47d8f6258
Candrikadewi/Candrika-Dewi_I0320019_Aditya-Mahendra_Tugas5
/I0320019_Soal2_Tugas5.py
796
3.6875
4
nama = str(input("Masukkan nama anda: ")) nilai = int(input("Masukkan nilai anda: ")) if nilai<60: print("Halo,",nama+"! Nilai anda setelah dikonversi adalah E") elif nilai>=60 and nilai<=64: print("Halo,", nama+"! Nilai anda setelah dikonversi adalah C") elif nilai>=65 and nilai<=69: print("Halo,", nama, ...
78ae0585b9750d6bb4901a4c95189035b1454ea5
LYSHN/python-100-day
/day-118/object_demo2.py
442
4.0625
4
a = [1, 'hello', [1, 2]] b = list(a) a[0] = 100 a[2][0] = 100 print(a) print(b) print(a is b) a = [1, 2, 3] b = a[:] print(a == b) print(a is b) a = (1, 2, 3) b = tuple(a) print(a == b) print(a is b) import copy a = [1, 'hello', [1,2]] b = copy.deepcopy(a) a[0] = 100 a[2][0] = 100 print(a) print(b) a = (1,2,3...
9d12fc8adb7a99503d70879c62481471371e5e32
LYSHN/python-100-day
/day-039/itertools-product-demo.py
149
3.640625
4
import itertools print(list(itertools.product("ab", "12"))) print(list(itertools.product("ab", "ab"))) print(list(itertools.product("ab", repeat=2)))
fe718bbf135fa0ae4376a60bb83218efb289f3cb
LYSHN/python-100-day
/day-031/random.py
889
3.90625
4
#!/usr/bin/python3 #默认生成0到1之间的随机数 import random print(random.random()) #uniform(a,b) import random print(random.uniform(2,5)) print(random.uniform(5,2)) #randint(a,b) import random print(random.randint(5,50)) #randrange([start], stop[, step]) import random print(random.randrange(1,10)) #print(ran...
19b4ab2c7b019b1504f293e10445bed6d5a61402
LYSHN/python-100-day
/day-107-csv/2.3-示例.py
223
3.59375
4
import numpy as np A = np.mat(np.full((2, 3), 10), int) B = np.mat(np.full((3, 3), 10), int) print(A*B) # 求矩阵相乘形式一 print(A.dot(B)) # 求矩阵相乘形式二 print(np.dot(A, B)) # 求矩阵相乘形式三
ec86ef8e6f40d7cc21624af32bb4888421bc7bbf
chensuim/leetcode
/huarongdao.py
2,307
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/1/28 上午10:59 # @Author : Sui Chen class Solution(object): target = (1,2,3,4,5,0) def slidingPuzzle(self, board): """ :type board: List[List[int]] :rtype: int """ visited = set() de = board[0] + board[...
5fc54f8655551f4671595f3af7e42d203f23dbd5
chensuim/leetcode
/prime_generator.py
391
3.859375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/4/16 下午3:47 # @Author : Sui Chen def is_prime(num): if num < 2: return False i = 2 while i * i <= num: if num % i == 0: return False i += 1 return True def prime_generator(): this = 2 while True:...
d09082de83122ea5d878076f971dab9a589ef85c
chensuim/leetcode
/split.py
1,408
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/5/5 下午2:27 # @Author : Sui Chen def split(ori, seperators=None, protectors=None, keep_seperator=False): """ :type ori: str 被分割的字符串 :type seperator: str 分隔符, 为空或None则按空格区分 :type protectors: dict 保护符,无视内部分隔符 :rtype: list """ if pro...
4a54e80e7879e7999c7cf2b1ed546e9e1925e93f
chensuim/leetcode
/longestPalindrome.py
656
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/1/25 上午11:37 # @Author : Sui Chen class Solution: # @return a string def longestPalindrome(self, s): if len(s)==0: return 0 maxLen=1 start=0 for i in xrange(len(s)): if i-maxLen >=1 and s[i-max...
674077b575984c248752931722fa36fb1317abe2
dengbuling/test1
/test_privacy/4.py
684
3.609375
4
a = [1, 2, 3, 11, 2, 5, 88, 3, 2, 5, 33] print(a.index(max(a))) max1 = 0 maxname = "" a2 = [ 'my', 'skills', 'are', 'poor', 'I', 'am', 'poor', 'I', 'need', 'skills', 'more', 'my', 'ability', 'are', 'so', 'poor' ] for i in a2: if a2.count(i) > max1: max1 = a2.count(i) maxname = i print(maxname) a4 ...
dda1742fc05b7a4db54ec07749c72d370dcdd017
mosho-p/advent_of_code2020
/day2.py
686
3.703125
4
def parse_pass(s): k, v = s.split(': ') num, char_ = k.split() min_, max_ = num.split('-') min_, max_ = int(min_), int(max_) return min_, max_, char_, v def is_valid(s): min_, max_, char_, v = parse_pass(s) return min_ <= v.count(char_) <= max_ def is_now_valid(s): min_, max_, char_,...
693f53c4f8f1cddaebe2c48177321daac9c0b2d5
sarvnazale/Wave-1
/Making Change.py
1,042
4
4
#getting user input total_cent = int(input("Total number of cents from the user is: ")) #defining variables cents_per_toonie = 200 cents_per_loonie = 100 cents_per_quarter = 25 cents_per_dime = 10 cents_per_nickel = 5 cents_per_penny = 1 #calculating number of toonies num_toonies = total_cent // cents_per_toonie tota...
d32c72801d968d35deaa712856fa5dccffe29f25
KimMooHyeon/Algorithm-Studying
/하샤드의 수.py
330
3.640625
4
def solution(x): answer = False now_sum=0 now_x=x while True: if x<10 : now_sum+=x break else: now_sum+=x%10 x=x//10 if now_x%now_sum ==0: answer = True print(now_sum) ret...
007e9fc1e123ce111f9ded809c5c1a234f83429e
KimMooHyeon/Algorithm-Studying
/count_game.py
1,406
3.65625
4
from random import randint landom_num=0 temp=0 problem=[] while landom_num<=2: temp=randint(0,9) if not temp in problem: problem.append(temp) landom_num=landom_num+1 print(problem) print("0과 9 사이의 서로 다른 세 숫자를 랜덤한 순서로 뽑았습니다.") challenge=0 while True: i=1 s_num=0 b_num=0 judge=0 ...
6cadceafe95f930cc3481767fe6f312b773bb430
hellenw/DRL-EGC
/environment.py
28,723
3.71875
4
# Elevator Simulator Environment modified from https://github.com/hse-aai-2019-team3/Applied-AI-Technologies import math import gym from gym import spaces, logger from gym.utils import seeding import numpy as np import copy import queue import time import pyglet from pyglet import gl class ElevatorEnv(gym.Env): ...
fb763a2154bc10ae362f621288b41d7b7d56b83a
karthishiv/func.py
/oops.py
7,287
3.90625
4
#EX_3 class Employee: def __init__(self): self.name = name self.age = age self.salary=sal Jack=Employee("Jack",24,30000) Jill=Employee("Jill",27,40000) #OOPR-Exer-4 class Athlete: def __init__(self,name,gender): self._name=name self._gender=gender def run...
eb093082e78139286b8fd9e807eea748d782788f
ProsperousHeart/flask-projects
/Starter Apps/REST-APIs/04 - SQLAlchemy/code/models/user.py
3,818
3.890625
4
import sqlite3 from db import db # class UserModel: class UserModel(db.Model): # tells SQLAlchemy it's something to save/add to db """ This is not a resource because the API cannot receive data into this class or send as a JSON representation. It is a helper used to store data about the user & contain...
4bd1635d3b9d2e6679431a51c49409060f17daef
Los4U/sudoku_in_python
/.history/triangle_20180614150304.py
306
3.90625
4
import math x1 = 1 y1 = 2 x2 = -1 y2 = 6 x3 = 3 y3 = 5 def distance(x1,y1, x2, y2): lenght = math.sqrt( (x1-x1)**1 + (y1-y2)**2) return lenght print("dlugosc AB = ", distance(x1, x2, y1, y2) ) print("dlugosc BC = ", distance(x2, x3, y2, y3) ) print("dlugosc AC = ", distance(x1, x3, y1, y3) )
86a4c48048fe65ece4019409ef58ba911f90a646
MartaDobrocinska/Kurs_python
/homework/homework_day04/multitool.py
3,180
3.578125
4
import random import homework.homework_day04.rectangle as rectangle import homework.homework_day04.pyramid as pyramid import homework.homework_day04.change as change import homework.homework_day04.fahrenheit_to_celsius as f_to_c import homework.homework_day04.celsius_to_fahrenheit as c_to_f import homework.homework_day...
121b1e5e3daa263fba0cf65a78b841d74de3e2bb
MartaDobrocinska/Kurs_python
/homework/homework_day04/bi_to_dec.py
785
3.890625
4
def binary(): """Converts a 6 digit binary number into a decimal """ question = input("Podaj 6-znakową liczbę w systemie binarnym: ") while True: try: int(question, 2) and len(question) == 6 break except: print("Podana liczba nie jest 6-znakową liczbą bina...
f0ac7e50e284d45ca368be7fb082c0f4ffee6459
ruthironside/w3_weekend_homework_rock_paper_scissors
/app/models/game.py
721
3.765625
4
class Game(): def __init__(self, player1, player2): self.player1 = player1 self.player2 = player2 def play_game(self, player1_choice, player2_choice): if (player1_choice == "rock" and player2_choice == "scissors") or (player1_choice == "paper" and player2_choice == "rock") or (player1_...
9257ae7106cf111e01eae338b262a65947204458
DishaCoder/Solved-coding-challenges-
/lngest_pall_str.py
221
4.125
4
inputString = input("Enter string : ") reverse = "".join(reversed(inputString)) size = len(inputString) if (inputString == reverse): print("Longest pallindromic string is ", inputString) else: for
097c7bd2abe1ec3643fceea7dbd81dd3b2dd7194
marcelopizani/resolucoes
/python/02/segundo.py
1,453
3.640625
4
#!/usr/bin/env python # -*- coding: latin1 -*- # a) O valor total da conta + 10% do garçom. # b) O valor da conta por pessoa (incluído os 10%) # c) A média em ml de Chopp que cada pessoa tomou # d) A quantidade de porções solicitadas. qtd_111 = 0; qtd_222 = 0; qtd_333 = 0; qtd_444 = 0; qtd_555 = 0; total = 0; opcao =...
2d3576bb820250672097dddcaf655746113aeec7
CMPS2200-Fall2021/assignment-01-aidanhussain
/main.py
2,450
3.53125
4
""" CMPS 2200 Assignment 1. See assignment-01.pdf for details. """ # no imports needed. def foo(x): ### TODO if x <= 1: return x else: return foo(x-1) + foo(x-2) def longest_run(mylist, key): ### TODO count = 0 longest = 0 for e in mylist: if e == key: ...
629d6019e80df163be89fec6e803888990953268
shilichang/leetcode_python
/1. Two Sum.py
485
3.515625
4
class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ dict={} for i in range(len(nums)): if nums[i] in dict: return[dict[nums[i]],i] else: ...
7e1af99b8267a6fd68099e54ced1e52fa58a3088
Sifrera/SelfTaught
/chap9challenge.py
490
3.6875
4
import os path = os.path.join("/home", "pi", "Documents", "text.txt") with open(path, 'r+') as f: print(f.read()) f.write(input("Type what you would like to add to the file.")) import csv mylist = [["Top Gun", "Risky Buisness", "Minority Report"], ["Titanic", "The Revenant", "Inception"], ...
b2aaca82d5242a531e7433f42946600e7a520915
Sifrera/SelfTaught
/chap7challenge.py
627
3.6875
4
shows = ["The Walking Dead", "Entourage", "The Sopranos", "The Vampire Diaries" ] for show in shows: print(show) for i in range(25, 51): print(i) for x, show in enumerate(shows): print(i) print(show) while True: ans = input("Guess a number or type 'q' to quit.\t\t") ...
161a857eb783e02818e494449c4f6b2721f2b13f
lmoscheni/SO
/Cola.py
543
3.625
4
''' Created on Jul 7, 2013 @author: Leandro Moscheni ; Julian Skalic ''' class Queue(): ''' Representacion de la Estructura de Cola ''' def __init__(self): self.index = 0 self.queue = [] def add(self,element): self.queue.append(element) self.index = self.index ...
ba031d9a61647dd800bb8feb988c60a86aed560c
jazzworth/pibal_python
/PlotClass.py
223
3.5625
4
import numpy as np import matplotlib.pyplot as plt x = [2,4,6,8,10] y = [6,7,8,2,4] x2 = [1,2,3] y2 = [10,14,12] plt.bar(x, y, label="Bars") plt.xlabel('x') plt.ylabel('y') plt.title("New Graph") plt.legend() plt.show()
6ae45b575dd5cec5232d6e1b75e32932ccba7128
sagarbudhthoki/calculator
/python lab/sagar.py
153
4.1875
4
temperature=int(input("What is the temperature now:")) if temperature>=30: print("the temperature is hot") else: print("the temperature is cold")
14dc8e0fe6b44328d12f34b08c2b1d7c3775c8a4
pjsheldon/PythonGradeBookMenu
/hwk7.py
3,934
3.734375
4
'''--------By: PJ Sheldon--------- --------Date: 8/20/20--------- hwk7.py programming assignment 5 SEC-290 Wilmington University''' class Grades: # constructor def __init__(self, score): self.score = score finalExamScore = 0 quizScores = [] assign...
50b9137c65574f48d874fb10490640ee459340a2
sumitisnot4u/data-structures-and-algorithms
/data_structures/python/min_heap.py
6,391
3.984375
4
class MinHeap: """ MinHeap is a binary tree-like data structure, but uses a list/array to store the values In a `MIN` heap, values are always lower than their children. The inverse is true for 'MAX' heap A heap should always be a full/complete binary tree, never open spots in-between values For INS...
72e6e45ae8f65d2e3bbec5cd541124a49d2e589f
sumitisnot4u/data-structures-and-algorithms
/data_structures/python/trie.py
4,615
4.28125
4
class TrieNode: def __init__(self): self.children = {} self.end_of_word = False class Trie: """ Trie is a tree-like data structure (not binary), great for storing and searching for words Each node has a hash set (or dictionary) of possible children, each of which is a single letter (e....
7180c6f53ffcd42fd914287563a3122a4dfd90e5
pavdemesh/grokking_algos
/ch_4_rec_count.py
201
3.9375
4
def rec_count(arr): """Returns count of all elements of an array in a recursive manner""" if not bool(arr): return 0 return 1 + rec_count(arr[1:]) print(rec_count([2, 6, 8, 5]))
a962d3377a3f30b5b226d4b1999b922c32dc0b15
sartechb/tcday
/tech_day.py
5,693
4.0625
4
q1_correct = ["linux", "redhat", "unix", "red hat"] q2_correct = ["bash"] q3_correct = ["nano", "vim", "vi", "emacs", "ed", "sed"] q4_correct = ["makefile", "make file"] q5_correct = ["git", "svn", "mercurial", "subversion"] q6_correct = ["compiled", "interpreted"] q7_correct = ["header", "header files", "headers"] q...
09e3acce6c3daec82a37bd5d366679bb96df297e
mcdallas/rsa
/rsa/rsa.py
821
3.515625
4
from .primes import random_prime, random_coprime def xgcd(b, n): """Takes positive integers a, b as input, and return a triple (g, x, y), such that ax + by = g = gcd(a, b)""" x0, x1, y0, y1 = 1, 0, 0, 1 while n != 0: q, b, n = b // n, n, b % n x0, x1 = x1, x0 - q * x1 y0, y1 = y1, ...
eb31fc6b5c6b5957bf62c9a7c48864dee92aeba5
lyvd/learnpython
/doublelinkedlist.py
1,521
4.5
4
#!/usr/bin/python ''' Doubly Linked List is a variation of Linked list in which navigation is possible in both ways either forward and backward easily as compared to Single Linked List. ''' # A node class class Node(object): # Constructor def __init__(self, data, prev, nextnode): # object data self.data = dat...
df9f7a91df1bbb03d9f9661ece0c905936aba7b8
lyvd/learnpython
/node.py
552
4.1875
4
#!/usr/bin/python # Create a class which presents a node class BinaryTree: def __init__(self, rootObj): # root node self.key = rootObj # left node self.leftChild = None self.rightChild = None # Insert a left node to a tree def insertLeft(self, newNode): # if there is no left node if self.leftChild ...
77ce3d6aa7f0a27ca75ca6107eeabdf17e5bfe79
aRToLoMiay/Special-Course
/Первые шаги/average_int.py
212
3.515625
4
# -*- coding: utf-8 -*- # Упражнение 5. Среднее значение целых чисел S = 0 for i in range(6): S += i d = float(S) / 5 print "Среднее значение = %.4f" % (d)
f0d0c2f1b869c22f0d16a4b26ddd8ff489623903
aRToLoMiay/Special-Course
/Основные инструкции/errors.py
852
4.34375
4
# -*- coding: utf-8 -*- # Программа для вычисления положения мяча при вертикальном движении # с использованием функции # Упражнение 1. Ошибки с двоеточиями, отступами и т.п. def y(t): v0 = 5 # Начальная скорость g = 9.81 # Ускорение свободного падения return v0*t - 0.5*g*t**2 t = 0.6 # Время...
18a7bdc14f2494a9611ece73ab18e9ab04afc32e
akjalbani/Test_Python
/Misc/Security/detect_brute_force.py
912
3.515625
4
import time # Dictionary to keep track of failed login attempts failed_logins = {} # Threshold for number of failed attempts within a time window threshold = 5 # Time window (in seconds) to consider for brute force attack detection time_window = 60 def detect_brute_force(ip_address): current_time = time.time() ...
030139068d2f3eafd4e60f3e3bfabf374a174e30
akjalbani/Test_Python
/Misc/Tuple/xycoordinates.py
499
4.15625
4
""" what are the Mouse Coordinates? """ ## practical example to show tuples ## x,y cordinates stored as tuple, once created can not be changed. ## use python IDLE to test this code. ## 08/06/2020 import tkinter def mouse_click(event): # retrieve XY coords as a tuple coords = root.winfo_pointerxy() print(...
4e1472347206df2f3bc71eb443ed25a829b4735b
akjalbani/Test_Python
/Misc/Medium_Large_Scripts/sample_emp.py
3,211
4.1875
4
# This script is for learning purpose import os import platform import replit replit.clear() global listEmp #Making ListEmp As Super Global Variable listEmp = ["Mark", "Navy", "Edgar", "Rashi", "Rehab","Taylor","Paul","Pumi","Zoey"] #List Of Employees def manageEmployee(): #Function x = "#" * 30 y = "=" * 28 glo...
e6d26f45c62d5a0b943c6c43e712fe04dc9307d1
akjalbani/Test_Python
/Misc/Network/dictionary_examples.py
2,039
4.5
4
# let us have list like this devices = ['router1', 'juniper', '12.2'] print(devices) ############### Another way to print values ######################### for device in devices: print(device) #If we build on this example and convert the list device to a dictionary, it would look like this: devices = {'hostname': 'rou...
e48318e1dc8b9e8e57699af9d4654f3f9403ddf0
akjalbani/Test_Python
/Misc/Network/validate_ip.py
341
3.796875
4
def validate_ip(addr): a = addr.split('.') if len(a) != 4: return False for x in a: if not x.isdigit(): return False i = int(x) if i < 0 or i > 255: return False return True addr=input("Enter the IP address:") address=validate_ip(addr) if address: print('Valid IP') else: ...
1ab7300e6044bcaae7b6543c3b7f62d09c039edb
akjalbani/Test_Python
/Misc/PythonFilling/Excel/reading_excel_file.py
256
3.5
4
# load any excel_file # filename.xlsx # if pandas is not installed use commdand to install pandas - pip install pandas # tested on python IDLE import pandas as pd excel_filename = input("Enter file name : -> ") df= pd.read_excel(excel_filename) print(df)
1da9d68ed4df02d7543dee4fe16714ee33bd2c04
akjalbani/Test_Python
/Misc/LogAnalysis/send_alert.py
1,480
3.78125
4
''' This script will create an email message with the specified subject and body, and it will use the smtplib library to connect to the email server and send the message. You will need to modify the script to use the correct email address and password for your account, as well as the correct SMTP server and port for...
0b15032255d72f2bca7d782491b3ddc647899c8e
akjalbani/Test_Python
/Misc/LogAnalysis/failed_logins.py
1,837
4.09375
4
''' This script will open the log file located at /path/to/log/file.log and search each line in the file for failed login attempts. It uses a regular expression to extract the IP address of the client that made the failed login attempt, and it keeps a count of the number of failed login attempts per IP address. If t...
29900772d1df82995e52988be2eba8303b1457fd
akjalbani/Test_Python
/Misc/Turtle_examples/shape2.py
288
4.15625
4
# Turtle graphics- turtle will draw angle from 0-360 (15 deg) # tested in repl.it # Type- collection and modified import turtle turtle = turtle.Turtle() for angle in range(0, 360, 15): turtle.setheading(angle) turtle.forward(100) turtle.write(angle) turtle.backward(100)
290dec9608903b300d6b4ff7930ada79157c9de3
treehopper-electronics/treehopper-sdk
/Python/treehopper/libraries/flushable.py
3,051
3.8125
4
import abc class Flushable(abc.ABC): """ Base class for any type of output device that can be flushed. Many output devices --- like LED drivers, GPIO port expanders, or displays --- are "flushable" devices. They contain individually-addressable components (such as individual GPIO pins): in certain ap...
f0f3fcbd2de1d87a3a68b8d19dcea90dab61c5c3
ravi4all/ML_JulyRegularEvening
/Python_Codes/prime_number_2.py
245
3.796875
4
num = int(input("Enter a number : ")) numbers = [] for n in range(num+1, num+50): for i in range(2, n): if n % i == 0: print("Not Prime",n) break else: print("Prime",n) break
255724b8bd84e1a0dbd793d35eec9d935fb480f5
susankorgen/cygnet-software
/Python100DaysClass2021/py/CoffeeMachineOOP/coffee_maker.py
2,064
4.15625
4
# Instructor code. # Except: Student refactored the self.resources structure and added get_resources. class CoffeeMaker: """Models the machine that makes the coffee""" def __init__(self): self.resources = { "water": { "amount": 500, "units": "ml", ...
8b03e83d0ce6fe77c885710b629cec7d26c6125f
susankorgen/cygnet-software
/Python100DaysClass2021/py/CoffeeMachineOOP/money_machine.py
1,573
3.875
4
# Instructor code. # Except: Student added exception checking in process_coins(), touched up money messages. class MoneyMachine: CURRENCY = "$" COIN_VALUES = { "quarters": 0.25, "dimes": 0.10, "nickels": 0.05, "pennies": 0.01 } def __init__(self): self.profit ...
b39ca3c96d692a0e3aca19c44cc73ba315022b4b
zhangbin0git/demo
/alien_invasion/ship.py
1,765
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Time : 17-7-29 下午1:26 # @Author : Zhangbin # @Site : # @File : ship.py # @Software: PyCharm Community Edition # 游戏中的元素角色类 # 飞船类 import pygame class Ship(pygame.sprite.Sprite): """飞船类""" def __init__(self, settings, screen): """初始化飞船的各个参数""" ...
c13e5dda54bf732e9dda14fb870da1fa035334a5
zhangbin0git/demo
/unittest/names.py
742
3.828125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Time : 17-7-28 上午1:39 # @Author : Zhangbin # @Site : home # @File : names.py # @Software: PyCharm Community Edition # 更加用户的输入格式化名字 import get_formatted_name print("请输入您的名字,如果退出请输入'q'") # 循环开始 while True: # 输入第一个名字 first_name = input("请输入firstname") ...
4bafd9f11ea338a2299508ea950ff3c37bacedc3
PyLov3r/intermediate_python
/c)OOP.py
1,710
3.953125
4
#Classes class Cat: def __init__(self, color, legs): self.color = color self.legs = legs def talk(self): print("Miau") felix = Cat("ginger", 4) print(felix.color) felix.talk() #Inheritance class Animal: def __init__(self, name, color): self.name = n...
67db80413e488c03cbffbf152d726771cb129052
RuiTTTT/mlp
/mlp.py
8,281
3.671875
4
#!/usr/bin/env python import math import random import csv random.seed(1) # method for initialize weights randomly between 0-1 def randomise(m, n): return [[random.random() for i in range(n)] for j in range(m)] # sigmoid activation function def sigmoid(x): return 1.0 / (1.0 + math.exp(-x)) def sigmoid_deriv...
63cdd3ddd6b76d250d77fd038b8a639d1f9724d5
jimmielin/HW-Numerical-Physics-201718
/ex8-spline.py
9,811
3.78125
4
#################################################################### # Computational Physics, 2017-18 Sem1 # HW-1 Ex-8 # # (c) 2017 Haipeng Lin <linhaipeng@pku.edu.cn> # All Rights Reserved. # # This program is written as Homework for the Computational Physics # Course in Peking University, School of Physics. # NO WARR...
ebc2088e067edd2a766591f0b67c7a7a903a7b7d
Bot-Mau/MST-Python-Package
/Math-2305-Final-Project-Fall-2020/algorithms.py
1,336
4.0625
4
import networkx as nx from functions import * from drawing import show_weighted_graph, draw_subtree def prims_algorithm(G, starting_vertex, show_graph = False, show_cost = False): #The function reads the graph G and uses starting_vertex to run prim's algorithm #it will create a temp graph T which is a co...
94bf2f2ad42eb83effc247ef6b44ed5593772710
kilianbasalo/MonPremierProjet
/tp01_ex2.py
5,175
3.9375
4
""" Programme simulant un distributeur de snacks Données : - Un montant entré par l'utilisateur - Un numéro d'article entré par l'utilisateur Indications : Le distributeur comporte : - Sandwich au poulet à 4.90 - Chips paprika à 2.50 - Barre chocolat à 2....
67885bd76e1123a3360966b6976cc4eeec31d995
TatianaFilimonova/labs
/Laba5.Farmer/laba5.py
1,607
3.5625
4
import xlrd from pulp import * var = int(input("Enter the number of your option: ")) n = var + 1 Yield = [] available = [] profit = [] names = [] rb = xlrd.open_workbook(r'FARMER.xls', formatting_info=True) sheet = rb.sheet_by_index(0) k = 1 for i in range(k, k+6): Yield.append(sheet.row_values(n)[i]) k += 6 for ...
c9b9cad8817833eaf199b1ff49bea7f9f391ce22
cantis/PythonCourse
/Archive/ChallengeProgramFlow1.py
384
3.6875
4
address = input("Ip Address: ") segmentCount = 1 segmentLength = 0 i = "" for i in address: #print(i) if i == '.': print("Segment {} length {}".format(segmentCount, segmentLength)) segmentCount += 1 segmentLength = 0 continue segmentLength += 1 if i != '.': p...
0b8cfcb728326bd5d4df4dbee0c00b197d94aba6
SpecCRA/feb19_swd_submission
/plot_code.py
4,362
3.546875
4
# Plotly code for February submission """ 1. Plot all teams besides the Mavs and Rockets in light grey 2. Create a separate plot for the Mavs and Rockets outside of the loop 3. Annotations: label min and max points - make dots for each """ # assign variables for notable points highest_scoring_game = df[df['PTS'] == 1...
506df0e07331bd7b2c002c240f0e931e79f8209d
Merigold89/Tic-Tac-Toe
/Tic-Tac-Toe.py
18,494
4.46875
4
""" A program to play Tic-Tac-Toe Author: KG """ import random class TicTacToe: print('Welcome to the tic-tac-toe game!\nPlayer X starts the game.\nEnter: start user/level user/level ' '(level: easy, medium, hard. To play 3 parameters are needed!) or "exit" or "help"\nGood luck!') def ...
525f27d7421d641ac2f00ac072e2c88aa6af51bd
shubamsharma/PythonSolutions
/05_edit_distance_and_image_from_text/min_max.py
745
3.5625
4
from functools import reduce def is_digit(n): try: int(n) return(True) except ValueError: return(False) def validate_array(func): def inner(A): print("Recieved array ", A) validate_arr = all([is_digit(s) == True for s in A]) if not validate_arr ...
8abae0c0aaf151fe03e2f8d922e202451c3f6218
Sewar-web/data-structures-and-algorithms1
/graph-depth-first/graph_depth_first/depth_first.py
776
3.734375
4
from collections import defaultdict class Graph: def __init__(self): self.graph = defaultdict(list) def addEdge(self, u, v): self.graph[u].append(v) def DFSUtil(self, v, visited): visited.add(v) print(v, end=' ') for neighbour in ...
1667473bf1f8a025e3592f2814e3d902f096c57b
Sewar-web/data-structures-and-algorithms1
/queue-with-stacks/queue_with_stacks/queue_with_stacks.py
2,748
4.0625
4
class Node: def __init__(self, value): self.value = value self.next = None class Stack: def __init__(self): self.top = None def push(self, value): node = Node(value) node.next = self.top self.top = node def pop(self): try: temp...
d37b1b5db9386fbcba6cc3aae14b959d23e86b3b
ls-daily-projects/graphs_sprint
/graph_adventure/traversal_test.py
575
3.5
4
def test_traversal(world, player, room_graph, traversal_path): visited_rooms = set() player.current_room = world.startingRoom visited_rooms.add(player.current_room) for move in traversal_path: player.travel(move) visited_rooms.add(player.current_room) if len(visited_rooms) == len(ro...
9840843031a759178d05003675aaad28622a12da
MasterFishfish/TNet
/testpackage/testpanda.py
604
3.671875
4
import pandas as pd import numpy as np def returnlist(): return ["a", "b"] if __name__ == '__main__': a = {"a": 1, "b": 2} b = {"a": 2, "b": 3} c = {"a": 3, "b": 4} d = {"a": 4, "b": 5} a1 = [] a1.append(a) a1.append(b) a2 = [] a2.append(c) a2.append(d) a3 = [] a3.ap...
ef87da55143b0ab5ba73f5da75bd399b0d93a54b
FelipeMolinari/Interpretador-Python
/compilador.py
2,912
3.65625
4
# O Objetivo é construir um compilador simples, capaz de fazer a análise semântica de # uma linguágem de exemplo # @author Felipe Molinari # 2/01/2021 import re from Interpretador import Interp END_WITH_SEMICOLON = ";$" START_WITH_CHARACTER = "^[a-zA-Z]" HAS_ASSIGNMENT_SIGNAL = "^[a-zA-Z]=.+;$" ASSIGNMENT_CORRECT =...
aba70e1a8cbb7b1496f55a978260b7f0f45dc614
stellazhang7/python3
/818_Dict.py
139
3.703125
4
dict = {"stella":50,"bunny":200} print(dict["stella"]) del dict["bunny"] print(dict) print(len(dict)) #有多少键值对 key-value pair
767e51ac875a9779f60ab152e9920c8bb8112437
stellazhang7/python3
/811_CelsiusToFahrenheit.py
209
4
4
# 接受一个输入到a 将它转换成整数后 根据公式算出华氏度再转换成字符串拼接输出 a = input("please input celsuis degree: ") c = int(a) print("fahrenheit is " + str(c * 1.8 + 32))
17e235ab89f51491c6f69260736417c3447bca43
TALABOULMA-Walid/python-learn
/Sources/improve/letterpress_cheat.py
1,925
3.53125
4
# use python -m cProfile letterpress_cheat.py import pickle from itertools import combinations PICKLE_WORD_FILE = "anagram-dictionary.pickle" WORDS_FILE = "/usr/share/dict/words" def create_anagram_dict(): """Creates a dictionary of all possible anagrams associated with their corresponding words""" try: ...
243915ea93ce6e827af68578a2ef6019dca26f1d
kalilventura/python
/exemplos/Procedural/conjuntos.py
515
3.796875
4
""" Sets não podem ter elementos duplicados add -> adiciona um dado update -> atualiza clear -> discard -> union ou | -> une intersection ou & -> todos os elementos presentes nos dois sets difference ou - -> elementos apenas no set da esquerda symmetric_difference ou ^ -> elementos...
ed0a03d3990ab93891c9236bef074db50cb876c2
kalilventura/python
/exemplos/Basico/leitura_teclado.py
280
4
4
# Entrada de dados nome = input("Qual seu nome?") idade = input('Qual sua idade?') ano_nascimento = 2021 - int(idade) print(f'usuario digitou {nome} e o tipo da variavel eh {type(input)}') print(f'{nome} tem {idade} anos.') print('Ano de nascimento {}'.format(ano_nascimento))
84541b7ceb0b56ad10f0fede67d7c32823d09814
ianmanalo1026/Projects
/Biginners/Guess the number (Project1).py
2,015
4.15625
4
import random class Game: """Player will guess the random Number""" def __init__(self): self.name = None self.number = None self.random_number = None self.indicator = None def generateNumber(self): self.random_number = random.randint(1,5) return se...
d38f4b9e9ce4026f30fe5850b9d565ceddcb80f6
cwkteacher/L4-Fortune-Teller
/Fortune-Teller-Basic/main.py
843
3.890625
4
import random from time import sleep import os fortunes = ['You will be very successful this year.','Next year will bring great things.', 'You will come into a large fortune.', 'This will be a very bad year for you.', 'You will not be successful this year.','You will lose something very dear to...
488421439b7188696f4e4d7f33dcc682e1bb3ef9
120Davies/Intro-Python-I
/src/13_file_io.py
1,074
4.375
4
""" Python makes performing file I/O simple. Take a look at how to read and write to files here: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files """ # Open up the "foo.txt" file (which already exists) for reading # Print all the contents of the file, then close the file # Note: pay close...
7e5119ca060af71e974544836406b8485a276949
jojonium/CS-2223-Algorithms
/Project 3/project_3.py
5,615
3.71875
4
# Joseph Petitti # Project 3 import sys from getopt import getopt, GetoptError from itertools import chain, combinations from time import perf_counter # Input: list l # Output: a list that represents a set of all subsets of list l def power_set(l): return chain.from_iterable(combinations(l, r) for r in...
7a8c19be074a7e62db5186dffe71d345b512fd26
serguei9090/Folder_Size_on_name
/put_folder_size-3rtv.py
2,049
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from pathlib import Path import os def humanbytes(B): 'Return the given bytes as a human friendly KB, MB, GB, or TB string' B = float(B) KB = float(1024) MB = float(KB ** 2) # 1,048,576 GB = float(KB ** 3) # 1,073,741,824 TB = float(KB ** 4) # 1,099,511,62...
bfe971aa1d5fa1c90cd08571c7d93b48027e266f
n-rajesh/Python
/Countdown Sys Mgr.py
1,070
3.625
4
""" This is a program to perform hibernate,shutdown or restart after the specified countdown time. Use powercfg /h on in Command prompt to enable hibernation. Replace on with off to disable it. """ import msvcrt import os import time print(__doc__) t = 1 c = int(input('\t1-Hibernate 2-Shutdown 3-Restart ...
5110b6adba216d616a5e43e7b644445a4252028c
Jerrykim91/FromZero
/1.kfq_Python/p8.py
666
3.6875
4
# 조건문, 반복문 # 내장함수 input() : 터미널을 통해 사용자 입력을 받는다 # 문자열를 리턴, 인자를 넣으면 프럼프트로 사용된다 ######################################################### price = int(input( '족발막국수는 얼마인가요?' )) print( price ) # : 조건문, 반복문 등 문장의 끝을 의미하고, 코드블럭을 시작해라 의미 if price > 6000 : # statement 최소 1줄에 대한 조건만족, 아무것도 하지 말아라 print('6000원 아닌가요') ...
6cff4bf0fee12e69679cfb46acbb840702749109
nataway/Python-PTIT
/tachsovasapxep.py
474
3.53125
4
""" Author: Tris1702 Github: https://github.com/Tris1702 Gmail: phuonghoand2001@gmail.com Thank you so much! """ N = int(input()) list_num = [] for n in range(N): s = input() s = s+'#' num = -1 for i in s: if i.isnumeric(): if num == -1: num = 0 num = num...
b3b2b4b47183d1febece5b1f0575fec66637ce3f
nataway/Python-PTIT
/tongchusonguyento.py
388
4.03125
4
""" Author: Tris1702 Github: https://github.com/Tris1702 Gmail: phuonghoand2001@gmail.com Thank you so much! """ import math def isPrime(x): for i in range(2, int(math.sqrt(x))+1): if x % i == 0: return 'NO' if x > 1: return 'YES' else: return 'NO' T = int(input()) for t in range(T): ...
30e1f6efcef4e34840e5b570440ec8bd1c4a9f8a
nataway/Python-PTIT
/solocphatdep.py
287
3.921875
4
""" Author: Tris1702 Github: https://github.com/Tris1702 Gmail: phuonghoand2001@gmail.com Thank you so much! """ def check(s): if ('888' in s) or (s[0] == '8'): return 'NO' for i in s: if i != '6' and i != '8': return 'NO' return 'YES' s = input() print(check(s))
2ff7396eb3c7e5ca1de11b3c1d31a91b3953e9d9
nataway/Python-PTIT
/sokhonggiam.py
347
3.65625
4
""" Author: Tris1702 Github: https://github.com/Tris1702 Gmail: phuonghoand2001@gmail.com Thank you so much! """ T = int(input()) for t in range (0, T): a = input() check = False for i in range (1, len(a)): if int(a[i-1]) > int(a[i]): print('NO') check = True brea...
0e646d9f662b0ae5cedafb7a3b4407e2c9b7e752
nataway/Python-PTIT
/chenxau.py
299
3.703125
4
""" Author: Tris1702 Github: https://github.com/Tris1702 Gmail: phuonghoand2001@gmail.com Thank you so much! """ s1 = input() s2 = input() vt = int(input()) - 1 check = True for i in range(0, len(s1)): if (i == vt): print(s2, end = '') check = False print(s1[i], end = '') if check: print(s2)
89d1a6d4c5fc6a449957a1b1c467d2e6b4082f2f
nataway/Python-PTIT
/songuyentolonnhattrongmatran.py
679
3.78125
4
""" Author: Tris1702 Github: https://github.com/Tris1702 Gmail: phuonghoand2001@gmail.com Thank you so much! """ import math def isPrime(x): for i in range(2, int(math.sqrt(x))+1): if x%i == 0: return False return x > 1 n,m = map(int, input().split()) a = [] for i in range(n): a.append(...
ab965f2581f0a63c10f4134fb82bf11c0e0cc2cc
Cwalker924/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/3-common_elements.py
170
3.59375
4
#!/usr/bin/python3 def common_elements(set_1, set_2): new_list = [] for ch in set_1: if ch in set_2: new_list.append(ch) return(new_list)
ecac3eaccf3fa1d8e00f77c8fcb7fc60ed26fe1e
Thornecooper123/food
/version 2.py
1,587
3.515625
4
# Fast Food gui # Thorne """ Program description """ # import libraries from appJar import gui # variables # class definitions class Gui: def __init__(self): app = gui("Menu", "800x600") app.setFont(20) # Frames to pick set menu items with app.toggleFrame(...
34636cad9bf5df526599d7b601829dc83f4db0d5
KleyLima/moedas
/source/moedas.py
1,949
3.734375
4
# -*- coding: utf-8 -*- from sys import argv class Moedas: """ Classe que representa as moedas, seus valores e relação na sua distribuição dado um valor.""" @classmethod def __init__(cls, vlr): """ Método que inicializa os atributos da classe, define as moedas disponiveis para distribuiç...
647fc588ebf05a65e148f42016e98080771531bd
dorkamotorka/Sudoku---Python
/model.py
5,154
3.734375
4
""" This module implements functionalities of the sudoko game """ import random class Player : def __init__(self, name, symbol) : self.name = name self.symbol = symbol class Game : def __init__(self, name1, name2, symbol1, symbol2) : self.name1= name1 ...
d5ee72e73fee1cd70adf40fdb02531131cbf6301
cmkerner20/ps3_4
/product.py
3,919
4.03125
4
import sys import os import math """ CS121 HW3 2017 """ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Helpers functions from HW2. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ''' These make properly formated strings given triples of variables. '''...
9d02365e69d9865526ac32f34421c2bbd641ea96
RocioPuente/KalAcademyPython
/PI2.py
107
3.578125
4
from fractions import Fraction a = [] for i in range (1, 17, 2): a = a + [Fraction(1,i)] print(a)
9e9ef10d9a14981aa09bed88da4ff5c520e7708b
RocioPuente/KalAcademyPython
/HW2/Celsius.py
133
3.765625
4
Celsius = eval(input("Enter temperature in Celsius:")) fahrenheit = (9/5)*Celsius+32 print("Temperature in fahrenheit:", fahrenheit)