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
fa690a54709d10df2953711b1da03eae5271c00c
Talon24229/txppythondocs
/Programs/lists_practice1.py
1,601
3.96875
4
#Talon Pauling #list practice 1 import random import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library GPIO.setwarnings(False) # Ignore warning for now GPIO.setmode(GPIO.BCM) # Use physical pin numbering #Us a module for requesting data online import requests #Us a module to control time import time #set up each pin...
d6b505873c599bbd5f579a099bee791be0d741d0
rupnarainP/python
/FlowControl.py
997
4
4
#if statements # name = input("Please enter your name ") # age = int(input("How old are you {0}? ".format(name))) # print(age) # # if age >= 18: # print("You're old enough to vote") # print("Please put an x in the box") # else: # print("Please come back in {0} years".format(18-age)) #######################...
ac0b9c7cbd00ba13b6f5409556cafaf60460ba96
Tabsdrisbidmamul/PythonBasic
/Chapter_9_classes/02 three_restaurant.py
1,260
4.40625
4
class Restaurant: """a simple to stimulate a restaurant""" def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): """will define what the restaurant is""" print(self.restauran...
514afedac18b94a9b99bdf233412b1c8655652b1
Tabsdrisbidmamul/PythonBasic
/Chapter_10_files_and_exceptions/05 programming_poll.py
305
4
4
# a program that will aks why you like programming filename = 'programming_poll.txt' while True: user_input = str(input('Why do you like programming? ')) with open(filename, 'a') as file_object: file_object.write('\n' + user_input + '\n') # essentially the program is just like the previous example
539d2bdefc2eb205879b7abe38455b801917d1e5
Tabsdrisbidmamul/PythonBasic
/Chapter_10_files_and_exceptions/13 Verify_user.py
1,295
3.9375
4
import json def get_stored_username(): """Get stored username if available""" filename = 'username.json' try: with open(filename) as f_obj: username = json.load(f_obj) except FileNotFoundError: return None else: return username def get_new_username(): """Prompt for a new username""" username = input...
b5bf1bc8f66cf5b2c4de55035fa8b6e60fc94fc3
Tabsdrisbidmamul/PythonBasic
/Chapter_8_functions/03 T_shirt.py
446
4
4
# make a function that will accept two parameters def make_shirt(size, text): """function to print a meesage on a t shirt and the size they want it in""" print('You wanted the t-shirt to be in size: ' + size) print('The message you wanted on the t-shirt: ' + text) # pass the arguments in positional form ma...
35d6f1f370cdf61b6bf1f496e08d0ea329d64995
Tabsdrisbidmamul/PythonBasic
/Chapter_8_functions/15 import_modules.py
301
4.1875
4
import math as maths # import maths module def area_of_a_circle(radius): """finds area of a circle, argument is radius""" area = round(pi * radius, 2) return area pi = maths.pi # call function, which will give me the area of a circle circle_0 = area_of_a_circle(50) print(circle_0)
9859d020429e26ca1ca363b211ddb10d0c66d411
Tabsdrisbidmamul/PythonBasic
/Chapter_5_if_statements/07 hello_admin.py
429
3.859375
4
usernames = [ 'admin', 'john', 'alice', 'sarah', 'phil'] # initialize a list of name for username in usernames: # run a for loop going though names if username == 'admin': # check to see if admin is list print('Hello Admin, would you like to see the status report?') else: # print regul...
c17a03c48b288270bf1bb671f8dca1fa6fbace24
Tabsdrisbidmamul/PythonBasic
/Chapter_10_files_and_exceptions/01 learning_python.py
766
4.34375
4
# variable to hold file name file = 'learning_python.txt' # use open function to open file, and print the contents three times with open(file) as file_object: content = file_object.read() print(content, '\n') print(content, '\n') print(content, '\n') print('indent\n') # open the file and read through each line a...
0ac565e0d4d3b948dcf0d8767039d6ccb2d9f71d
Tabsdrisbidmamul/PythonBasic
/Chapter_10_files_and_exceptions/04 guest_book.py
448
4.1875
4
# program that asks the user name, once entered print a prompt to say it was # accepted and append the string onto the file filename = 'programming.txt' while True: userName = str(input('What is your name? ')) print('Welcome ', userName) with open(filename, 'a') as file_object: # the \n is required, as the write...
0f33021c849d0d73cebee12027d46fbb4cdbbf92
Tabsdrisbidmamul/PythonBasic
/Chapter_11_testing_your_code/test_city_country.py
690
3.984375
4
""" Run tests to see if they fall within range, by using the 6 methods described in test_name_function.py """ from unittest import TestCase from city_functions import city_country class TestCity_country(TestCase): def test_city_country(self): """Do city's such as 'Santiago, Chile' work?""" formatted_cities = ci...
3c5b8e6838f2ebead83149f9e35c12f3c7a9b96c
Tabsdrisbidmamul/PythonBasic
/Chapter_7_user_inputs_and_while_loops/08 dream_vacation.py
819
4.28125
4
# set an empty dictionary to be filled up with polling later responses = {} # make a flag set to true polling_active = True while polling_active: # prompt for user's name and their destination name = input('\nWhat is your name: ') dream_vacation = input('What place is your dream vacation? ') # store ...
1a293280bfcd68858c01823f1dd9de0d4af62b13
Tabsdrisbidmamul/PythonBasic
/Chapter_11_testing_your_code/city_functions.py
331
3.9375
4
""" Simple function to neatly format the city, country and population """ def city_country(city, country, population=None): if population: formatted_city = "{0}, {1} - Population {2}".format(city, country, str(population)) else: formatted_city = "{0}, {1}".format(city, country) return formatted_cit...
24c95a3ab3e6b6e6a6cfa4ab1fbfc0f43dbf9409
GudjonGunnarsson/python-challenges
/codingbat/warmup1/9_not_string.py
884
4.40625
4
#!/usr/bin/python3 """ This challenge is as follows: Given a string, return a new string where "not" has been added to the front. However, if the string already begins with "not", return the string unchanged. Expected Results: 'candy' -> 'not candy' 'x' -> 'not x' 'n...
263750ea598586c75abd38753feee54d0fdad53c
IsaiahSama/period-tracker
/database.py
1,810
3.96875
4
# File which handles the functionality of the database from sqlite3 import connect, Connection class Database: """Class which holds all the operations regarding database usage.""" def __init__(self) -> None: self.connect() self.setup() def setup(self): """Function responsible for ...
868733a299e161f0d21d9013272a38b48dfeaa39
antongagagap/-
/Lab №3/main.py
1,915
3.609375
4
import random alphabet = 'abcdefghiklmnopqrstuvwxyz' def read_file(): text = '' with open('text.txt', 'r', encoding='utf8') as f: text = ''.join([line for line in f]).lower() text = text.replace('j', 'i') return text text = read_file() def generate_matrix(): alphabet_indexes = list(ra...
98680d787a61e32856c850b5384ab61d619d0358
pdcook/ParallelComputingLecture
/example4.py
387
3.609375
4
#!/usr/bin/env python3 import threading import time def function(i): print("Thread %d is active." %i) time.sleep(i/2) print("Thread %d is done." %i) threads=[] for i in range(1,9): t = threading.Thread( target = function, args=[i]) threads.append(t) t.start() print("All threads have started....
598438f382764573bf048d5e788654d1a721f9c4
JarrodDoyle/Shattered-Strongholds
/cells.py
1,221
3.84375
4
class Cell: """ Base cell class inherited by all cell types """ def __init__(self, cell_name, char, bk_color = "dark gray", color = "white", is_blocked = True, blocks_sight = True): self.cell_name = cell_name self.char = char self.bk_color = bk_color self.color = ...
99984c421b10232209ebc71a64ef4d02c51ef25e
JarrodDoyle/Shattered-Strongholds
/map_generation/mazes_and_rooms.py
10,558
3.59375
4
from map_generation.dungeon_base import Dungeon from rect import Rect from kruskals import Kruskals_Algorithm import random, cells class Dungeon_Mazes_And_Rooms(Dungeon): """ Class used to generate rooms and mazes dungeon variant, inherits from Dungeon """ def __init__(self, width, height): """...
915deca3aed8bb835c8d915589a91e5f02cf3f49
DocAce/Euphemia
/dicey.py
2,108
4.1875
4
from random import randint def roll_die(sides): return randint(1, sides) def flip_coin(): if randint(0, 1) == 0: return 'Heads' else: return 'Tails' def generate_coin_flip_output(args): numflips = 1 # just use the first number we find as the number of coins to flip for arg in ...
c140b20943ce2144bd87a51b740a22de36593301
AdoenLunnae/AoC-2020
/day1/day1.py
794
3.765625
4
from sys import stderr def read_file(filename): with open(filename, 'r') as f: raw_text = f.readlines() return [line.strip() for line in raw_text] def silver(input_data): for n1 in input_data: if (n2 := 2020 - n1) in input_data: return(n1*n2) def gold(input_data): for n1 ...
443e11199c51f081558531cdb117f242f6f00474
Abhilash1792/AI55
/ai5.py
3,751
3.90625
4
#!/usr/bin/env python # coding: utf-8 # # Best First Search # In[10]: from queue import PriorityQueue v = 14 graph = [[] for i in range(v)] def best_first_search(source, target, n): visited = [0] * n pq = PriorityQueue() pq.put((0, source)) while pq.empty() == False: u = pq.get()[1] ...
9b500120160a2ebbe282b1d83a39e4d527c120f6
xy-241/dataStructure-Algorithm
/BigONotation/linearTime.py
175
3.84375
4
n = int(input("The n value: ")) i = 0 j = 0 # Example 1 while i < n: i += 1 # f(n) = n, O(f(n)) = O(n) # Example 2 while j < n: j += 3 # f(n) = n/3 , O(f(n)) = O(n)
6d85eea922073b53217332e37725574e39234b66
brunoorlandin/CS3121
/projeto.py
7,240
3.828125
4
import os import math def sep(): print("\n===========================================\n") def classificaOnda(c): while True: op = int(input("Entre com: \n1 - Numero de onda\n2 - Frequencia angular\nEscolha: ")) if op == 1: no = float(input("Numero de onda (em rad/m): ")) ...
3883899fdfb8840028d3cf78828e8b7905ea7755
SHREYAS180298/python-sequence-pair
/seqpair.py
3,567
3.609375
4
import numpy as np n=int(input("Enter the number of modules:\n")) ##print("Enter the width and height of each module in WxH format in order:\n") ##for i in range(1,n+1): ## print("Module :",i) ## a,b=input().split('x') ## w.append(a) ## h.append(b) w_h=[[]*2]*n w=[] h=[] right=[] left=[] above=[] below=[] ...
e1456f7bfe3005e9ca6e5935eaf1be2caaf0109b
Ascarik/PythonLabs
/Ch05/Lab39.py
414
3.609375
4
percent = 0 baseSalary = 5000 salesAmount = 30000 result = salesAmount - baseSalary if result >= 0 and result <= 5000: percent = 8 elif result >= 5000.01 and result <= 10000: percent = 10 elif result >= 10000.01: percent = 12 result = result / (percent/100) # result = (salesAmount-baseSalary) * print("th...
ba1c9588eeb746dad415a0b3064a11bb06412660
Ascarik/PythonLabs
/Ch05/Lab21.py
470
3.734375
4
step = 1 for i in range(0, 8): count = 1 for q in range(0, 8): if q < 8 - step: print(" ", end="") else: # print(count, end=" ") print("{0:4}".format(count), end="") count *= 2 count //= 4 for t in range(0, 7): if count == 0...
e4c581b1ee18813cfd210118cf8e4df159218756
Ascarik/PythonLabs
/Ch08/Lab13.py
488
3.859375
4
def prefix(s1, s2): if len(s1) == 0 or len(s2) == 0: return result = "" index = 0 while True: if index == (len(s1) - 1) or index == (len(s2) - 1): break if s1[index] == s2[index]: result += s1[index] else: break index += 1 ...
1fd57ce49ddce42ff8a20017040507dbdb340130
Ascarik/PythonLabs
/Ch06/ShowCurrentTime.py
1,022
4.09375
4
import time def getCurrentTime(): currentTime = time.time() # Get current time currentTime # Obtain the total seconds since midnight, Jan 1, 1970 totalSeconds = int(currentTime) # Get the current second currentSecond = totalSeconds % 60 # Obtain the total minutes totalMinutes = totalSecon...
fc27b4861ef7c7fcd503acac082b04843a94c665
Ascarik/PythonLabs
/Ch06/Lab08.py
638
4.21875
4
# Converts from Celsius to Fahrenheit def celsiusToFahrenheit(celsius): return (9 / 5) * celsius + 32 # Converts from Fahrenheit to Celsius def fahrenheitToCelsius(fahrenheit): return (5 / 9) * (fahrenheit - 32) print( format("Celsius", "20s"), "Fahrenheit", " | ", format("Fahrenheit", "20s"), f...
20c51e96dfb934c7f16943c53037b25e9afebcac
Ascarik/PythonLabs
/Ch04/Lab37.py
672
3.890625
4
import turtle, random NUM = 200 x1, y1 = random.randint(-NUM, NUM), random.randint(-NUM, NUM) weight = random.randint(50, NUM * 2) height = random.randint(50, NUM * 2) x2 = x1 + weight y2 = y1 + height turtle.penup() turtle.goto(x1, y1) turtle.pendown() turtle.goto(x1 + weight, y1) turtle.goto(x1 + weight, y1 + heig...
e230e4eca6dcd6e4fb1b43bd2b8498cb902bf37b
Ascarik/PythonLabs
/Ch06/Lab36.py
637
3.828125
4
from random import randint # import randint # Generate a random character between ch1 and ch2 def getRandomCharacter(ch1, ch2): return chr(randint(ord(ch1), ord(ch2))) # Generate a random uppercase letter def getRandomUpperCaseLetter(): return getRandomCharacter('A', 'Z') def getRandomNumbers(): retu...
2fbfd883868ae994a0dd0b7b27fc3c4917b49b79
Ascarik/PythonLabs
/Ch05/Lab32.py
151
3.515625
4
amount = eval(input("Enter an amount: ")) sum = 0 pers = 5 / 100 / 6 for i in range(0, 6): sum = (amount + sum) * (1 + pers) print("sum =", sum)
bb055ce2658a2f285549a7464e81ccfe93944e72
Ascarik/PythonLabs
/Ch09/Lab20.py
951
3.765625
4
from tkinter import * class Lab20: def __init__(self): window = Tk() window.title("Lab20") self.canvas = Canvas(window, width=400, height=400) self.canvas.pack() self.x = 200 self.y = 200 self.radius = 100 self.canvas.create_oval(100,100,300,300) ...
f015c4a597d2f97ebf6da1f9650003f9fce3776a
Ascarik/PythonLabs
/Ch08/Lab19.py
3,317
3.6875
4
class Rectangle2D: def __init__(self, x=0.0, y=0.0, width=0.0, height=0.0): self.__x = x self.__y = y self.__width = width self.__height = height def get_x(self) -> float: return self.__x def get_y(self) -> float: return self.__x def get_width(self) -> ...
bf8658e4b7071fe103881dc4a8d620acbfe2da37
Ascarik/PythonLabs
/Ch04/Lab17.py
916
4
4
import random def getScissorRockPaper(my_num): if my_num == 0: name = "scissor" elif my_num == 1: name = "rock" else: name = "paper" return name my_num = int(input("scissor (0), rock (1), paper (2): ")) random_num = random.randint(0, 2) result = "The computer is {0}. You are...
d5e6fc5ce25fdca1fd3efadbcede7b1eed02825b
Ascarik/PythonLabs
/Ch06/Lab11.py
508
3.59375
4
def computeCommission(salesAmount): if salesAmount >= 0 and salesAmount <= 5000: percent = 8 elif salesAmount >= 5000.01 and salesAmount <= 10000: percent = 10 elif salesAmount >= 10000.01: percent = 12 return salesAmount * (percent / 100) print( format("Sales Amount", "20...
fba1bff558d888c863985d959e01c7e6ad42d1ef
Ascarik/PythonLabs
/Ch04/Lab35.py
913
3.765625
4
import turtle, random NUM = 200 x0, y0 = random.randint(-NUM, 0), random.randint(0, NUM) x1, y1 = random.randint(0, NUM), random.randint(-NUM, 0) x2, y2 = random.randint(-NUM, NUM), random.randint(-NUM, NUM) result = (x1 - x0) * (y2 - y0) - (x2 - x0) * (y1 - y0) if result < 0: result = "p2 is on the left side of...
6e0ddb0412a5f38c233d513c26492d9ddb5d2a1b
Ascarik/PythonLabs
/Ch04/Lab36.py
644
4.1875
4
import turtle, random NUM = 200 x1, y1 = 0, 0 radius = random.randint(50, NUM) x2, y2 = random.randint(-NUM, NUM), random.randint(-NUM, NUM) # Pull the pen down turtle.circle(radius) turtle.penup() turtle.goto(x2, y2) turtle.pendown() turtle.begin_fill() turtle.color("red") turtle.circle(3) turtle.end_fill() # Displ...
e6ebfbb74f789acd3ba52366a845bd610d245911
Ascarik/PythonLabs
/Ch04/Lab24.py
311
3.9375
4
import random suitArray = ["Clubs", "Diamonds", "Hearts", "Spades"] rankArray = ["Ace", "Jack", "Queen", "King"] rank = random.randint(2, 14) suit = random.randint(0, 3) if rank>10: rank = "the "+rankArray[rank-11]+" of" suit = suitArray[suit] print("The card you picked is {0} {1}".format(rank, suit))
7c3fb292bc55adc57215e07efa2f8e8e035a38fb
Ascarik/PythonLabs
/Ch06/Lab46.py
768
4.03125
4
import turtle def drawPolygon(x=0, y=0, radius=50): turtle.pensize(3) turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.circle(radius, steps=6) def drawTriangle(x, y, radius, degree): turtle.pensize(3) turtle.penup() turtle.goto(x, y) turtle.right(degree) turtle.pendow...
e4217b4334366b0ae16ecaf93e978c643797635f
Ascarik/PythonLabs
/Ch01/Lab8.py
129
3.71875
4
radius = 5.5 p = 3.14 area = radius * radius * p perimeter = 2 * radius * p print("Area:", area) print("Perimeter:", perimeter)
ce4db2b77fbe6ac0fa529c371c0c84140b6d4afa
Ascarik/PythonLabs
/Ch03/Lab6.py
73
3.90625
4
n = int(input("Enter an ASCII code: ")) print("The character is",chr(n))
0077af010119ae571ea74073e727116e552fd199
Ascarik/PythonLabs
/Ch02/Lab25.py
373
4
4
import turtle width = int(input("Enter width: ")) height = int(input("Enter height: ")) turtle.pensize(3) turtle.penup() turtle.goto(0, -(height / 2)) turtle.pendown() turtle.forward(width / 2) turtle.right(90) turtle.forward(height) turtle.right(90) turtle.forward(width) turtle.right(90) turtle.forward(height) turtl...
13bc4176b4732e9ff7d8ad217d83b1679895467f
Ascarik/PythonLabs
/Ch08/Lab07.py
672
3.9375
4
def getNumber(uppercaseLetter: str) -> str: number = "" uppercaseLetter = uppercaseLetter.upper() for i in range(len(uppercaseLetter)): if uppercaseLetter[i].isalpha() and "A" <= uppercaseLetter[i] <= "Z": symbol = ord(uppercaseLetter[i]) - ord("A") if uppercaseLetter[i] ...
cca51fe5c77d509353d849ffaeb9f9b5843b7df5
Ascarik/PythonLabs
/Ch06/Lab26.py
156
3.71875
4
def printMersenneNumners(number): for i in range(number): i += 1 print("{:>5} {:>20}".format(i, 2 ** i - 1)) printMersenneNumners(31)
597b45907e2e5dd8e49c9963e5411581fda40b91
Ascarik/PythonLabs
/Ch04/Lab9.py
254
3.765625
4
weight1, price1 = eval(input("Enter weight and price for package 1: ")) weight2, price2 = eval(input("Enter weight and price for package 2: ")) num = 1 if weight1 / price1 < weight2 / price2: num = 2 print("Package", num, "has the better price.")
20e520abaf6cb6cc3e007ddb9e5d266d38b60733
hosseink/Automated_poker_player
/pokereval-0.1.1/prob/code.py
1,126
3.578125
4
from pokereval.card import Card from pokereval.hand_evaluator import HandEvaluator import itertools import copy card1 = Card(14,1) card2 = Card(14,2) hole = [card1, card2] board = [] score = HandEvaluator.evaluate_hand(hole, board) cards = [] for i in range(2,15): for j in range(1,5): if (Card(i,j) == car...
2d2389b06f95882a52cc99f52e615cf3c318ffdf
vesteinnbjarna/Forritun_Vesteinn
/Hlutapróf 1 undirbúningur/Programming exercises/P20.py
167
4.09375
4
turns = int(input('How many integers do you want to enter: ')) countdown = 0 while countdown < turns: num = int(input('Enter a number: ')) countdown += 133
71adcc544a902e71d283a4ffefb069622b2a03c6
vesteinnbjarna/Forritun_Vesteinn
/Lestrarverkefni/Kafli 2/simple_while.py
251
4.15625
4
#simple while x_int = 0 #test loop-controled variable at the start while x_int < 10: print(x_int, end =' ') # print x_each time it loops x_int = x_int + 1 # changing x_int while in loop print () print ('Final value of x_int: ', x_int)
3cef1f194a10b0e2657e88e259833c03f1fa6627
vesteinnbjarna/Forritun_Vesteinn
/Lestrarverkefni/Kafli 5/number_position.py
278
4.09375
4
def get_digit(number, position): """Return digit in position in number counting from right""" return number // (10**position)%10 number = int(input("Enter a number: ")) position = int(input("Enter its position: ")) num_pos = get_digit(number, position) print(num_pos)
94a919169f98db4d533b7b186c3c2c4a49dc491c
vesteinnbjarna/Forritun_Vesteinn
/Lestrarverkefni/Kafli 5/celius_to_farenheit.py
347
4.1875
4
def celsius_to_farenheit(celsius_float): """ Convert Celsius to Fahrenheit. """ return celsius_float * 1.8 + 32 print("Convert Celsius to Fahrenheit.") celsius_float = float(input('Enter degrees in celsius:')) fahrenheit_float = celsius_to_farenheit (celsius_float) print(celsius_float," converts to ", fahre...
c34e5855f6a781a18bfb02ee809ce1b5c1ee25e6
vesteinnbjarna/Forritun_Vesteinn
/Hlutapróf 1 undirbúningur/Assingment 4/A4.1.py
76
3.90625
4
num = int(input('Enter a integer: ')) for i in range (1,num): print (i)
6dd4cd8ca29d2169ea4df8d24372d57e0132b47f
vesteinnbjarna/Forritun_Vesteinn
/Tímaverkefni/Assignment 12/Q2.py
466
3.875
4
# sort_list() function goes here def sort_list(a_list): a_list.sort() # get_list() function goes here def get_list (): a_list = [] number = input() while number.isdigit(): a_list.append(int(number)) number = input() return a_list ...
e5dbd401cbb63acdd259b185a02eeee98498734e
vesteinnbjarna/Forritun_Vesteinn
/Hlutapróf 2 undirbúningur/longest_word.py
682
4.40625
4
def open_file(filename): file_obj = open(filename, 'r') return file_obj def find_longest(file_object): '''Return the longest word and its length found in the given file''' max_length = 0 longest_word = "" for word in file_object: word = word.strip() length = len(word) ...
f3c08e778a40e3dfb2076d55a4135147f39a4f8a
vesteinnbjarna/Forritun_Vesteinn
/Tímaverkefni/Assignment 7/A7.6.py
345
4.09375
4
def fibo(n): n1 = 1 n2 = 1 count = 0 if n == 1: print (n1) else: while count < n: if n1 != 0: print (n1, end= ' ') fib = n1+n2 n1 = n2 n2 = fib count += 1 n = int(input("Input the length of Fibonacci sequ...
e9b16fba6e3a93f03f9e0b4950b9f3692f2a8cc8
vesteinnbjarna/Forritun_Vesteinn
/Tímaverkefni/Assignment 12/Q4.py
606
4.5
4
def merge_lists(first_list, second_list): a_new_list = [] for element in first_list: if element not in a_new_list: a_new_list.append(element) for element in second_list: if element not in a_new_list: a_new_list.append(element) a_new_list = sorted(a_new_li...
f526cc3f2914bcbf2d9c72966d472c92d36f3bd4
vesteinnbjarna/Forritun_Vesteinn
/Tímaverkefni/Assignment 4/A4.6.py
229
3.59375
4
top_num = int(input("Upper number for the range: ")) # Do not change this line perfect_num = 0 sum_num = 0 for i in range (1,top_num): if i % 2 == 0: sum_num += i if sum_num == i: print (i)
e0b0f0b3ec6cfe4adb826d78aadaf9496db112ad
vesteinnbjarna/Forritun_Vesteinn
/Tímaverkefni/Assignment 7/A7.5.py
699
4.1875
4
import string # palindrome function definition goes here def is_palindrom (imported_string): original_str = imported_string modified_str = original_str.lower() bad_chars = string.whitespace + string.punctuation for char in modified_str: if char in bad_chars: modified_str = modi...
086f5a21e7f96beaea63b02995bb5a870072075b
vesteinnbjarna/Forritun_Vesteinn
/Hlutapróf 1 undirbúningur/Programming exercises/P25.py
282
3.984375
4
low = int(input('Enter a lower number: ')) high = int(input('Enter a higher number: ')) counter = 0 sum_three_five = 0 for i in range(low, high): if i % 3 == 0 or i % 5 == 0: sum_three_five += i counter += 1 if counter == high -1: print(sum_three_five)
17f31ab18c5d3f2d100c967bb88ca7b399d28278
vesteinnbjarna/Forritun_Vesteinn
/Tímaverkefni/Assignment 7/A7.3.py
353
4.15625
4
# The function definition goes here def is_num_in_range(number): if number > 1 and number < 555: answer = str(number) + " is in range." else: answer = str(number) + " is outside the range!" return answer num = int(input("Enter a number: ")) result = is_num_in_range(num) print (resu...
cdc7f8ada5729b22c8eaa5f3e373c33c00e1e46d
vesteinnbjarna/Forritun_Vesteinn
/Hlutapróf 1 undirbúningur/Programming exercises/P27.py
346
4.03125
4
turns = int(input('How many turns do you want to take? ')) counter = 0 sum_of_negative_integers = 0 while counter < turns: num = int(input('Enter a integer: ')) counter += 1 if num < 0: sum_of_negative_integers += num if counter == turns: print('Sum of the entered negative numbers: ' ...
d4321a075f9540f36673bc598bfc9f1990598094
vesteinnbjarna/Forritun_Vesteinn
/Skilaverkefni/Skilaverkefni 5/project.py
1,683
4.5625
5
# The program should scramble each word in the text.txt # with the following instructions: # 1.The first and last letter of each word are left unscrambled # 2. If there is punctuation attached to a word it should be left unscrambled # 3. The letter m should not be scrambled # 4. The letters between the first an...
5d4722be04bb0d81d158f4c867a7bdb0a26cdbeb
jespher/selenium_webdriver_python
/primeira_aula/aula001_webdriver.py
603
3.5625
4
from selenium import webdriver driver = webdriver.Chrome() driver.get("http://www.google.com") # element = driver.find_element_by_xpath("//input[@name='btnI']") # Funciona element = driver.find_element_by_css_selector("input[name='btnK']") # Funciona # element2 = driver.find_element_by_css_selector("input[name='...
eb8266f810d5fdfdec69483e0d92b45420048b54
ntc1327/polynomial-regression
/project3.py
2,705
3.8125
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt # Calculates the hypothesis for the given order of polynomial def hypothesis(X, theta, n): # initialize hVals as array of zeros, reshape theta to be one bigger than the polynomial order hVals = np.zeros((100, 1)) theta = theta...
6f898b7d08ff5bb02a4b2dd05dcbf87ab3a51717
edocappelli/Orange-Crystal
/orangecontrib/crystal/plotting/PlotData1D.py
4,116
3.5
4
from collections import OrderedDict import copy class Autoscale(object): pass class PlotData1D(): """ Represents a 1D plot. The graph data together with related information. """ def __init__(self, title, title_x_axis, title_y_axis): """ Constructor. :param title: Plot title...
5136319edc47f9882757785342e8730d4a2c940e
mukadem/Mukadem-s-Repo
/scope.py
275
3.921875
4
def min_pos(vals): """Returns the minimum positive value.""" min_val = max(vals) print(x) for v in vals: if (v >= 0) and (v < min_val): min_val = v return min_val x = [-2, -4, 3, 6, 88, 76, -7] y = min_pos(x) print(y)
5b915f985fa093f6019459b40fc22647321a15e0
rheimon1/caesar_cipher
/main.py
1,413
3.703125
4
import json import hashlib from collections import OrderedDict def decode_text(encrypted_text, shift): characters = 'abcdefghijklmnopqrstuvwxyz' # string to store the decode text decrypted_text = '' # decodes each character of the encoded text for letter in encrypted_text: if letter in c...
3924586f9e9534bf51f97eacba179040b8926315
Bernard-Safi/Python
/DEVUTC503_01/EquationSecondDegre.py
500
3.8125
4
import math def calculerDelta(a,b,c): return b*b-4*a*c def resoudreSecondDegre(a,b,c): delta = calculerDelta(a,b,c) if delta > 0: val = [(-b-math.sqrt(delta))/(2*a),(-b+math.sqrt(delta))/(2*a)] elif delta < 0: val = "pas de solution" else: val = [-b/(2*a)] return val pri...
684b62def0d8dd5bb1110021eeb538b3b06b0cbb
KECB/learn
/computer_vision/07_drawing_functions.py
2,145
3.6875
4
import numpy as np import cv2 img = cv2.imread('images/saturn.png') def draw_circle(): """ cv2.circle(img, center, radius, color, thickness, lineType, shift) params: img --> Input image where circle is to be drawn center --> x, y coordinate of circle center radius ...
01f81f4b6be13fb17f0eeac40ea34f7a20c0e7d0
ryanmclincha/hangman
/hangman.py
3,401
4.21875
4
import word_list def play_hangman(): # pull a word from a custom list answer_string = word_list.word_select() answer_string = answer_string.upper() # this is how many times the player can guess wrong while True: difficulty = input("Select difficulty easy(1) normal(2) hard(3): ")...
e5f416c53d4e682be87950d8a841b02ce2c6b9bc
antonio-donato/StringCalculator
/exec.py
758
3.5
4
import re class Stringa: def __init__(self): self.somma = 0 self.parametri = "" self.default_delimiter = "," def add(self, parametri): lista_parametri = [] self.parametri = parametri if self.parametri != " ": if self.parametri.startswith("\\"): ...
a3ffb78a36226c1f6816f62b1f6e6566f38e8eea
dev1-responsify/make_requests
/blog_scraper/post_dates.py
358
3.546875
4
from bs4 import BeautifulSoup import requests response = requests.get("http://blogs.reuters.com/") soup = BeautifulSoup(response.text, 'html.parser') def find_dates(url): title =[n.text for n in soup.find_all("h2")] date = [x.text for x in soup.find_all("div",attrs={"class":"timestamp"})] print(date) ...
83dbc7fd502d37b344b909cc688329ab5803483e
raokiey/Data-augmentation-for-object-detection-Pytorch
/visual_effect/adjust_saturation.py
1,107
3.515625
4
import cv2 import random import numpy as np class RandomAdjustSaturation(object): """Adjust the saturation of the given image using a randomly chosen amount in the given range. Args: min_delta (float): Minimum of factor multiplying the saturation values of each pixel. max_delta (f...
e82d9202ef8a3d8455f71cdd7f413c1396735d7f
bharara/ProjectEuler
/9- Special pythagorean Triplet.py
662
3.84375
4
# - Problem 9 # - Special Pythagorean triplet # # A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. n = 1000 # We know # a + b +...
8c4bb565144fc5414dd061b3cd1245d65f134b22
bharara/ProjectEuler
/41 - Pandigital prime.py
566
3.75
4
# - Problem 41 # - Pandigital Prime # # What is the largest n-digit pandigital prime that exists? from math import sqrt from itertools import permutations def isPrime (x): if x == 2: return True if x % 2 == 0: return False for i in range(3,int(sqrt(x)+1), 2): if x % i == 0: return False return True val =...
7e00770f72378a6013aa54debbeb87e467cf66f5
cod4i3/MyAtcoder
/ABC01_99/ABC93/a.py
101
3.578125
4
s = input() if (s.count('a') == 1 and s.count('b') and s.count('c')): print('Yes') else: print('No')
d24eff2552c13234d0ba5766a11298d22dd711c2
cod4i3/MyAtcoder
/ABC01_99/ABC4/c.py
258
3.5
4
N = int(input()) list = [1, 2, 3, 4, 5, 6] ans = [] for i in range((N // 5) % 6, len(list)): ans.append(list[i]) for i in range((N // 5) % 6): ans.append(list[i]) for i in range(N % 5): ans[i], ans[i + 1] = ans[i + 1], ans[i] print(*ans, sep="")
ad840cf6fec255e0f4fc13b255a4acd34073efbb
cod4i3/MyAtcoder
/ABC100_199/ABC108/a.py
79
3.59375
4
K = int(input()); k = int(K / 2) print(k * (k + 1)) if K % 2 else print(k * k)
5adfebebffa786e9e65d6e6cd4392818251f7f01
cod4i3/MyAtcoder
/ABC01_99/ABC23/b.py
419
3.625
4
N = int(input()) S = input() if (S == 'b'): print(0) exit(0) ac = 'b' ans = "" for i in range(1, N + 1): ans = "" if i % 3 == 0: ans += "b" ans += ac ans += "b" elif i % 3 == 1: ans += "a" ans += ac ans += "c" else: ans += "c" ans +...
1faa1b8e02fc4b2c4cbcdb12fb121daa4806231c
cod4i3/MyAtcoder
/ABC100_199/ABC169/d.py
798
3.625
4
def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a def main(): N = int(input()) import c...
aca4275284f8b46825da717007ba049b888b1974
cod4i3/MyAtcoder
/ABC100_199/ABC132/a.py
119
3.671875
4
S = input() flag = True for c in S: if S.count(c) != 2: flag = False print('Yes') if flag else print('No')
13edbb662fa3b3b7a4bf592749b958cd0d700ee3
cod4i3/MyAtcoder
/ARC01_99/ARC35/a.py
204
3.6875
4
s = input() r = s[::-1] for i in range(len(s)): if((len(s) % 2 and i == len(s) // 2 + 1) or s[i] == r[i] or r[i] == '*' or s[i] == '*'): pass else: print('NO') exit(0) print('YES')
147b770e81264cbbc08b16e58e80ed3b0ac1ba52
aos83137/phone_address
/merge_sort.py
668
4.03125
4
def merge(list, low, mid, high): l = low r = mid + 1 temp = [] while l <= mid and r <= high: if list[l] < list[r]: temp.append(list[l]) l += 1 else: temp.append(list[r]) r += 1 if l > mid: temp.extend(list[r:high + 1]) elif ...
d78e4d4927b456eb0cc77d084f61ed4ac0764708
tburandt/pyam
/pyam/index.py
782
3.65625
4
import pandas as pd def get_index_levels(df, level): """Return the category-values for a specific level""" return list(df.index.levels[df.index._get_level_number(level)]) def replace_index_values(df, level, mapping): """Replace one or several category-values at a specific level""" return df.index.se...
3ad98a6cf77bd8ac6a41d2f4a97f3db718357999
coalastudy/python-datascrapping-code
/week5/stage1-1-file.py
325
3.640625
4
# ---- 파일 쓰기 ---- # f = open('test.txt', 'w') # # f.write("hello") # f.close() # ---- 파일에 추가 ---- # f = open('test.txt', 'a') # # f.write("hello world!") # f.close() # ---- 파일 읽기 ---- # f = open('test.txt', 'r') # lines = f.readlines() # # for line in lines: # print(line) # # f.close()
5da2845f9bca8a104478194e68ef3b69ab4426ef
coalastudy/python-datascrapping-code
/week4/stage1-2.py
937
3.515625
4
people = {'korean': 380, 'american': 42, 'japanese': 15, 'german': 26, 'french': 7, 'chinese': 213, 'canadian': 11} print(people.keys()) print(people.values()) print(people.items()) for p_item in people.items(): print('There are', p_item[1], p_item[0] + 's') chnInfos = {'하트시그널2': {'hit': 20000, 'like': 3800}...
cf35d4ef21452488517d6d143e59a692ee46643f
coti/adventofcode
/day4/day4part2.py
631
3.65625
4
#!/usr/bin/env python import sys import md5 def startsWithZeros( h ): if len( h ) < 6: print "The hash is too short" return None for c in h[:6]: if c != '0': return False return True def getHash( secret, number ): m = md5.new() m.update( secret ) m.update( str( number )) m...
6e23a813d9ee0e2bf8f02778acf25046ccb8cc25
coti/adventofcode
/day3/day3part1.py
972
3.875
4
#!/usr/bin/env python import sys def addPresent( grid, coords ): if coords in grid.keys(): grid[coords] = grid[coords] + 1 else: grid[coords] = 1 return def move( c, coord ): x, y = coord if c == '>': x = x + 1 elif c == "<": x = x - 1 elif c == '^': ...
7290bc25f5ca4730011e0ef0a459eacd60405a9b
noelthomas07/project
/maxarg.py
169
3.671875
4
#!/usr/bin/env python3 import sys max = -float("inf") for arg in sys.argv[1:]: i = int(arg) if i>max: max = i print(f"le plus grand entier est {max}")
caf58a8d76227b7adcc1c91b3f01e8e608e393a7
ainigrivS/HB-homework
/functions_mid_session_quiz.py
517
4
4
def convert_to_seconds(hours, minutes, seconds): hours_to_minutes = hours * 60 allminutes_to_convert= hours_to_minutes + minutes hoursminutes_to_seconds = allminutes_to_convert * 60 total_seconds = hoursminutes_to_seconds + seconds return total_seconds total_time_sec = convert_to_seconds(1, 1, 1) print total_...
da4b48f5e640691e6618b4dc640cc697bd6f1691
stefan-radu29/Teme-facultate-python
/Assignment 9/domain/grade.py
2,591
3.8125
4
import unittest from domain.exceptions import ValidationError class Grade: ''' Instances of this class represent a grade, having the attributes the id of the student which receives the grade, the assignment for which the grade is given and the actual grade ''' def __init__(self, assignmen...
0269094f22a869f32c57078390689d711f18e533
stefan-radu29/Teme-facultate-python
/Directed graph/controller.py
8,598
3.765625
4
import graph from math import inf class Controller: def __init__(self, directed_graph, file_name): """ Constructor for the controller class. :param directed_graph: object of class Directed_graph :param file_name: string, name of the file from which the graph will be loaded...
ceac7dc34bcbb2e51c2bdcd49ce04725d89a4873
cschmer/Fin5350
/Notebooks/pets.py
460
3.609375
4
class Animal: def __init__(self, kind, message): self.kind = kind self.message = message def speak(self): pass class Dog(Animal): def speak(self): print(f"The {self.kind} says: {self.message}") class Cat(Animal): def speak(self): print(f"The...
8b778d0e197e74f928e288439e977e612db8da1f
tichi97/code_practice
/class node.py
592
4
4
class node: def __init__(self,data=None): self.data = data self.next = None class linked_list: def __init__(self): self.head = node() # add new node to end def append(self,data): new_node = node(data) cur = self.head while cur.next!=None: cur = cur.next cur.next=new_node def length(self): c...
c6cf2225f94d848d061cd6ec9f2947d77abc6309
jhassler1031/cook-meal
/cook_meal.py
2,713
3.96875
4
#define classes #define recipe class class Recipe: def __init__(self, name, ingredients): self.name = name self.ingredients_needed = ingredients self.count = 0 def __repr__(self): return self.name def __lt__(self, ingredient): self.ingredients.append(ingredient) ...
ed4faa9570e683fd262992405c86828655fc1d04
hongningsg/Computer-Vision-and-Image-Processing
/ImageFiltering/example/ImageFilter.py
408
3.5625
4
from ImageFiltering import filter import numpy as np import cv2 ''' This is an example of using filter 0 -1 0 -1 5 -1 0 -1 0 to sharpen image. ''' TestImg = cv2.imread('./TestImage/input.jpg', -1) a = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]]) Imgfilter = filter.filter(a, padding=True, pad_option='edge')...
395cd7fe112ecafbee7007900e6cef41edd9e8ef
jackmoody11/project-euler-solutions
/python/p035.py
794
3.984375
4
from utils import is_prime def is_circular(n): # If there is an even number in # the number, then unless it is 2 # there will be an even ,and thus # non-prime, rotation if any((c in ['2','4','6','8']) for c in n): return False # Check if all rotations are primes for i in range(len(...
ce5f65c7114ac6974db2f0d9f5d4afd188bec15a
jackmoody11/project-euler-solutions
/python/p047.py
1,009
3.890625
4
# Thanks to https://radiusofcircle.blogspot.com/2016/06/problem-47-project-euler-solution-with-python.html # This post helped me rethink how to not double count and reduce number of primes I was counting def unique_prime_factors(n): """ Return set of prime factors for integer n. """ prime_factors = set() i...
6fb326b679234dcbe8a4c970f43d215025d26037
jackmoody11/project-euler-solutions
/python/p004.py
430
3.953125
4
# Find largest palindrome that is a multiple of 2 3 digit numbers from utils import is_palindrome def compute(): max_p = 0 for i in range(100, 1000): # Only go to i (inclusive) to eliminate double counting for j in range(100, i + 1): num = i * j if num > max_p and is_pa...