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
e887a71eac6cf9fa87425b7e4db9b86ee2bc71dc
minhazalam/py
/py_basic/variables.py
245
4
4
# This program shows the working of variables in python # variable declaration name = "Minhaz Alam" age = 22 height = 5.7 # print statements print(name) print(type(name)) print(type(age)) print(type(height)) print(int(height)) print(len(name))
328931edeb4128727316cc80b135935d06434f6a
minhazalam/py
/py dict fun and files/programs/csv_writing.py
713
4.1875
4
# ABOUT : This program deals with the writing of the .csv files using # python 3 code as shown olympians = [("John Aalberg", 31, "Cross Country Skiing"), ("Minna Maarit Aalto", 30, "Sailing"), ("Win Valdemar Aaltonen", 54, "Art Competitions"), ("Wakako Abe", 18, "Cycling"...
fcc0ab92404ec3998a1736613c598c37a128ac2f
minhazalam/py
/py_basic/data_type.py
464
3.90625
4
# This program shows the implementation of the data type in # python 3 language print( type ("Hey, Py3") ) # floating point number print(type(3.14)) # different types of string passing in the python 3 language # 1. Triple double quotes print(type("""I'm trying to learn python language specialization""")) # 2. Tri...
0d9b592c42a8269fac200ae17e3fe97a7071fd4c
minhazalam/py
/py dict fun and files/programs/tup_pack.py
435
3.984375
4
# About : This is the implementation of the tuple packing functionality # and its application in function return statement # define func and pass radius as param def circle_info(radius) : # calculate circumference circum = 2 * 3.14 * radius # calculate area of the circle area_cir = 3.14 * radius * rad...
b2677a1cee82e3f2a851f604804f276131f63d75
minhazalam/py
/class_inheritance/exceptions/try_exception.py
554
4.15625
4
# we'll see how this try and exception works in the python 3 programming language # syntax : # try: # <try clause code block> # except <ErrorType>: # <exception handler code block> # def square(num): # return num * num # # assertion testingg # assert square(3) == 9 # try and except block of statement a_...
488ce6fdedfc22bf06ed51069a86e61d8007c2d4
Toranian/Data-Structures-In-Python
/node.py
1,886
3.734375
4
from typing import NewType, Optional, Generic, TypeVar T = TypeVar('T') class Node: ''' Class that holds a value and points to another Node class. Parameters: value (Generic[T]) : The value of the Node next ('Node') : The next Node to point to ''' def __in...
e651f5d49fb105171120512c6bd84a3881f3a332
jgoodell/Django-Board-Game
/pytic/pytic/core/model.py
6,892
4
4
from random import randint class Move(object): '''Class representing a move on the tic tac toe board. ''' def __init__(self,player,x,y): self.player = player self.x = x self.y = y self._move = [self.player,self.x,self.y] def __getitem__(self,index): return self...
b5bb951fbf60a2be483aa608baaa635c77943f5b
jorgelrt/python-digitalone
/Aula4B.py
184
3.875
4
x = 0 while x <= 10: print('a = {}'.format(x)) x += 1 y = 0 while y <= 10: y += 1 print('y = {}'.format(y)) #o ultimo é 0 11, pois incrementa primeiro e depois printa
bd670f5a6c28f467a8b245cc91080961eec9590b
andrewruban/Programming
/Python/Practice/stock_margin_calc.py
662
4.0625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Margin stock calculator. author: Andrey Ruban website: how2.pp.ua last modified: Sep 2018 Every programm should has: 1 Check input data before business logic 2 Exception termination 3 Data output """ try: amount = float(input("Enter amount of cc: ")) price_past ...
1a107032f19812f93df4ad21f6e39456ad8a81f5
lixingaaa/Python
/5.列表和元组/练习/test3.py
743
3.765625
4
# 模拟购物车购物过程 # 存放商品列表 list = [] for i in range(5): product = input("请输入商品编号和名称进行商品入库, 每次只能输入一件商品: \n") list.append(product) # 输出所有入库商品 for item in list: print(item) # 存放购物车的商品信息 cat = [] buyProduct = "" print("请输入要购买的商品编号: ") for item in list: productNumber = input("") if item.find(productNumber) =...
fdeaa90951a4d691c3155753f3278037ba229169
lixingaaa/Python
/2.输入与输出/实战任务/lesson1.py
171
3.5
4
# 键盘输入相应字母,数字或者符号,输出其ASCLL的状态中 value = input('请输入字母,数字或者符号: ') print('ASCLL值为:%d' % (ord(value)))
1cd7eaacbfbe7da91b9139f4989caeda8165c728
svetakrasikova/domestic_violence_project
/sveta-bsoup-example.py
2,961
3.765625
4
# a simple test of parsing reddit documents with Python... # first, some libraries: from bs4 import BeautifulSoup import requests # then, what page are we getting? Here's an arbitrary post, but this # would probably be iterating over a list of links or something. url = 'https://www.reddit.com/r/emotionalabuse/commen...
eff579a5e13bd543666069b222ade3a0d386ba8c
XanderCalvert/learning_python
/bmielse.py
502
4.375
4
height = float(input("enter your height in m: ")) weight = float(input("enter your weight in kg: ")) _bmi = weight / (height * height) bmi = round(_bmi, 1) if bmi <= 18.5: print(f"Your BMI is {bmi} you are underweight") elif bmi <= 25: print(f"Your BMI is {bmi} you are a normal weight") elif bmi <= 30: ...
ab3ff10764d5607a3e2c29f08fd68081fba6de74
radhanathdas/shatter
/shatter/machine_learning/labeled_data.py
2,137
3.5
4
#!/usr/bin/env python """ Defines classes and methods to package data for machine learning. """ import pandas as pd from shatter.util.code_dict import CodeDict __author__ = 'juan pablo isaza' class LabeledData: """ Suitable for Supervised Machine learning problem. """ def __init__(self, x, y): ...
9ddbf17684ac6737544bb2c091645855a9eab046
MadmanSilver/holbertonschool-interview
/0x10-rain/0-rain.py
683
3.6875
4
#!/usr/bin/python3 """ Contains rain method. """ def rain(walls): """ Calculates how much water is retained. """ total = 0 left = -1 right = -1 for i in range(len(walls)): if left == -1 and walls[i] > 0: left = i elif left != -1 and walls[i] >= walls[left]: ...
93d512ce16d15a0afe2c55a088e622c6c52b9858
ZYFM/PythonLearn
/excel_xlrd.py
672
3.671875
4
# coding:utf8 import xlrd def read_excel(): #open workbook book = xlrd.open_workbook('text.xlsx') #get all sheet name print(book.sheet_names()) #sheet context table = book.sheet_by_name('Sheet1') #table = book.sheet_by_index(0) #nrows is the number of rows, row_values is row's va...
117988ee999bf425f9485aa8b0b45ef521ced609
matgd/Advent-of-Code-2018
/day_2/advent_2018y_2d_part2.py
694
3.6875
4
line_chars_sets_map = {} def day_2_part_2(): with open('input.txt') as file: for line in file: unique_chars_line_set = set() for i in range(len(line)): unique_chars_line_set.add(str(i)+line[i]) line_chars_sets_map[line] = unique_chars_line_set map_va...
75596d144fdfcdbf9a8ca7d83228f12ba796d2b5
Fabian648/Python
/Schaltjahre.py
225
3.78125
4
def leap_year(y): years = [] for i in range(y): if i % 4 == 0: years.append(i) elif i % 100 == 0 and i % 400 == 0: years.append(i) print(years) leap_year(3000)
88ffd6690c0dbfb7a8ae9ece1330d4a11727dcd4
kartikeysingh1311/guvi
/leapyear.py
129
3.890625
4
x=int(input()) if x%100==0 and x%400!=0: print("not leap") elif x%4==0: print("leap") else: print("not leap")
f5056cb903b55b4279c42e28d3f662abad0fc99f
Robischafer/programming
/HT1_Q1_Q2.py
4,015
3.84375
4
### Programming ### Take Home Exam 1 import numpy import matplotlib.pyplot as plt import pandas import random from tabulate import tabulate ## Q1 # european call option payoff: max(0, S(T) - K), # T=maturity, S(T)=price at given date, K=strike price def OptionEval(S, K): """ return the pay...
6301ad14fee9fc2e76f407b11dc74531ae0b7967
crystalrlee/advent_of_code_2019
/day1/star2.py
462
3.609375
4
def main(): values = [] with open("fuel-amounts.txt") as file: mass = [int(line.strip()) for line in file.readlines()] for num in mass: fuel = (num//3)-2 values.append(fuel) fuel_for_fuel = fuel//3 - 2 # checks if fuel needs fuel while fuel_for_fuel > 0: ...
deeb0cf9be38a053afa72f86cf03bfd8ac04abe4
Michail73/SberLessions
/list.py
148
3.59375
4
#k=list(input('Put digits ')) k=['90', '45', '3', '43'] i=0 for i in range(0,len(k)): if i % 2 == 0: print(k[i], sep=' ', end=' ')
b483376c28f76fdc112b74b537701cb085818724
Michail73/SberLessions
/stairway.py
137
3.984375
4
n=int(input('Put length of stairway ')) for i in range(1, n+1): for j in range(1,i+1): print(j, sep='', end='') print()
460872822ea0a85e4eeac7f30e194d5814ad303d
mackrugeri/Python-Related_work-and-Project
/Python related task/other.py
5,516
4.125
4
from copy import deepcopy class Puzzle: def __init__(self,l,level=0,l_move=None): self.level=level self.board=l self.explored=False self.up=self.down=self.left=self.right=None self.l_move=l_move def path_finding(Puzzle): Path="" for value in Puzzl...
b5f049b8eb02dcbd3d7b30f3f221ea7571b14c78
eddycastillon/backend-s3-reto
/reto3/Level3.py
1,071
3.875
4
scores = [] def validate_value( score): try: val = int(score) except ValueError: print(f"Value {score} is not an int") return False return True def request_value ( iteration): name = input(f"[{iteration}]Enter student name\n") scores.append({"name": name}) scores[itera...
15e946b8c31097abf9f3cd12a2f396ef137ae05f
bschatzj/Algorithms
/knapsack/knapsack.py
877
3.8125
4
#!/usr/bin/python import sys from collections import namedtuple Item = namedtuple('Item', ['index', 'size', 'value']) def knapsack_solver(items, capacity): answer = [] efficiencies = [] for item in items: if item.size < capacity: efficiency = item.value / item.size efficiencies.append((efficien...
2b933d02da7a0b4df342f7328165a197da732baf
EricGao2015/leetcode-using-python
/easy/ReverseInteger.py
496
3.5
4
class Solution0(object): def reverse(self, x): str_x = str(x) if x<0: result = int(str_x[-1:0:-1])*-1 else: result = int(str_x[::-1]) return result*(result<2147483648 and result>=-2147483648) class Solution1(object): def reverse(self, x): result,flag = 0,1 if x<-1: x *= -1 flag = -1 while...
19b7ddb4adb18f61bbc01b29f3e030d8da0d24dd
EricGao2015/leetcode-using-python
/easy/NextGreatElement1.py
1,314
3.546875
4
class Solution(object): def nextGreaterElement0(self, findNums, nums): result = [] length_nums = len(nums) for n in findNums: start = nums.index(n) flag = False for i in range(start+1, length_nums): if nums[i]>n: result....
036802c1859c5dbc9922de3a6ad66fb2a5d6e4f8
EricGao2015/leetcode-using-python
/easy/BinaryTreePaths.py
849
4.03125
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def binaryTreePaths(self, root): if root: stack = [(root, str(root.val))] path = [] while stack: current,val = stack.pop() if (None,None...
352b2340e2aa52aa31e26acfd7ee6659d2ca5de1
EricGao2015/leetcode-using-python
/easy/RemoveNthNodeFromEndofList.py
731
3.84375
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def removeNthFromEnd(self, head, n): if head.next: Node1, Node2 = head, head for i in range(n): Node2 = Node2.next if not Node2: return head.next while N...
7458e57a5f21d5a7bd5fae55b348f027b9811778
EricGao2015/leetcode-using-python
/easy/MinimumDepthofBinaryTree.py
1,090
3.78125
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def minDepth0(self, root): #BSF if root: bsf_list = [(root, 1)] while bsf_list: for i in range(len(bsf_list)): current, depth = bsf_li...
57b011b86f05819bd39cc10e7aad9d7c88664ffe
ygqwan/py-tools
/time.py
2,339
3.578125
4
# -*- coding: cp936 -*- import re import os import sys class Day: """ һڵ """ def __init__(self): self.mouthDayRun = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] self.mouthDayPing = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] """ жǷΪ """ def judgeRun(self...
2e61f23e78905c918c5ae9b1edd9606de8cf8651
l3eamster/Data_Structure
/lab9/quick.py
1,331
3.890625
4
def quicksort(list, mode): global count if mode == 'low': pivotIndex = 0 elif mode == 'high': pivotIndex = len(list)-1 elif mode == 'mid': pivotIndex = (len(list)-1)//2 less =[] equal = [] greater = [] if len(list) - 1 > 0: pivot = list[pivot...
ca62a580325f42b14bd0efecefea5dabf707af60
Atousa-Niazi/OSLab-T3
/math-greatest-common-divisor--python/main.py
386
3.703125
4
#Atousa-Niazi-Abkoh-98440127-OSLab--t3-7 - Math-greatest common divisor -Python print('enter n1 , n2 :') n1=int(input()) n2=int(input()) min_n=min(n1,n2) i_old=0 for i in range(1,min_n+1): # range default is 0-n-1 so we will give it a start and stop point if n1%i==0 and n2%i==0: if i==max(i_old,i): ...
b9f0aed4126f5ebb538e95280833508a0ae1dcb0
JadeClarke/Exploring-Python
/MyFirstProgram.py
1,630
4.03125
4
#asks for name and desire to play game print("Hello! This is Jade's first independent Python program.") name = input("What's your name? ") print("\nNice to meet you, " + name.title() + "!") response = input("Would you like to play a guessing game? (y/n) ") while response.lower() != "y" and response.lower() != "n":...
55986d1bcb412fe0749ed40b09a2363d7edfc367
adam-worley/com404
/1-basics/6-mocktca/2-tca1/Q6.py
862
4.0625
4
def is_league_united(hero_1,hero_2): if(hero_1=="Superman" or hero_1=="Wonder Woman"): if(hero_2=="Superman" or hero_2=="Wonder Woman"): result=True else: result=False else: result=False return result def decide_plan(hero_1,hero_2): is_league_united(hero_1...
5131b6fcb9b0dd402cc8b5ac45515bf1c89c3122
adam-worley/com404
/1-basics/5-functions/8-function-calls/bot.py
1,331
3.796875
4
def box (word): x=len(word) print((x+4)*"-") print("|",word,"|") print((x+4)*"-") def lcase(word): print(word.lower()) def ucase(word): print(word.upper()) def mirror(word): x = len(word)-1 for count in range(x, -1, -1): print(word[count],end="") def repeat(word): print("...
8c44c1692f9091b3290f50c23ee3529888b606db
adam-worley/com404
/1-basics/5-functions/4-loop/bot.py
271
4.125
4
def cross_bridge (steps): x = 0 while (steps>0): print("Crossed step") steps = (steps-1) x = x+1 if (x>=5): print("The bridge is collapsing!") else: print("we must keep going") cross_bridge(3) cross_bridge(6)
0a7343306387e4f6c326a8bec187da13dc2c45ed
adam-worley/com404
/1-basics/6-mocktca/1-minimumtca/Q2.py
255
4.125
4
print("Where is Forky?") forky_location=str(input()) if (forky_location=="With Bonnie"): print("Phew! Bonnie will be happy.") elif(forky_location=="Running away"): print ("Oh no! Bonnie will be upset!") else: print("Ah! I better look for him")
a091889aaabc44bb5f7bf8cbfcf5225d4bceb4a2
adam-worley/com404
/1-basics/5-functions/5-multiple-parameters/bot.py
193
3.59375
4
def climb_ladder (steps_left,steps_crossed): if(steps_left>steps_crossed): print("still some way to go!") else: print("we made it!") climb_ladder(5,2) climb_ladder(5,5)
637abb15832ba8ebafa8e90d958df4ea05d3b236
keshavkummari/KT_PYTHON_6AM_June19
/Functions/Overview_Of_Functions.py
1,347
4.25
4
# Functions in Python # 1. def # 2. Function Name # 3. Open & Close Paranthesis and Parameters # 4. Colon : Suit # 5. Indented # 6. return statement - Exits a Function """ def function_name(parameters): function_suite return [expression] def sum(var1,var2): total = var1 + var2 print(total) retu...
ec48cabfa032093f6b670560ae4a4f19189d6bde
keshavkummari/KT_PYTHON_6AM_June19
/OOPS/Class.py
218
3.765625
4
class exClass: eyes = "Brown" age = "30" def echoName(self): print(self.eyes) print(self.age) return "Hello" exObject = exClass() exObject.eyes exObject.age exObject.echoName()
1c44a87590cf3b98bfe4ba91f8164aa64c177f05
KKhushhalR2405/AlgoNOOB
/word break.py
466
3.984375
4
def word_break(input_string, partial, dictionary={}): if len(input_string) == 0: print(partial) return for i in range(0, len(input_string)): word = input_string[:i+1] if word in dictionary: partial.append(word) word_break(input_string[i+1:], partial, dict...
dddf3d40f623311ae4549763b952cfd37a8829ee
nocLyt/CIS700
/P1/P3/small-world.py
949
3.6875
4
import matplotlib.pyplot as plt import networkx as nx import numpy as np def get_para(): return 500, 16, 0.1 def degree_list(): dc = dict() # (degree, number of node) for u in g.nodes(): d = g.degree(u) dc[d] = dc.get(d, 0) + 1 degrees = dc.keys() num_nodes = dc.values() re...
978f9cbbc071171e85d9447f16b0c9078ac410e3
francisnardi/python_unicamp_201802
/lab06/lab06.py
4,575
3.515625
4
#!/usr/bin/env python # coding: utf-8 # # Tarefa de laboratório 06 # ### Campeonato de futebol # * Em um campeonato de futebol, todos os times inscritos se enfrentam duas vezes: uma em seu estádio e outra no estádio adversário. O principal elemento para classificação é a pontuação acumulada: cada time recebe três pon...
cfbba32a8f869a1f9afaba9381382611f70c789a
MompuPupu/ProjectEuler
/Problems 1 - 10/Problem 1.py
516
4.5
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. def determine_if_multiple_of_3_or_5(number): """Return whether the number is a multiple of 3 or 5. """ if number % 3 == 0 or n...
ffd4583fc2f7498e36d5f9bd8fa7162c08295439
MompuPupu/ProjectEuler
/Problems 1 - 10/Problem 4.py
1,154
4.34375
4
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers # is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. import math def check_for_palindrome(num): # loads the number into an array of characters digit_list...
8a87dbd472f93069fed84fc930fd74bc52401d54
teamappollojumpstart/MovieDB-Code
/RoughFiles/imdbtext.py
643
3.515625
4
import sys import string from urllib import urlopen from BeautifulSoup import BeautifulSoup try: with open('imdb.txt') as f: pass print "File (imdb.txt) already exists." except IOError as e: print "Generating new file (imdb.txt)." try: text = urlopen('imdb.htm').read() print "inside loop" ...
a58b1b187ca6c17d6275036fc5e0ae73d00dc02e
Lulistar/exercicios_obi
/luli_exercicio_um.py
168
3.6875
4
D = int (input()) if (D <= 800): print (1) elif (D > 800 and D <= 1400): print (2) elif (D > 1400 and D <= 2000): print (3) else: print (-1)
1fc15c2929280699d4b1fd006528252edc5ed7b0
lemoosy/GPS
/GPS v1.1/main.py
1,262
3.96875
4
paths = list() distances = list() matrix = [ [0, 4, 0, 0, 0, 0], [0, 0, 2, 2, 0, 0], [0, 2, 0, 0, 7, 0], [1, 2, 3, 0, 0, 0], [0, 0, 0, 0, 0, 2], [0, 0, 2, 0, 0, 0] ] def get_paths_between(departure, arrival, cities = list()): for city in r...
ce211a7908e9c9bf7c414d40b5c8e8e186de8258
giodavoli/fantacalcio-optimization
/webscraping_price_fanta.py
1,732
3.578125
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 23 15:52:46 2021 @author: giovanni.davoli """ import requests import lxml.html as lh import pandas as pd from bs4 import BeautifulSoup import csv url='https://www.fantacalcio-online.com/it/asta-fantacalcio-stima-prezzi' #Create a handle, page, to handle th...
1a6b96bc6f2f20447a9923bffcb20c383ca13cc3
Rawkcy/Project-Euler
/q10.py
556
3.953125
4
#!/usr/bin/python """ The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. # http://en.wikipedia.org/wiki/Prime_number#Number_of_prime_numbers_below_a_given_number """ import math def is_prime(num): divisor = 2 while divisor <= int(math.sqrt(num)): if num %...
ee164fea12b17eb34cf532481c77e93bd91a2313
nda11/CS0008-f2016
/ch5/ch5,ex3.py
1,064
4.375
4
# name : Nabil Alhassani # email : nda11@pitt.edu # date :septemper/11th # class : CS0008-f2016 # instructor : Max Novelli (man8@pitt.edu) # Description:Starting with Python, Chapter 2, # Notes: # any notes to the instructor and/or TA goes here # ...and now let's program with Python # exercise 3 # Many financial exper...
932092174b6f64bda58c31b36a1305bd11a3dd47
nda11/CS0008-f2016
/ch6/ch6.ex4.py
749
3.953125
4
# name : Nabil Alhassani # email : nda11@pitt.edu # date :septemper/11th # class : CS0008-f2016 # instructor : Max Novelli (man8@pitt.edu) # Description:Starting with Python, Chapter 2, # Notes: # any notes to the instructor and/or TA goes here # ...and now let's program with Python # exercise 4 # main function def m...
81d1b25c60fd7043a49fb43f2cb4c808c4d21a86
nda11/CS0008-f2016
/ch2.py/ch2-ex3 bis.py
442
4.25
4
# Exercise : ch2-ex3 #This program asks the user to enter the total square meters of land and calculates the number of #acres in the tract. #set one_acre value and one_acre= 4,046.8564224**2 one_square_meter= 0.000247105 #input square_meter square_meter=float(input('enter the total square meters:',)) # calculation th...
935e0d1a4a7f85d3aa7a44c03171faa99c491d6f
marcoahansen/Python-Estudos
/exercicios/semana3/fizz.py
210
4.125
4
def main(): numero= float(input("Digite um número para saber se é divisível por 3:")) resto3 = numero % 3 if(resto3 == 0): print("Fizz") else: print(int(numero)) main()
c036e0e051bc0a428f1f49c5d21308c775eef4c4
marcoahansen/Python-Estudos
/exercicios/semana4/fatorial2.py
111
3.921875
4
n = int(input("Digite o valor de n: ")) if n >= 0: fat = 1 for i in range(1, n+1): fat*=i print(fat)
a6cc5d1c4b10594c24756f551d1051fc59780635
dzmitrybakunovich/data-structures-and-algorithms
/threaded_binary_tree/threaded_binary_tree.py
5,880
3.9375
4
class TreeNode: def __init__(self, value, left=None, right=None, parent=None): self.value = value self.left = left self.right = right self.parent = parent self.rt = None def has_left_child(self): return self.left def has_right_child(self): return sel...
0476e6aee17c67beecd3c44a600ac80e10498dc4
vigge93-BTH-courses/DV1582-Programmering-fortsattningskurs
/Tentamen/Upg6.py
1,263
3.84375
4
class Library: """Library class.""" def __init__(self): """Initialize library.""" self._available = {} self._loaned = {} def to_dict(self): """Convert the book library to a dictionary.""" return { 'available': [book.to_dict for book in self._available], ...
0e8689f7c89ab48dfe97116f57e12613e6775412
vigge93-BTH-courses/DV1582-Programmering-fortsattningskurs
/Tentamen/Upg7.py
1,903
3.890625
4
from threading import Thread class Book: """Book class.""" def __init__(self, isbn): """Initialize book""" self._queue = Queue() self._isbn = isbn @property def isbn(self): """Return ISBN of book""" return self._isbn def get_from_waitlist(self): "...
6a3b96f554983c1345714fadcee6d9df31927491
vigge93-BTH-courses/DV1582-Programmering-fortsattningskurs
/p5_test/flappy_birb.py
892
3.546875
4
import p5 class Bird(): def __init__(self): self._x = 60 self._y = height/2 self._d = 40 self._v = 0 self._a = 1 self._is_dead = False def update(self): self._y += self._v self._v += self._a def draw(self): p5.fill(255) p...
f73202ffef55df8bcee6a70f2aefe81c58b46fab
MacSoares/FGA-IA2015
/NeuralGenMSEMod.py
5,267
4.09375
4
""" This code represents a set of functions to implement the toy problem for the Xor gate, it uses an Artificial Neural Network in which the parameters are set by a Genetic Algorithm, in this case, the weights are being set. This must be used with the interface, as it does not print any result on the screen and works ...
9887a1ed6960ab8dd7ed2e4928765f52944906e5
JoaoCostaIFG/MNUM
/firsttest/q2_2017.py
205
4
4
#!/usr/bin/env python3 r = float(input("R: ")) m = float(input("m: ")) def expr(x): return (x**m - r) / (m * x ** (m - 1)) iter = 23 x = 3 for i in range(0, iter): x = x - expr(x) print(x)
5d006642e98eb791aaffd63878373ab880f1c508
JoaoCostaIFG/MNUM
/secondtest/2017/3simpson.py
940
3.5
4
#!/usr/bin/env python3 # CHECKED # NOTE I suggest this tecnic to working on exercises where we only have a # table of values (instead of a function). Just rewrite the list for each step, # keeping only the values you need for that step. ft2 = [1.04, 0.37, 0.38, 1.49, 1.08, 0.13, 0.64, 0.84, 0.12] ft1 = [1.04, 0.38, 1...
a29dc22ed1abea1ccec62d84bfc20e2bd52e98ad
JoaoCostaIFG/MNUM
/my_tests/2019/up201806560-Joao-Costa-p5a.py
508
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # up201806560-Joao-Costa-p5a.py # we'll call dy/dt, z # so we get a new expression and # the given expression becomes: # dz/dt = A + t^2 + t * z A = 1.5 def dydt(t, y, z): return z def dzdt(t, y, z): return A + (t**2) + t * z # s t = 1 y = 0 z = 1 # y'0...
1f134715ca273a179634b7b5d9f96bb9c017a720
JoaoCostaIFG/MNUM
/exams/2015/4_2_picard_peano_1eq.py
389
3.921875
4
#!/usr/bin/env python3 from math import log, e def f(x): return (e**x) - (4 * (x * x)) def recorr(x): return 2 * log(2 * x) # only 1 iteration to calculate x = 1.1 print(x) x = recorr(x) print(x) # # (DON'T DO THIS, IT IS INCORRECT) # # Residue (how much is left to an equation for it to become an ident...
f0cef96d25892e261438ff813eb0ed5cf0712b53
JaimeyHolm/Programming
/Opdracht 9.1.py
324
3.65625
4
def sum(): total = 0 aantalKeer = 0 while True: nextInt = (input('next int: ')) if nextInt == '0': break else: total += int(nextInt) aantalKeer += 1 return aantalKeer, total x, y = sum() print('Er zijn', x, 'getallen ingevoerd, de som is:'...
83eebc13adf35abcb3a3eec583620b98393f9f6f
JaimeyHolm/Programming
/Opdracht 7.1.py
263
3.703125
4
def convert(tempC): tempF = tempC * 1.8 + 32 return tempF def table(): print ('°C \t \t °F') for i in range(-30, 41, 10): uitkomst = i * 1.8 + 32 print(uitkomst, '\t', float(i)) print(convert(25)) print('\n') print(table())
e8918b3973b395b64a6f30dfdd8ad0ddc110496b
JaimeyHolm/Programming
/Test 2.py
280
3.625
4
import datetime def tijd(): vandaag = datetime.datetime.today() s = vandaag.strftime("%H") s = int(s) if s < 12: return('Goedemorgen') elif s >= 12 and s < 18: return('Goedemiddag') elif s > 18: return('Goedenavond') print(tijd())
346b4bb13262aa7328c9ed991e9d608ccf2650da
Daiten/codecademy
/Strings/every_other_letter.py
528
3.796875
4
# Write your every_other_letter function here: def every_other_letter(word): counter = 2 new_word = "" for letter in word: if counter % 2 == 0: new_word += letter counter += 1 else: counter += 1 continue return new_word # Uncomment these...
c8b2b2d26966b0957d399072ca00f2dbbd97607a
rsingh25/CodeProblems
/p416.py
870
3.953125
4
# You are in an infinite 2D grid where you can move in any of the 8 directions: # (x,y) to # (x+1, y), # (x - 1, y), # (x, y+1), # (x, y-1), # (x-1, y-1), # (x+1,y+1), # (x-1,y+1), # (x+1,y-1) #You are given a sequence of points and the order in which you need to cover the points. Give the minim...
75e7200d930b484988ca8355a15139674f01fa77
treehouse-projects/5-skills-for-backend-developers
/setup.py
377
3.515625
4
import sqlite3 conn = sqlite3.connect('test.db') cursor = conn.cursor() cursor.execute('CREATE TABLE articles (title TEXT, content TEXT)') cursor.execute('INSERT INTO articles (title, content) VALUES ("First post...", "From my new blog app!")') cursor.execute('INSERT INTO articles (title, content) VALUES ("We got a pu...
1899f8ca67dd94ff8a8be8778b23d3eed218dd32
duplipensando/example-py
/lacos-de-repet_for.py
363
3.90625
4
""" for elemento in interável: faça algo #para cada 'elemento' dentro do 'iteravel': faça algo """ palavra = 'Python' """ for posição, letra in enumarate(palavra): print(posição, letra) """ frase = 'pao foi a feira'.split() for palavra in frase: if palavra =='pao': print('Eu...
05a2c2de19472f150d7dc78f4171f06b4d71c14d
ntrang086/sudoku_solver
/utils.py
2,062
3.875
4
"""Utility functions for solution.py""" # Encode rows, columns and boxes rows = "ABCDEFGHI" cols = "123456789" boxes = [r + c for r in rows for c in cols] # A list of assignments to be used for visualization assignments = [] def assign_value(values, box, value): """Record each assignment (in order) for later reco...
9b161d6dedc0a393c9055bcac661d2f2bf200b0f
Robin-Wujw/algorithm_study
/algorithm_python/al_003_cp.py
2,735
3.546875
4
#!/usr/bin/python3 import sys import math import time import random import matplotlib.pyplot as plt x1 = [] y1 = [] x2 = [] y2 = [] x3 = [] y3 = [] L = [] def random_List(Length): start=-500 end =+500 for i in range(Length): L.append({"x":random.randint(start,end),"y":random.randint(start,end)}) ...
60200e32b44fe087c724f146ea2a724971255a36
BohdanHamulets/hackerrank
/closures_decorators/name_directory.py
2,014
4.0625
4
#!/usr/bin/python # -*- coding: utf-8 -*- """Let's use decorators to build a name directory! You are given some information about people. Each person has a first name, last name, age and sex. Print their names in a specific format sorted by their age in ascending order i.e. the youngest person's name should be printed...
e9f935c3b3dbd22a36ee90a01fa5abd9442489f1
mnabu55/kickstart
/kickstart2020/round_d/RecordBreaker.py
2,229
3.75
4
''' Problem Isyana is given the number of visitors at her local theme park on N consecutive days. The number of visitors on the i-th day is Vi. A day is record breaking if it satisfies both of the following conditions: The number of visitors on the day is strictly larger than the number of visitors on each of the previ...
30131651996397e653976cbe338d86b054f79323
VB6Hobbyst7/Random-Projekte
/Python/Turtles/Kreuz.py
742
3.578125
4
import turtle, time turtle.ht() x = 150 c=0 def k1 (): #x = 150 turtle.goto(10,14) for i in range(4): turtle.left(90) turtle.forward(x) turtle.right(90) turtle.forward(x) turtle.right(90) turtle.forward(x) time.sleep(1) def k2 (): ...
34e91092ce59b011edd50ea826e6c055fe241fdf
VB6Hobbyst7/Random-Projekte
/Python/Notenberechner/NeueNote.py
421
3.609375
4
def funk (): fach = input("Das Fach deiner Note: ") note = input("Die Note: ") provgewicht = input("Die Gewichtung der Note in %: ") if len(provgewicht) <3: gewicht = "0"+provgewicht else: gewicht = provgewicht o1 = open (fach, "r") liste = (o1.read()) ...
fe797840e9ccbdf6b804dde2a1e097728d461923
VB6Hobbyst7/Random-Projekte
/Python/Turtles/lerlern.py
426
3.5
4
from turtle import * speed(0) a=360 for i in range(a*2): forward(i/360) left(a/360) pencolor(1,0,0) penup() goto(0,0) pendown() for i in range(a*2): forward(i/360) right(a/360) pencolor(0,1,0) penup() goto(0,0) pendown() for i in range(a*2): forward(-i/360) left(a/...
2f3cf52da18ad63dcd6a9cec6710b3b1b15f1e9f
Victor-Bonnin/git-tutorial-rattrapages
/guessing_game.py
1,300
4.375
4
#! /usr/bin/python3 # The random package is needed to choose a random number import random # Define the game in a function def guess_loop(): # This is the number the user will have to guess, chosen randomly in between 1 and 100 number_to_guess = random.randint(1, 100) name = input("Write your name:...
3759e1450a801809bb2b00bcbf17d8ab474054a4
nagalr/algo_practice
/src/main/Python/Sort/insertion_sort.py
565
4.15625
4
def insertion_sort(l): """ Insertion Sort Implementation. Time O(n^2) run. O(1) space complexity. :param l: List :return: None, orders in place. """ # finds the next item to insert for i in range(1, len(l)): if l[i] < l[i - 1]: item = l[i] # moves the...
61a12fd0be2eddb48ac58db7ef7e80911ab6e7e9
valeriacavalcanti/ALP-2020-R
/Bimestre_02_Aula_02/atividade_individual/questao03.py
508
3.859375
4
qt_sorv = int(input('Sorvete: ')) qt_suco = int(input('Suco: ')) qt_past = int(input('Pastel: ')) qt_brig = int(input('Brigadeiro: ')) total = qt_sorv * 2.5 total += qt_suco * 3 total += qt_past * 10.5 total += qt_brig * 4 # mais duas formas de obter o total # total = qt_sorv * 2.5 + qt_suco * 3 + qt_past * 10.5 + q...
89504a7ac3e6a5015924dc9f954813554095349c
valeriacavalcanti/ALP-2020-R
/Bimestre_03_Aula_02/exercicios/03_frequencia.py
201
3.5625
4
meses = [0] * 12 for i in range(10): dia = int(input('Dia: ')) mes = int(input('Mês: ')) ano = int(input('Ano: ')) meses[mes - 1] += 1 for i in range(12): print(i + 1, meses[i])
6855767600a908cc10b29ebbc043995d45c74d75
valeriacavalcanti/ALP-2020-R
/Bimestre_03_Aula_04/avaliacao/03_estatisticas.py
782
3.78125
4
numeros = [] soma = qtde_acima = qtde_ultimo = 0 # leitura dos valores e soma for i in range(10): numeros.append(int(input('Número: '))) soma += numeros[i] # cálculo da média media = soma/10 # descobrir os valores acima da média for i in range(10): if (numeros[i] > media): qtde_acima += 1 # desc...
56fa3fc21b5ba31732a8f7ec72a196383c886f8d
valeriacavalcanti/ALP-2020-R
/Bimestre_02_Aula_04/atividade_individual/questao3.py
219
3.6875
4
qtde = 0 for i in range(10): print(f"Produto: {i + 1}") antes = float(input("Valor antes: ")) depois = float(input("Valor depois: ")) if (depois < antes): qtde += 1 print("Quantidade =", qtde)
0bac6abd792bc04f9a86413a0b61387047a5f05e
valeriacavalcanti/ALP-2020-R
/Bimestre_03_Aula_01/exemplo_if_2.py
473
3.828125
4
''' obter o valor de uma compra valor <= 100 : 2 parcelas valor > 100 e valor <= 200 : 4 parcelas acima 200: 6 parcelas ''' valor = float(input("Valor: ")) if (valor <= 100): print('2 parcelas') else: # certeza: valor > 100 if (valor <= 200): print('4 parcelas') else: # certeza: valor ...
1ef862f91644cbf3a2cf818636621d3b57b4f533
valeriacavalcanti/ALP-2020-R
/Bimestre_02_Aula_04/aula/exemplo3.py
274
3.90625
4
soma = 0 for i in range(10): numero = int(input(f"Informe o {i + 1}º valor: ")) #soma = soma + numero soma += numero print("A soma dos números é", soma) print(f"A soma dos números é {soma}") #interpolação print("A soma dos números é {}".format(soma))
bdea2cf4080076cf60d59123221949c6d7096180
valeriacavalcanti/ALP-2020-R
/Bimestre_04_Aula_01/exemplo_01.py
261
3.890625
4
palavra = input('Palavra: ') print(type(palavra), palavra) print(len(palavra)) for i in range(len(palavra)): print(palavra[i]) # ord: retorna o código decimal de um símbolo # chr: retorna o símbolo de um código decimal print(ord('A')) print(chr(65))
b56913994cb21aa034a29d71a920bc4a3208754e
valeriacavalcanti/ALP-2020-R
/Bimestre_03_Aula_01/exemplo_for_1.py
197
3.765625
4
for i in range(4): print(i) print('-----') for i in range(1, 4): print(i) print('-----') for i in range(1, 10, 2): print(i) print('-----') for i in range(10, 0, -1): print(i)
79727a130d7a29fb91b6404ef325292d54830704
valeriacavalcanti/ALP-2020-R
/Bimestre_04_Aula_01/exercicios/02_minusculos.py
131
3.890625
4
qtde = 0 frase = input('Frase: ') for s in frase: if (s >= 'a') and (s <= 'z'): qtde += 1 print('Quantidade:', qtde)
c268b2c6f0917df8bf832d787d3ab902c3d05485
actecautomacao/automatiza
/arquivofunc/principal.py
477
3.609375
4
from registrousuario import connect1 while True: operacao = int(input('Informe senha padrão (223) para processeguir: ')) try: if operacao != 223: print('Usuario Invalido!') elif operacao == 223: print('Inicio do processo!! ') print(operacao) ...
da36656d2fca63da8a68fbbb30e09e82f26c0f66
actecautomacao/automatiza
/produtos.py
424
3.609375
4
class Produtos: def __init__(self, codigo_produto = 'Sem código'): self._codigo_produto = codigo_produto def regist_produc(self): registro1 = str(input('Informe codigo produto: ')) self._codigo_produto = registro1 print(f'O codigo do produto informado foi: {self._codi...
cb4f70081a044c26437d01dec940883055ca937f
csmithsalzberg/Smith-Salzberg-Caleb_Lee-Vivien
/jobs.py
899
3.734375
4
#Caleb Smith-Salzberg, Vivien Lee #Team :) #Softdev1 pd7 #HW03 #2017-09-15 #initialize dictionary and read in csv file dict={} file = open('occupations.csv','r') ugly = file.read() lines = ugly.split("\n") import random #delete unnecessary lines from csv file del lines[0] del lines[len(lines)-1] del lines[len(lines)...
f062b21083eb11c033daf75e5d5c001375370e27
RxstydnR/Nematode_Wave_Prediction
/main/data_augmentation.py
6,008
3.578125
4
import numpy as np def data_augmentation_xy(x,y): """ Apply data augmentation to both Input wave X and output wave Y. This is an exteded version of 'Time Series Augmentation' (https://github.com/uchidalab/time_series_augmentation). Args: x (array): input wave y (array): output wave ...
d43b49567f9813917c070d451aba0638c15de1a9
DacksLab/RNAediting
/rediting/util/rmath.py
4,659
3.625
4
#!/usr/bin/env python """This module includes functions to calculate various metrics. This includes simple calculations such as mean, but also specific calcs for things like pearson correlation coefficient and polyT""" import math import collections import random from bisect import bisect import numpy as np from red...
4f9cbdf03d413bcb8a041f84e56aa825021480ed
DacksLab/RNAediting
/rediting/util/files.py
3,868
3.65625
4
#!/usr/bin/env python """This module contains functions pertaining to dealing with reading from, and writing to, files as well as organizing the resulting data from read files into usable data structures.""" def nonblank_lines(f): """read file lines, but skip blank lines""" for l in f: line = l.strip...
7c03fbe2ef45c0d4c50a9f2fc8ed7a585dec4151
Aperjump/Fluent_Python
/ch14/compare_iterators.py
164
3.90625
4
s = 'ABC' for char in s: print(char) it = iter(s) while True: try: print(next(it)) except StopIteration: del it break
aee55b11794cab330c7055c464051914b236b354
jgersain/web_scraping
/web_scraping.py
1,091
3.546875
4
import requests # parsear texto html y acceder a el como si fuera un arbol from bs4 import BeautifulSoup # perimite guardar las imagenes import urllib FAO = 'http://www.fao.org/economic/ess/ess-home/es' INDEXMUNDI = 'https://www.indexmundi.com/agriculture/?commodity=corn&graph=production' def run(): for i in rang...
3c2ef981967e0cc166a6274a50bcbb1d6434c6a1
py4/sudoku
/sudoku.py
1,793
3.640625
4
class Sudoku: def __init__(self, in_path): self.arr = [[0 for x in range(9)] for x in range(9)] with open(in_path) as f: for i,line in enumerate(f): for j,el in enumerate(line.split(' ')): self.arr[i][j] = int(el) def get_square(self, i, j): ...