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
751eba4e5bb07a8aedd1b07c34deb61883a7fcf6
AlgorithmOnline/jaeeun
/2_20210216.py
353
3.625
4
def solution(routes): routes.sort() answer = 1 travel = routes[0] for i in range(1,len(routes)): travel2=routes[i] travel =[max(travel[0], travel2[0]), min(travel[1], travel2[1])] if travel[0]<=travel[1]: continue else: answer+=1 travel...
e52687a118e5b20633742d2de98ca183ebe7fe4d
AlgorithmOnline/jaeeun
/2_20200812.py
703
3.625
4
# 프로그래머스 이중 우선순위 큐 def solution(operations): # 항상 소팅이 돼어 있어야한다. answer = [] queue=[] for op in operations: if op[:1] =='I': queue.append(int(op[2:])) queue.sort() elif op =="D 1": # 최대 제거 if len(queue) ==0: continue else: ...
6e480641effc28b3d49ea423dee4cb516febb2f7
AlgorithmOnline/jaeeun
/1_20210205.py
982
3.828125
4
import math x0, y0, r0, x1, y1, r1 = map(float, input().split()) def area(x0, y0, r0, x1, y1, r1): d = math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2) rr0 = r0 * r0 rr1 = r1 * r1 # Circles do not overlap if (d > r1 + r0): return 0 # Circle1 is completely inside circle0 elif (d <= abs(r...
5cef9d58b690a0e6a805fc83a8483ca890e889f3
pengjinfu/DemoDjango
/study/ArrayClass.py
2,401
3.75
4
import random import re import statistics class ArrayClass: def __init__(self, name, init_arr): self.name = name self.init_arr = init_arr def to_string(self): return self.name def demo_arr(self): arr = ['a', 'b', 'c'] return arr.append(self.name) def demo_if(...
9e18840ba570b2c8366a8bf68e9ffcab18782421
PaNOSC-ViNYL/XOPPY
/devel/glossary/test1.py
564
3.515625
4
def read_json(json_name): json_text = open(json_name).read() json_dict = eval(json_text) json = sorted(json_dict.items(), key=lambda x: json_text.index('"{}"'.format(x[0]))) #print(json) #json_lowercase = dict((k.lower(), v) for k, v in json.iteritems()) json_lowercase = json ...
90d819ae7a224af104405a39d6e75a3f38eab8e6
MrCat9/HelloPython
/从list删除元素.py
377
3.84375
4
#用list的pop()方法删除最后一个: L = ['Adam', 'Lisa', 'Bart', 'Paul'] L.pop() print(L) #['Adam', 'Lisa', 'Bart'] #Paul的索引是2,用 pop(2)把Paul删掉: L = ['Adam', 'Lisa', 'Paul', 'Bart'] L.pop(2) print(L) #['Adam', 'Lisa', 'Bart'] #如果我们要把Paul和Bart都删掉 L = ['Adam', 'Lisa', 'Paul', 'Bart'] L.pop(2) L.pop(2) print(L) #['Adam', 'Lisa']
f0054948c66568ce30cb8d9e94d723b5179de097
MrCat9/HelloPython
/list中替换元素.py
298
4.21875
4
#先删除,在添加==替换 #对list中的某一个索引赋值,就可以直接用新的元素替换掉原来的元素,list包含的元素个数保持不变。 L = ['Adam', 'Lisa', 'Bart'] print(L) #['Adam', 'Lisa', 'Bart'] #L[2] = 'Paul' L[-1] = 'Paul' print(L) #['Adam', 'Lisa', 'Paul']
682ccfae072a9a22bfe9374f7ce0ebb0a0d43f8d
MrCat9/HelloPython
/Python之set.py
4,832
4.125
4
#dict的作用是建立一组 key 和一组 value 的映射关系,dict的key是不能重复的。 #有的时候,我们只想要 dict 的 key,不关心 key 对应的 value,目的就是保证这个集合的元素不会重复,这时,set就派上用场了。 #set 持有一系列元素,这一点和 list 很像,但是set的元素没有重复,而且是无序的,这点和 dict 的 key很像。 #创建 set 的方式是调用 set() 并传入一个 list,list的元素将作为set的元素: s = set(['A', 'B', 'C']) print(s) #{'A', 'B', 'C'} #请注意,上述打印的形式类似 list, 但它不是 list,...
fd2c03b45022de5c70da5245fa75ffb03cc39093
JamesTadleyGreen/Instagram_Liker
/instagram.py
3,168
3.53125
4
#Program to load up instagram, login using details, navigate to specific tags # and like a specified number of photos. Then record data in text file. #imports from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys import webbrowser import ti...
af846700f2a2ec653612061a5208a5281052d5ad
OsaAjani/cours-iot
/introduction_a_python/tp/crypto_price.py
1,064
3.609375
4
#!/usr/bin/env python3.5 #-*- coding: utf-8 -*- import cryptocompare def quit () : print('Merci d\'avoir utilisé CryptoPrice !') exit(0) def show_coin_list () : coin_list = cryptocompare.get_coin_list(format = True) for coin in coin_list : print(coin) def show_coin_price (coin) : if ...
8c893dcb173cb7dc653d93d89512e184b80016b3
caspeerpoiuy/data-structures-and-algorithms-
/classical_algorithms/select_sort/implement.py
544
4.0625
4
def select_sort(alist): """ select sort thinking: compare element and find the min index, if element less than min, change their position. """ if len(alist) == 0: return for i in range(1, len(alist)): min_index = i - 1 for j in range(i, len(alist)): if ali...
bb6d923f1614534d539d9e4258a80235ae73fab2
stepin105014/github-upload
/proj_base.py
1,955
3.796875
4
from nltk.tokenize import sent_tokenize, word_tokenize import nltk from nltk.corpus import stopwords """ Reading Input """ val = input("Enter the text : ") print ("Input given :"+ str(val)) # Tokenization tokens=sent_tokenize(val) print("Tokens are :") print(tokens) wtokens=word_tokenize(val) print("Word Tokens...
773b1abb8495beae8dbe657a1b3d3785cdcb3442
danhouldsworth/helloLanguages
/HelloWorld+/hello.py
153
3.875
4
# 1. Done # Note: This is the syntax for Python 2.X # in Python 3.x print is a function. greeting = "Hello" greeting += ", " + "world!" print greeting
cff75e4f5f2a051df3653fa1ec86e01f371d19c5
Likhith-Sreekar/PYTHN-PROGRAMS
/addition.py
157
3.96875
4
def addition(no1,no2): Result=no1+no2 return Result a=int(input('Enter the 1st number')) b=int(input('Enter the 2nd number')) print(addition(a,b))
ee7879ca5072d5cbd6c99433d5fac43371752348
balbok0/MC-and-Jet-Tutorial
/scicomp/debug/conways_game_of_life/2_conway_pre_formatted.py
1,049
3.84375
4
#!/usr/bin/env python """ Conway's game of life example, part two. This does not conform to PEP8 standards. Use pep8 to check most standards, and then fix the others by eye. """ def conway(population, generations = 100): for i in range(generations): population = evolve(population) return pop...
fa3a024cd1fec523eb0023f13eb5bd1485e8e123
daminiamin/Dictionary-WordCount
/wordcount.py
344
3.515625
4
# put your code here. test_file = open("twain.txt") def counts_words(phrase): word_count = {} for line in test_file: words = line.split() for word in words: word_count[word] = word_count.get(word, 0) + 1 for word in word_count.items(): print(f"{word[0]} {word[1]}") ...
62442ae7e65f511647a46820a322ba70380eab54
TOlmsteadWSCU/CS-310-Python-Projects
/Bank_TOlmstead_310/Account.py
748
3.765625
4
# class for one account class Account: ''' An account consists of an owner and a balance ''' def __init__(self,account_num, owner,init_balance=0): self.account_num = account_num self.owner = owner self.balance = init_balance def credit(self,amt): self.balance+=amt ...
5bb4b5f9a9d2b22fde70d344a9da5230e75354f8
Eiman24/FM6001
/fishrename.py
2,027
3.546875
4
# 对cocos捕鱼资源文件进行重命名 import os, sys def main(): pass # list_foldernames = ['dragon', 'quanpingzhadan', 'shayu', 'haitun', 'chuitousha', 'bianfuyu', 'hetun', 'jianzuiyu', 'shiziyu', 'dianman', 'xiaowugui', 'denglongyu', 'hudieyu', 'xiaochouyu'] # for foldername in list_foldernames: # name_changer(f...
4bba499b572fe4986ef55e08439058a60ab5b4fd
parthjpatelx/deviations
/app.py
2,164
3.890625
4
# Reading an excel file using Python import xlrd, datetime import xlwt from xlwt import Workbook def write_deviation(last_name, date_string, cycle_name, IRB_number): my_deviation = f"Patient {last_name} was assessed on {date_string} for {cycle_name} on {IRB_number}. At this visit, the patient was dispensed drug. H...
b6bf1a9a7938250f814500050793e86a23f35b32
aalyar/Alya-Ramadhani_I0320123_Mas-Abyan_Tugas2
/I0320123_soal1_tugas2.py
1,043
3.859375
4
#menghitung luas persegi panjang print("Luas Persegi Panjang") p = float(input("Masukkan panjang: ")) l = float(input("Masukkan lebar: ")) luas_persegi_panjang = p * l print("luas persegi panjang:", luas_persegi_panjang) print("---------------") #menghitung luas lingkaran print("Luas Lingkaran") r = float(input("Mas...
62c04de5e4a5b2f1fb9b4526cd62aea1cc781fa7
audtjf4008/programming
/0624/dna.py
853
3.734375
4
def comp(seq): comp_dict={'A':'T','T':'A','C':'G','G':'C'} seq_comp = "" for char in seq: if char in comp_dict: seq_comp += comp[char] else: seq_comp += '?' retrun seq_comp def rev(seq): seq_dna = "ATGC" seq_rev = "" for char in seq: ...
d366f6bc0285023ec30a6ff8cb2e236c3f6e477f
JEONINSUCK/PythonChallenge
/pythonchallenge stage 15.py
662
3.59375
4
import re import calendar as cal def cal_year(year): if (year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)): return True else: return False data = [] for year in range(1000,2017): if cal_year(year)==True: data.append(year) else: continue string = "" f = [] for i in ...
c29038f295cdeb6c21fd9664df9d3898d19d7ede
KamilPrzybysz/python
/04.03.18/zad3/zad3.py
86
3.890625
4
lista=[1,2,3,4,5,6,7,8,9,10] print(lista) lista=list(i*3 for i in lista) print(lista)
3de7a31e38f1766045412875190ac2293f627c99
KamilPrzybysz/python
/04.03.18/zad6/zad6.py
480
3.59375
4
def funkcja(wektor1, wektor2): iloczyn=0 c=len(wektor1) for i in range(c): iloczyn+=wektor1[i]*wektor2[i] return iloczyn a=int(input('Podaj dlugosc wektorow: ')) w1=[] w2=[] for i in range(a): w1.append(int(input('Podaj '+str(i+1)+' wartosc do wektora w1: '))) print('-------------') for i i...
b2d765b6068e05992dbce84a502fadba875fb304
jvfd3/DataStructure
/Lists/LE2/Codigos/Programas Exemplo 7 - Casamento de parênteses em Python/Casamento_Parenteses.py
1,080
3.953125
4
# Livro: Data Structures and Algorithms Using Python. Rance Necaise. 2011. # casamento_parenteses.py - # Verifica o balanceamento de parenteses (, { e [ usando uma pilha em Python. from lliststack import Stack # Nome do Arquivo a abrir FILE_NAME = "no-errors.txt" def main() : arquivo = open( FILE_NAME, "r" ...
90a3fab2b6574e51e6330ee053c5d10c472dbae7
BirgerK/KL_HAW
/MDP/Aufgabe4/Birger/MDP_Aufgabe4/src/Simulation/Elevator.py
4,983
3.6875
4
import Simulation from Simulation.Statuses import ElevatorStatus, DoorStatus, Direction, CallStatus class Elevator(object): 'An elevator which transports people vertically in a building.' def __init__(self, elevator_id, start_in_floor, scheduler): self._id = elevator_id self._current_floor = ...
308d8f4dca8b463b3717c5b015f55ff2efad0a39
jvano74/advent_of_code
/2019/day_19_test.py
15,791
3.828125
4
import pytest from typing import List, NamedTuple class Puzzle: """ --- Day 19: Tractor Beam --- Unsure of the state of Santa's ship, you borrowed the tractor beam technology from Triton. Time to test it out. When you're safely away from anything else, you activate the tractor beam, but nothing happe...
9f1b37c28e8170fb67895bd40725672c8e4bc742
jvano74/advent_of_code
/2015/day_21_test.py
7,514
4.1875
4
from typing import NamedTuple class Puzzle: """ --- Day 21: RPG Simulator 20XX --- Little Henry Case got a new video game for Christmas. It's an RPG, and he's stuck on a boss. He needs to know what equipment to buy at the shop. He hands you the controller. In this game, the player (you) and the e...
8c4df39a55b73cc8d7786370c03137bc3074cab5
jvano74/advent_of_code
/2015/day_03_test.py
3,093
4.09375
4
def move(d, x, y): if d == ">": x += 1 elif d == "<": x -= 1 elif d == "^": y += 1 elif d == "v": y -= 1 return (x, y) def ans(directions): """ --- Day 3: Perfectly Spherical Houses in a Vacuum --- Santa is delivering presents to an infinite two-dimensio...
58899a589a4d90c428776ed8f74fc59fb5b2eff3
jvano74/advent_of_code
/2016/day_04_test.py
4,107
3.8125
4
from collections import defaultdict class Puzzle: """ --- Day 4: Security Through Obscurity --- Finally, you come across an information kiosk with a list of rooms. Of course, the list is encrypted and full of decoy data, but the instructions to decode the list are barely hidden nearby. Better remo...
3869487719f0196d56f2005a5af45c204295ac1b
jvano74/advent_of_code
/2015/day_02_test.py
3,121
4.125
4
def wrapping_paper_needed(input): """ --- Day 2: I Was Told There Would Be No Math --- The elves are running low on wrapping paper, and so they need to submit an order for more. They have a list of the dimensions (length l, width w, and height h) of each present, and only want to order exactly as mu...
31edc903410b6781967b9413700b031d931133cf
jvano74/advent_of_code
/2015/day_12_test.py
4,696
4.3125
4
import re import json def string_sum(string): """ --- Day 12: JSAbacusFramework.io --- Santa's Accounting-Elves need help balancing the books after a recent order. Unfortunately, their accounting software uses a peculiar storage format. That's where you come in. They have a JSON document which co...
3589a4854d2b38e36d8d56f28c18f1cbf0658266
jvano74/advent_of_code
/2021/day_22_test.py
18,996
4.34375
4
from typing import NamedTuple class Puzzle: """ --- Day 22: Reactor Reboot --- Operating at these extreme ocean depths has overloaded the submarine's reactor; it needs to be rebooted. The reactor core is made up of a large 3-dimensional grid made up entirely of cubes, one cube per integer 3-dimensional coordina...
59e3b18b030420f4459be6dea16c073f06107e35
jvano74/advent_of_code
/2022/day_25_test.py
9,351
4
4
class Puzzle: """ --- Day 25: Full of Hot Air --- As the expedition finally reaches the extraction point, several large hot air balloons drift down to meet you. Crews quickly start unloading the equipment the balloons brought: many hot air balloon kits, some fuel tanks, and a fuel heating machin...
cdb0945d8a75534c693b3f7f98a33625ecb37013
jvano74/advent_of_code
/2021/day_14_test.py
6,582
3.6875
4
from collections import Counter class Puzzle: """ --- Day 14: Extended Polymerization --- The incredible pressures at this depth are starting to put a strain on your submarine. The submarine has polymerization equipment that would produce suitable materials to reinforce the submarine, and the nearby volcanically-...
761eaf9b854f25f069f8d0914e05f8b4f8061a3e
jvano74/advent_of_code
/2017/day_01_test.py
4,078
3.625
4
class Problem: """ --- Day 1: Inverse Captcha --- The night before Christmas, one of Santa's Elves calls you in a panic. "The printer's broken! We can't print the Naughty or Nice List!" By the time you make it to sub-basement 17, there are only a few minutes until midnight. "We have a big problem,"...
31ed8b9e8c193dede6b06754ef6b90a4ae1ae1c6
jvano74/advent_of_code
/2016/day_23_test.py
7,593
4.03125
4
from collections import defaultdict import re class Puzzle: """ --- Day 23: Safe Cracking --- This is one of the top floors of the nicest tower in EBHQ. The Easter Bunny's private office is here, complete with a safe hidden behind a painting, and who wouldn't hide a star in a safe behind a painting? ...
826c7072cc6bada4b595106229046b138cf40f12
jvano74/advent_of_code
/2015/day_07_test.py
8,515
3.703125
4
import numpy as np import re from collections import defaultdict import pytest class Puzzle: """ --- Day 7: Some Assembly Required --- This year, Santa brought little Bobby Tables a set of wires and bitwise logic gates! Unfortunately, little Bobby is a little under the recommended age range, and h...
10d96b7f5971f9b28f49ec364b828da700e6d616
jvano74/advent_of_code
/2018/day_13_test.py
10,792
4.28125
4
from typing import NamedTuple class Puzzle: r""" --- Day 13: Mine Cart Madness --- A crop of this size requires significant logistics to transport produce, soil, fertilizer, and so on. The Elves are very busy pushing things around in carts on some kind of rudimentary system of tracks they've come up w...
9e212907e1c525fc1bc1ae0fec938e50dad02ac7
jvano74/advent_of_code
/2019/day_05_test.py
13,527
3.953125
4
import pytest from typing import List class Puzzle: """ --- Day 5: Sunny with a Chance of Asteroids --- You're starting to sweat as the ship makes its way toward Mercury. The Elves suggest that you get the air conditioner working by upgrading your ship computer to support the Thermal Environment Super...
63e9319fbce60cfec3ce6606aa8b9969b5e68d13
jvano74/advent_of_code
/2015/day_11_test.py
3,667
4.21875
4
import re def new_password(pwd): """ --- Day 11: Corporate Policy --- Santa's previous password expired, and he needs help choosing a new one. To help him remember his new password after the old one expires, Santa has devised a method of coming up with a password based on the previous one. Corpor...
42b7050430419a715dc0091175975d929709c83b
jvano74/advent_of_code
/2019/day_20_test.py
15,353
4.09375
4
from typing import Set, Dict, List, NamedTuple from collections import deque, defaultdict class Puzzle: """ --- Day 20: Donut Maze --- You notice a strange pattern on the surface of Pluto and land nearby to get a closer look. Upon closer inspection, you realize you've come across one of the famous spa...
617d9049e16911c42ae49610f4c61a24fc045eb8
jvano74/advent_of_code
/2021/day_25_test.py
10,150
4
4
from typing import NamedTuple class Puzzle: """ --- Day 25: Sea Cucumber --- This is it: the bottom of the ocean trench, the last place the sleigh keys could be. Your submarine's experimental antenna still isn't boosted enough to detect the keys, but they must be here. All you need to do is reach...
7c3476b4ff2b1b25c2fa797ab8dd45713736aec7
jvano74/advent_of_code
/2019/day_10_test.py
10,979
3.875
4
from numpy import sin, cos, pi, arctan2 from collections import defaultdict from typing import List class Puzzle: """ --- Day 10: Monitoring Station --- You fly into the asteroid belt and reach the Ceres monitoring station. The Elves here have an emergency: they're having trouble tracking all of the a...
febffbadb732ad0709cdba7239a369cb03565e71
jvano74/advent_of_code
/2018/day_15_test.py
23,610
4.09375
4
from typing import NamedTuple from queue import PriorityQueue class Puzzle: """ --- Day 15: Beverage Bandits --- Having perfected their hot chocolate, the Elves have a new problem: the Goblins that live in these caves will do anything to steal it. Looks like they're here for a fight. You scan the...
df3bb88e5a4f240e8841920633f762bcb39f9212
jvano74/advent_of_code
/2022/day_07_test.py
9,057
4.0625
4
from typing import NamedTuple class Puzzle: """ --- Day 7: No Space Left On Device --- You can hear birds chirping and raindrops hitting leaves as the expedition proceeds. Occasionally, you can even hear much louder sounds in the distance; how big do the animals get out here, anyway? The devi...
8b9635f49f3109aeae2c325d575c1f54a19fb712
jvano74/advent_of_code
/2015/day_09_test_alt.py
3,804
4.1875
4
from typing import List from collections import defaultdict from heapq import heappush, heappop class Puzzle: """ --- Day 9: All in a Single Night --- Every year, Santa manages to deliver all of his presents in a single night. This year, however, he has some new locations to visit; his elves have pro...
aaeba59e40e36ad997bf7f236122964186d6a022
tohkev/Data-Analytics
/Analyzing Data in Python/PyBank/main.py
1,898
3.703125
4
import os import csv path = os.path.join("Resources", "budget_data.csv") # Tracking various parameters used in calculations total_months = 0 total_profit = 0 change_total = 0 net_change_list = [] month_of_change_list = [] # reads csv file with financial data with open(path, "r") as datafile: reader = csv.reader(...
c6ace3025009418d4f7558034c4d9723055c8078
DaishanHuang/Canopy
/MITx6001/Lec4Problems.py
700
3.671875
4
def clip(lo, x, hi): ''' Takes in three numbers and returns a value based on the value of x. Returns: - lo, when x < lo - hi, when x > hi - x, otherwise ''' s = max(lo, x) return(min(s, hi)) def clip(lo, x, hi): return min(max(x, lo), hi) def square(x): return x*x d...
eeb051007e9b7363d36b3819e7e44a0e4aec3471
DaishanHuang/Canopy
/MITx6001/L3Problem5c.py
104
3.890625
4
end = int(raw_input('Enter an integer ')) y = 0 for x in range(end + 1): y = x + y print y
6c8cdb28620babdc883269c0a6a56a8d1b172d57
RoshaniPatel10994/ITCS1140---Python-
/Quiz's/quiz 4/quiz 4 before program/product in Main() function.py
781
3.875
4
# 3/9/2020 # Product # Multiply 2 number together using python fuctions # Define Main module def main(): # Declare variables x = 0.0 y = 0.0 Answer = 0.0 # Call GetInput function X, Y = GetInput() # Call CalProduct function Answer = CalcProduct(X, Y) # Calculate Di...
a69ae0606cc01d496905c9111bb1b5461db4b828
RoshaniPatel10994/ITCS1140---Python-
/Array/Lab.py
1,502
3.90625
4
# Patel Roshani # InClassLabLists # Def Main Module def main(): # Declare Variables NumHomes = 0 AvgPrice = 0.0 NumAbove = 0 NumBelow = 0 Prices = [0.0] # Call GetInput NumHomes, Prices = GetInput() #Call CalAvg AvgPrice = CalcAvg(NumHomes, Prices) # Call C...
1147eb7a1190460f976c5a5134c66f97410a836d
RoshaniPatel10994/ITCS1140---Python-
/Quiz's/quiz 4/Quiz 4 ans.py
825
3.828125
4
def main(): #define variables numorders = int() amt = int() coupon = str() #getinputs numorders = int(input("Enter number of orders: ")) amt = int(input("Enter total spent: ")) #call function CalcCoupon(numorders, amt) #define function def CalcCoupon(numorders, amt): #logic dete...
7b85a1c7233bec1ac0f6a7df5eba4eb82aa46d96
RoshaniPatel10994/ITCS1140---Python-
/Array/Practice/rainfall right ans.py
332
3.84375
4
days = int() def Rainfall(days): rain_log = float() rain_log = [] dayss=int(days) for I in range (0,dayss): rain_log.append(float(input())) return(rain_log) def main(): days = int() days = int(input()) myRain = [0.0] * days myRain = Rainfall(days) print(myRain...
db59ee60efb684c780262407c276487760cca73c
RoshaniPatel10994/ITCS1140---Python-
/Array/Practice/Beginin array in lecture.py
1,815
4.5
4
# Create a program that will allow the user to keep track of snowfall over the course 5 months. # The program will ask what the snowfall was for each week of each month ans produce a total number # of inches and average. It will also print out the snowfall values and list the highest amount of snow and the lowest amo...
78aa868973b7170d260593511b44ae410b9978be
RoshaniPatel10994/ITCS1140---Python-
/final exam/Final Exam.py
1,483
3.703125
4
#Define main def main(): #sales array from Professor SalesData=[2010.45,5500.00,1170.65, 550.25, 50.95,3650.45] #Print space print() #Call PrintSales sales = PrintSales(SalesData) print() #Find profit profit = DetermineProfits(SalesData) #Print space print() #...
09104914632843b275485f1258c2fa6399ba7339
RoshaniPatel10994/ITCS1140---Python-
/Loop Repetition structure And Decison Structure/num of cookies.py
853
3.953125
4
answer = str() num_cookies = int() rate = float() discount = float() subtotal = float() total = float() while answer != 'quit': num_cookies = int(input("Enter the number of cookies: ")) if num_cookies <= 6: rate = 0.0 elif num_cookies <= 12: rate = 0.5 elif num_coo...
c3869c3a16815c7934e88768d75ee77a4bcc207d
RoshaniPatel10994/ITCS1140---Python-
/Quiz's/quiz 5/LookingForDatesPython.py
1,479
4.40625
4
#Looking For Dates Program #Written by: Betsy Jenaway #Date: July 31, 2012 #This program will load an array of names and an array of dates. It will then #ask the user for a name. The program will then look for the user in the list. #If the name is found in the list the user will get a message telling them #...
c4a91a468b3c96852d1365870230b15433f8007c
RoshaniPatel10994/ITCS1140---Python-
/Quiz's/quiz 2/chips.py
989
4.15625
4
# Roshani Patel # 2/10/20 # Chips # This program Calculate the cost of an order of chips. # Display program that will ask user how many bags of chips they want to buy. #In addition ask the user what size of bag. #If the bag is 8 oz the cost is 1.29 dollar if the bag is 16 oz then the cost is 3.59 dollars. #If ...
dbcbd1dfe444464583ef6d6949c17588031b0cdc
Cluedrew/little-scribe
/scribbler/primitive.py
722
3.828125
4
#!/usr/bin/env python3 """Translating primitives into values. Primitives are not defined, but have an intrinsic value and type based on the tokens used.""" from base_types import ( IntegerType, ) from scope import ( Definition, ) from tokenization import ( IntegerToken, ) def primitive_integ...
0e27d9b7fdb232557d90760be79213e7fff55b9d
tijohask/Covering_Arrays
/Full_Hill_Climbing.py
4,416
3.5
4
import sys import numpy import random import itertools import time #Found on stack overflow def choose(n, k): """ A fast way to calculate binomial coefficients by Andrew Dalke (contrib). """ if 0 <= k <= n: ntok = 1 ktok = 1 for t in range(1, min(k, n - k) + 1): ntok *= n ktok *= t ...
8473efd6c1430d1b981a4f4e1c0ba742691c3572
DenzolRamen/Data-Structures-and-Algorithms
/Data Structures - Arrays/Reversing a string.py
1,309
3.875
4
# Reverse string 'Hi I am Denzel' # Solution 1 def reverse1(string): counter = len(string)-1 newStr = [] # Section for input checking.Start # Section for input checking.End while counter >= 0: newStr.append(string[counter]) counter -= 1 return ''.join(newStr) # Solution 2 def reverse2(st...
dcd86820d01321bad0912528a99a19eab34a72c7
gptjddldi/oembed_backend
/utils.py
2,514
3.671875
4
import requests import urllib3 import urllib def get_json(url): """ example url = https://www.youtube.com/watch?v=dBD54EZIrZo url 을 받아서 도메인 추출 https://www.youtube.com/ json file 에서 해당 도메인 이름있는 컬럼 확인 해당 칼럼의 schema 에 url 이 매칭되는 지 확인 url_name 추출 `{url_name}+format=json&url=url` 으로 request 요청,...
a95bdaa18d1b88eb8d178998f6af8f1066939c81
Lin-HsiaoJu/StanCode-Project
/stanCode Project/Wheather Master/weather_master.py
1,463
4.34375
4
""" File: weather_master.py Name: Jeffrey.Lin 2020/07 ----------------------- This program should implement a console program that asks weather data from user to compute the average, highest, lowest, cold days among the inputs. Output format should match what is shown in the sample run in the Assignment 2 Handout. """...
92e0031f054add61799cd4bfcd81a835e705af0d
ruthvika-mohan/python_scripts-
/merge_yearly_data.py
1,002
4.125
4
# Import required modules # Glob module finds all the pathnames matching a specified pattern # Pandas required to do merge operation # chdir() method in Python used to change the current working directory to specified path. from os import chdir from glob import glob import pandas as pdlib # Move to the path t...
8b5be8bebb6295fa681c58b73248d7bb8f92fb0f
aleenaadnan15/Class-work
/revise.py
527
3.671875
4
class student(): def __init__(self, name,age,rollno,gender): self.name = name self.age = age self.rollno = rollno self.gender = gender def print_details(self): print('name:',self.name,'age:',self.age, 'rollno:',self.rollno, 'gender:',self.gender) student1 = st...
eb43a005624bf51961a25f749f9b61ee8da7322b
christinapomykal/python-challenge
/PyBank/main.py
2,643
3.65625
4
# Import os and csv modules import os import csv csvpath = os.path.join("Resources", "budget_data.csv") # print(csvpath) # Lists to store data date = [] profitLoss = [] with open(csvpath) as csvfile: # CSV reader specifies delimiter and variable that holds contents csvreader = csv.reader(csvfile, delimiter=...
835f465eaa293f4d862f99d8e786394d31e78845
PierrotAWB/ProjectEuler
/Misc. Programs/permutator.py
589
3.6875
4
import math, time # permutation generator t = time.time() def createPermutation(numberList, permutationIndex): digit = [] k = len(numberList) # numberList = [i for i in xrange(1, n + 1)] # n numbers, 1 to n total = permutationIndex - 1 # "nth permutation" for i in xrange(k - 1, -1, -1): digit.append(number...
553f6b3c6cc172192dd935e4322ab478d01c34fd
quano2/MATLAB-to-Python-Translator
/node.py
6,376
3.59375
4
from functions import * def printVar(var): ''' Will return the printed version of var if it is a Node, otherwise will return var. :param var: :return: ''' if isinstance(var,Node): var = var.print() return var class Node: type = "NODE" def __init__(self,m ...
1e60b41b66e944478c8d207a96b7ee3d34c1e835
elionoula/PythonCalculatorHW
/src/Calculator.py
1,343
3.90625
4
def addition(a, b): a = float(a) b = float(b) return a + b def subtraction(a, b): a = float(a) b = float(b) return a - b def multiplication(a, b): a = float(a) b = float(b) return a * b def division(a, b, c): a = float(a) b = float(b) if (b == 0): return Non...
51d5ae57627ed7795ab41bd809f776e702a33920
yseakshay77/Udacity-data-structures-and-algorithms-nanodegree
/Assignment 3/Problem 2.py
2,229
3.78125
4
def Search(arr, key): n = len(arr) pivot = pivotFind(arr, 0, n - 1); if pivot == -1: return binarySearch(arr, 0, n - 1, key); if arr[pivot] == key: return pivot if arr[0] <= key: return binarySearch(arr, 0, pivot - 1, key); return binarySearch(arr, pivot + 1, n - 1, key)...
b3db986e17b830ef3d69cc2c93eb18de20b5ce0f
likebe/TurtleRace
/TurtleRace/Card.py
5,045
3.6875
4
# Liwei Jiang, Yin Li, Kebing Li # CS269 JP17 # Computer Game Design # Card.py # Jan. 15th 2017 import pygame class Card: def __init__(self, screen, type = 0, image = "card1.png" ): self.type = type self.tag = None self.step = 0 self.category = 0 self.image = image self.image2 = "card.png" self.bigIma...
ff485ccb47b4acd337c0996ed69e407858a06460
hilarymelroy/Ai_Labs_intern
/Ai_DS_intern_assessment_top_genres.py
1,007
3.890625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 20 18:05:58 2018 @author: hrm1886 """ import pandas as pd from collections import Counter ''' This function saves movie data in a pandas dataframe and creates a dictionary with genres as keys and frequency of occurances of genres as values. It outputs the top 5 genres ...
0587f599b6c6a488ae85f35ef57726dd76154768
diego-coder/golf_maintenance
/golf_maintenance.py
2,597
3.625
4
from math import pi from math import ceil from math import floor def calculate_rough_sod_area(length, width): rough_sod_area = ((length * width) - (calculate_smooth_sod_area(course_width) + calculate_sandtrap_area(course_width))) rough_sod_area_rounded_up = ceil(rough_sod_area) return rough_sod_area_roun...
88850cc9a63540a8a779968fb94d5f6a1915631a
wikimedia-research/floccus
/floccus/check.py
1,292
3.578125
4
import regexes import re """ A generic function for checking whether a regular expression matched a row. Returns True or False """ def generic_check(regex, row): if(re.search(regex, row)): return True return False """ Check whether a row returned zero results or not. """ def check_zero(row): return generic_...
9351659f89ade591fe87bba333d0310ac417e5c0
calumroy/tf_htm
/src/conv2d_tf.py
3,109
3.96875
4
import tensorflow as tf # This shows an example of using the convolve 2d tensorflow function and how to pad the input # and adjust the kernel ''' paddings is an integer tensor with shape [n, 2], where n is the rank of tensor. For each dimension D of input, paddings[D, 0] indicates how many values to add before the co...
99f9cdc93c69fcd8beac52d0d16ecd7faccd69c7
fontes99/pvf-language
/Classes/Tokenizer.py
4,450
3.53125
4
from .Token import Token class Tokenizer: def __init__(self, origin, position, actual): self.origin = origin self.position = position self.actual = actual self.balance_paren = 0 self.balance_brace = 0 self.builtIns = ["printo", "reado", "ifo", "whilo", "elso", "retu...
a9b38b6888c9e6dc623a6d61bb6d22736623c077
TopperTips/PySpark-By-Example
/rearrange-column-in-dataframe.py
1,267
3.5625
4
#toppertips.com #http://toppertips.com/pyspark-data-frame-rearrange-columns #import necessary files from pyspark.sql.types import StructType, StructField, IntegerType, StringType tips_list = [[1,"item 1" , 2], [2 ,"item 2", 3], [1 ,"item 3" ,2], [3 ,"item 4" , 5]] tips_schema = StructType( [StructField("Item_ID",Int...
65b63c669f8ea96182c3a662a968142803040192
AianaG/Codewars
/Simple maze.py
2,605
3.578125
4
def has_exit(maze): check_mutliple_kate = sum([a.count('k') for a in maze]) if check_mutliple_kate != 1: raise Error kate_position = find_original_position(maze) reached_edge = check_if_on_edge(maze, kate_position[0], kate_position[1]) possible_way_outs = way_outs(maze, kate_position...
a2a27c35261880040b4014ae6a0fee5992a5937f
AianaG/Codewars
/Valid Spacing.py
256
3.78125
4
def valid_spacing(s): print(s) count_space = list(s).count(' ') count_words = len([a for a in s.split(' ') if a != '']) if s == '': return True elif count_space > count_words-1: return False else: return True
a5be29fe097f3794dd5ddc4bc5f99f49f7ed2815
buckleypj84/Data-Files-and-Reports
/Checkup.py
277
4.0625
4
#Check up print("Hello User!") ans = input("What is your name? ") print(f"hi {ans}!") print("Hi " + ans + "!") age = input("what is your age? ") if (int(age) < 8): print("Aww! you are just a baby!") if (int(age) >= 8): print("ah...a well traveled soul are ye!")
75325fc8ed1e39c7171e1018a343208be713cc6a
Int-TRUE/2021knupython
/2. variables+datatypes/number_datatypes.py
443
3.6875
4
# 숫자 자료형 # 정수형 a = 154 print(type(a)) a = 0 print(type(a)) a=-25 print(type(a)) # 실수형 b = 181.34 print(type(b)) b = -22.22 print(type(b)) # 복소수형 - 'complex' c = 1 + 4j print(type(c)) print(c.real) # 실수부 print(c.imag) # 허수부 print(c.conjugate()) print(abs(c)) # 루트(1 + 4*4 = 17) = 4.12XX # 예제 : 스스로 사칙연산을 활용해가며 확인해보자 a=...
9923aca618c6b67c988b6233e2bd6c50ef87c834
Leyka/Advent-2015
/day5/day5b.py
1,171
3.9375
4
def main(): with open('data.txt', 'r') as f: data = f.read() rows = data.split('\n') count = 0 for text in rows: if has_pair_twice(text) and has_sandwich_letters(text): count += 1 print(count) def has_pair_twice(text): """ It contai...
48f272b3b5c02aa5cf76427e0fc0dc85fa7e35f4
RafaelTosetto/Python_Exercices
/Modulo_2/Atividade04.py
492
3.984375
4
'''Return the input string, backward''' contrario = "" word1 = str(raw_input("Insira uma palavra: ")) ''' O tipo len eh igual a lengh, ou seja, comprimento. Logo a variavel contador recebe o tamanho da quantidade de letras da variavel word1''' contador = len(word1) while contador != 0: contrario += word1 [cont...
c5c91f7073894be5d58e17685749b19fc51f9cd5
pgallo725/IPCV-Camera-Calculator
/calculator.py
3,621
4.3125
4
"""Module for parsing and evaluating arithmetic expressions""" OPERATORS = ['+', '-', '*', '/'] def compute(symbols): """ Solve an arithmetical expression, given an array containing the digits and the operator :param symbols: an array of *strings* with the symbols (digits and operators) :return: tuple...
a7fc8315e51cf013a448c21fd401738350345fe5
mgranemann/Curso-Python-Fundamentos
/section5/activities/activity3.py
385
3.59375
4
# Atividade 3 - Criar arquivo novo - argumento 'a' # Crie uma funcao para salvar uma placa de veiculo # A funcao deve receber a placa por parametro # A funcao deverá armazenar em arquivo texto # cada placa deve ser armazenada em uma linha def estacionamento(placa): arquivo = open('placas.txt', 'a') arquivo.wri...
5390f60e16856cc705318e82421c907efc34f285
mgranemann/Curso-Python-Fundamentos
/section5/activities/activity10.py
1,077
3.59375
4
# Crie uma funcao para listar os instrumentos salvos na atividade anterior # A funcao deve converter cada linha em um dicionário, # A funcao deve tratar os caracteres de quebra de linha # Caso ocorra algum erro durante a leitura, a funcao deve exibir a mensagem de erro (Exception) def ler(): try: lista_in...
053215ffa980a71cf11572584ccf5dc25a6a0e0f
sermanzanedo/2fbigdataEOI
/encriptacion.py
2,095
3.828125
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 17 17:52:57 2016 @author: Sergio """ print "Este es un programa para encriptar frases. Consiste en indicar primero una frase a encriptar y luego dar dos valores numericos que sirvan para:" print "Primero alterar el orden de las palabras en la frase introducida" p...
d6c1dd48d0c1b6bdc9c5bd7ebd936b30201112e5
febikamBU/string-matching
/bmh.py
2,182
4.03125
4
from collections import defaultdict from sys import argv, exit from comparer import Comparer def precalc(pattern): """ Create the precalculation table: a dictionary of the number of characters after the last occurrence of a given character. This provides the number of characters to shift by in the cas...
a20404427609f97a1f6e841efe0674371a2e5fbd
yangcongtougg/interview-question
/tree/binary_tree.py
3,182
4
4
# _*_ coding: utf-8 _*_ # @Time :2018/3/13 12:33 # @Author :maxzhangcong # @Email :maxzhangcong@163.com """ *************模块文档注释************** 二叉树的实现 树节点的添加 """ class Node(object): """节点类""" def __init__(self, item): self.item = item self.lchild = None self.rchild...
cb861120122dc196b56827aaab8b8b7357088d99
MathKode/Decrypt
/test liste.py
158
3.578125
4
import io print(file.read()) file.close() i = True while i : mot = input('Mot : ') if mot in z : print('Non') else : print('Oui')
a6759b87027f5300ccc05b231ed20757e6237d31
JongSeokJang/Sogang_ConputingThinking
/t1.py
1,816
3.578125
4
def cal_kor_avg(students): kor_total=0 for i in students: kor_total+=students['kor'] return kor_total/len(students) def cal_eng_avg(students): kor_total=0 for i in students: eng_total+=students['eng'] return eng_total/len(students) def cal_mat_avg(students): mat_total=0 f...
e5f98ee519d4232018d9a4d9da50e31370f562dc
JongSeokJang/Sogang_ConputingThinking
/p10_2.py
267
3.984375
4
while(1): instr = input("input:") if( instr == "STOP"): print("Bye") break outstr = "" for c in instr: if c.islower(): outstr = outstr + c.upper() elif c.isupper(): outstr = outstr + c.lower() else: outstr = outstr + c print(outstr)
e1e2d2ec351944b25fd779eccf98fbf0e5c677c5
gkelty/Sorry
/boardButton.py
511
3.59375
4
import pygame #Invisible buttons behind the image of our board to add functionality TRANSPARENT = (0, 0, 0, 0) class BoardButton(): #Creates the object giving it a tile numberand a location from the list of pawn locations def __init__(self,tileNum,locationX,locationY): self.tileNum = str(tileNum) ...
40861069dd3ced07748ff731e7115d04a00a8d3f
gkelty/Sorry
/Pawn.py
995
3.625
4
import Image #Pawn class class Pawn: #Possible colors with there corresponding images colors = ['yellow', 'green', 'red', 'blue'] pawnImages = {'yellow': Image.getImage('images\sorryPawnYellow.png'), 'green': Image.getImage('images\sorryPawnGreen.png'), 'red': Image.getIm...
b4f49b1373a9b61f07be12559435764f62091d8e
Sonaiofficial/FizzBuzz-Solution-
/main.py
452
4.0625
4
#Write your code below this row 👇 #take i as a veriable and start from 0 i=0 # here we take the range for fizz buzz is 1-100 for numbers in range(1, 101): # we tart i from 1 and check if the i is divisble by 3 , 5 or both at a time ad the print statement derive as per the condition matched i += 1 if (i % 3==0 and ...
2964d50c7d834e0ac94f16de5ea497ebe9ed932d
dinulade101/ECE322Testing
/post_requests/post_req.py
1,117
3.578125
4
import sqlite3 class PostReq: def __init__(self, cursor): #assume cursor is already setup self.cursor = cursor def validate_location(self, loc_code): """ Checks if the location code is in the locations db :param loc_code: location code that we want to validate ...
a29e29d8f4e58d67a3d7cf38132b587cb8c27822
dinulade101/ECE322Testing
/command/cancelBookingCommand.py
2,224
4.3125
4
''' This file deals with all the commands to allow the user to cancel bookings. It will initially display all the user's bookings. Then the user will select the number of the booking displayed to cancel. The row of the booking in the db will be removed. The member who's booking was canceled will get an automated messag...
3e50850a1e24cc243739578057737517782f1df2
ThePavolC/An-Introduction-to-Interactive-Programming-in-Python
/Pong.py
5,363
3.75
4
# Implementation of classic arcade game Pong import simplegui import random # initialize globals - pos and vel encode vertical info for paddles WIDTH = 600 HEIGHT = 400 BALL_RADIUS = 20 PAD_WIDTH = 8 PAD_HEIGHT = 80 HALF_PAD_WIDTH = PAD_WIDTH / 2 HALF_PAD_HEIGHT = PAD_HEIGHT / 2 LEFT = False RIGHT = True ball_...
7d77f122017030431417902d4d298ddbf6953b90
soniabliss/Itunes
/hw1pr2.py
6,471
3.546875
4
# # hw1pr2 ~ CS181 spring 2021 # # # Name(s): Sonia Bliss # import requests import string import json import time # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # Problem 2 starter code # # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # # # # starting function:...