blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
a64ba64cd3ec6fae0217460100145edeb8fbfb63
sniemi/SamPy
/sandbox/src1/gnomonic/gnomonic.py
3,066
3.5625
4
def transformation(x, y, theta1, lam0): from math import sin, cos, asin, atan, sqrt rho = sqrt(x**2. + y**2.) c = atan(rho) #rho == 0. ???? if (rho == 0.): theta = 0. lam = 0. else: theta = asin((cos(c)*sin(theta1)) + (y*sin(c)*cos(theta1)/rho)) lam = lam0 + ata...
6d986d35f8b8fdd6a01bbcb499ad58f119568bb1
hsp48/IT610
/code2.py
1,750
3.8125
4
# Hemali Patel import datetime d = datetime.datetime.utcnow() Time = d.strftime("%a, %d %b %Y %H:%M:%S GMT\r\n") PatientName = input("Enter your name: ") print("Welcome to your HealthRecord, " + PatientName) print("Today is " + Time) #PatientAddress = input("Enter your address: ") #PatientDOB = input("Enter your D...
8dda3709dd801f7ec2b041429f6e8b3834063fac
Ericzyr/pyc_file
/studyeveryday/day1.py
226
3.71875
4
#!/usr/bin/env/python # _*_coding:utf-8_*_ # Author # name = input("input you name:") # age = input("imput you age:") # print(name, age) a = 3 b = 4 if a == b: print("-eq") elif a != b: print("=") else: print("=!")
9fd7f5d632b9c5415e66cca8835bd6fdea6091ce
Ericzyr/pyc_file
/project/ls.py
226
3.53125
4
#!/usr/bin/env/python # _*_ coding:utf-8 _*_ # Author:Eric def outer(func): def inner(): #print('before') func() #print('after') return inner @outer def f1(): print("F1") s = f1() print(s)
43faba67c87ad7de71c0bfc9c654529789390200
Ericzyr/pyc_file
/project/regex.py
733
3.65625
4
#!/usr/bin/env/python #_*_coding:utf-8_*_ # Author #!/usr/bin/python import urllib import urllib.request import os import re ip = os.popen("ipconfig").read() ipadres = "IPv4 地址.* (.*)" ipsone ="子网掩.* (.*)" getcode = re.compile(ipadres) getcode1 = re.compile(ipsone) codelist = getcode.findall(ip) codelist1 = getcode1.f...
8e8385ef43328339c89263ba5d73f31edf240f7c
ralitsapetrina/Programing_fundamentals
/Dictionaries/wardrobe.py
958
3.578125
4
n = int(input()) counter = 0 clothes_dict = {} while counter < n: colors = input().split(" -> ") key = colors[0] value = colors[1].split(",") if key in clothes_dict.keys(): clothes_dict.get(key).extend(value) else: clothes_dict[key] = value counter += 1 searching = input().s...
b537156162716df52ba50d403fb317ac66bcccb5
ralitsapetrina/Programing_fundamentals
/functions_and_debugging/greater_of_two_values.py
461
4.09375
4
def greater_int(v1, v2): print(max(int(v1), int(v2))) def greater_string(v1, v2): print(max(v1, v2)) def greater_char(v1, v2): print(max(v1, v2)) if __name__ == "__main__": value_type = input() value1 = input() value2 = input() if value_type == "char": greater_char(value1, valu...
99021eeb004c8deb749be2c581335f15be899bb0
ralitsapetrina/Programing_fundamentals
/Dictionaries/mixed_phones.py
405
3.828125
4
data_list = input().split(" : ") phone_dict = {} while not data_list[0] == "Over": if data_list[0].isdigit(): value = data_list[0] key = data_list[1] elif data_list[1].isdigit(): value = data_list[1] key = data_list[0] phone_dict[key] = value data_list = input().split(...
4bc67383a9503d15a5adc74b398e29d196a10570
ralitsapetrina/Programing_fundamentals
/functions_and_debugging/printing_triangle.py
368
3.96875
4
def printing_triangle(num): for row in range(1, num + 1): for col in range(1, row+1): print(f'{col}', end=" ") print() for row2 in range(1, num + 1): for col2 in range(1, num-row2+1): print(f'{col2}', end=" ") print() if __name__ == "__main__": num...
038f6792547910c110f95e6a43a039fb25e39739
ralitsapetrina/Programing_fundamentals
/EXAM/2_command_center.py
1,161
3.8125
4
data_list = list(map(int, input().split())) def multiply_inlist(data_list, command_list): element = command_list[1] n = int(command_list[2]) if element == 'list': data_list = data_list * n elif int(element) in data_list: while int(element) in data_list: data_list.remove(int(...
54cf28e7511aafcd6d8b1c58fc5b7fad4b92dff9
Motselisi/FunctionPackage
/FunctionPackage/recursion.py
447
3.9375
4
def sum_array(array): return(sum(array)) def fibonacci(n): if n <= 1: return n else: return fibonacci(n - 1) + fibonacci(n - 2) def factorial(n): if n <1: return 1 else: returnNumber = n * factorial( n - 1 ) print(str(n) + '! = ' + str(returnNumber)) return ...
cb8844bcac1c3fa02a35fbab9c6e8fd5c993cb74
MysticSoul/Exceptional_Handling
/answer3.py
444
4.21875
4
# Program to depict Raising Exception ''' try: raise NameError("Hi there") # Raise Error except NameError: print "An exception" raise # To determine whether the exception was raised or not ''' '''Answer2.=> According to python 3.x SyntaxError: Missing parentheses in call to print ...
43d0ff3a57bd0c6b7d14e7a1b1fd39f1fb7de46e
JTSchwartz/chorecore-py
/chorecore/strings.py
149
3.5
4
def replacement_map(alter: str, replacements: dict): for key in replacements.keys(): alter = alter.replace(key, replacements[key]) return alter
81629a87c33df62b0c6772f9bbd96d7737135031
csestelo/advent_of_code
/2021/day-2/part_2.py
503
3.671875
4
from io import StringIO def calculate_position_as_in_manual(instructions: StringIO) -> int: horizontal_position = 0 depth = 0 aim = 0 for step in instructions: direction, qty = step.strip().split(' ') qty = int(qty) if direction == 'forward': horizontal_position +...
0d74ce6cdac536a6db72fde5dcc54ad4d5491a76
SupahXYT/pathfinders
/thread.py
795
3.578125
4
import threading from random import random from time import sleep class Useful: def __init__(self): self.list = [] def random(self): for i in range(15): self.list.append(random()) sleep(1) class Visualize: def __init__(self): self.use = Useful() def m...
1b1831a88321c97dad633eb7b0b81b20b59631c7
huangliu0909/Random-SkipList
/test_sl.py
5,375
3.59375
4
import random import datetime import sys minint = 0 maxint = sys.maxsize class Node(object): def __init__(self, key=minint, value=[], level=1): self.key = key self.value = value self.level = level self.right = None self.down = None class SkipList(object)...
6e4eca96847b5be0be67a2b9998bf1205fcf0fdd
sripushkar/Gas-Money
/main.py
2,827
3.828125
4
import requests import xml.etree.ElementTree as ET print("Welcome to Gas Money Calculator by Sri Julapally") print("Make sure to only enter appropriate inputs for the below questions, or the program will fail.") pricesUrl = "https://www.fueleconomy.gov/ws/rest/fuelprices" pricesList = requests.get(pricesUrl) pricesRo...
693445221ddfee3592077c1f6e7a86ab73436d51
kevinmcaleer/PicoCrab
/transition.py
10,423
3.609375
4
from math import sin, cos, pi, sqrt def check_exceptions(calc, change_in_value, start_value): # Check if the value is increasing over time if change_in_value > start_value: if calc > (change_in_value + start_value): # print("triggerd increase exception") return change_in_value + st...
dc33678a8148cc46b16fe2cc739a41deb05b2cb6
devhelenacodes/python-coding
/pp_03.py
320
3.890625
4
#List Less than Ten max_val = input("Type a random number not more than 89:\n") a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] x = [] y = [] for item in a: if item < 10: x.append(item) print(x) try: max_val = int(max_val) for item in a: if item < max_val: y.append(item) print(y) except ValueError: pass
9aff241bff636fa31f64cc83cb35b3ecf379738a
devhelenacodes/python-coding
/pp_06.py
621
4.125
4
# String Lists # Own Answer string = input("Give me a word:\n") start_count = 0 end_count = len(string) - 1 for letter in string: if string[start_count] == string[end_count]: start_count += 1 end_count -= 1 result = "This is a palindrome" else: result = "This is not a palindrome" print(result) # Learned...
a0c9c921c59cb43a94724fa0e5be5ee090a0eb8c
Eakamm/Notes
/PythonLearning/基础语法/7q9p8siqi_code_chunk.py
117
3.78125
4
numbers = 10 while 1: if numbers % 2 == 0: continue print(numbers) numbers-=1 if numbers < 0: break
61afb5ff48304df45244d45458f1d95acf5ae85a
YusukeWasabi/guess_the_number
/guess_the_number_AUTO.py
376
3.828125
4
from random import randint print("///// THIS PROGRAM STOPS WHEN BOTH 'X' and 'Y' values are the same /////\n") while True: x = randint(2, 8) y = randint(2, 8) if x == y: print("\tBoth X and Y matched! Hooray!") print(f"\tX = {x} and Y = {y}") break else: print(f"X = {x}...
34b04e7f38acc6940a808a80945e2d6e048e065c
AlbertSuarez/advent-of-code-2018
/src/day_8.py
2,946
3.75
4
""" Day 8: Memory Maneuver """ _INPUT_FILE = 'data/day_8_input.txt' def build(idx, numbers, result): if idx == len(numbers): return # Get header info child_nodes = numbers[idx] idx += 1 metadata_entries = numbers[idx] # Get recursively children information if child_nodes: ...
ce1f18b609f93ee5cb4bcb7be6c85b86f29312d9
xfrl/national_flag
/博茨瓦纳.py
1,600
3.546875
4
""" 博茨瓦纳国旗 博茨瓦纳(Botswana)又译为波札那,全称博茨瓦纳共和国,是位于非洲南部的内陆国,首都哈博罗内。博茨瓦纳国旗呈长方形,长宽之比为3∶2。 旗面中间横贯一道黑色宽条,上下为两个淡蓝色的横长方形,黑色与淡蓝色之间是两道白色细条。黑色代表博茨瓦纳人口中的绝大部分黑人;白色代表白人等人口中的少数部分;蓝色象征蓝天和水。 国旗的寓意是在非洲的蓝天下,黑人和白人团结、生活在一起。 """ import turtle width = 900 height = 600 turtle.screensize(width,height,"white") turtle.setup(width=width,height=heig...
d5a5b426c401684a326290e27101c566a9240c88
xfrl/national_flag
/圣多美和普林西比民主共和国.py
2,091
3.9375
4
""" 圣多美和普林西比民主共和国国旗 圣多美和普林西比国旗呈横长方形,长与宽之比为2:1。由红、绿、黄、黑四色构成。靠旗杆一侧为红色等腰三角形,右侧为三个平行宽条,中间为黄色,上下为绿色,黄色宽条中有两颗黑色五角星。 绿色象征农业,黄色象征可可豆和其他自然资源,红色象征为独立自由而斗争战士的鲜血,两个五角星代表圣多美、普林西比两个大岛,黑色象征黑人。 """ import turtle import math w = 900 h = 450 h_m = h/3 c = math.sqrt((math.pow(h / 2,2) + math.pow(h / 2,2))) #三角形边长 turtle.screensize(w,h...
a6766e78080ba1118533361e4d16d2e5a9e63694
xfrl/national_flag
/古巴.py
2,418
3.890625
4
""" 古巴国旗 长方形,长与宽之比为2:1。旗面左侧为红色等边三角形,内有一颗白色五角星;旗面右侧由三道蓝色宽条和两道白色宽条平行相间、相连构成。五角星代表古巴是一个独立的民族。 三角形和星是古巴秘密革命组织的标志,象征自由、平等、博爱和爱国者的鲜血。 五角星还代表古巴是一个独立的民族。三道蓝色宽条表示古巴形成时由三部分组成,白条表示古巴人民的纯洁理想。 """ import turtle import math w = 900 h = 450 h_m = h/5 turtle.screensize(w,h,"white") turtle.setup(w,h) t = turtle.Turtle() t.pensize(1...
d33b8a03042d3f81fe99e1733a23cff45b320bef
pyfra/tic-tac-toe
/game.py
3,012
3.671875
4
from board import Board from players import RandomPlayer, HumanPlayer, MiniMaxPlayer, MixedPlayer, DLPlayer, Player import random as rnd import time class Game: def __init__(self): self.board = None self.players = [None, None] def _initialize_game(self): self.board = Board() ...
5ae27ed7ccb33a62bbb98ff56f51952d43eaaed6
sergiofagundesb/PythonRandomStuff
/qualnome.py
320
4.125
4
n1 = int(input('Digite um número')) n2 = int(input('Digite mais um número')) s=n1+n2 p=n1*n2 di=n1//n2 d=n1/n2 pot=n1**n2 mod=n1%n2 print('A soma é {},\n o produto é {},\n a divisão inteira é {},\n a divisão é {:.3f},\n a potência é {}\n e o resto {}'.format(s,p,di,d,pot,mod), end='====') print('Cu é bom')
cfa7164dda49a23369a3eed3c7bfa7e894f5ac5a
sergiofagundesb/PythonRandomStuff
/dobro.py
422
3.9375
4
n=float(input('Digite um número')) print('O número {} tem seu dobro {}, triplo {}, e raiz quadrada {}'.format(n,(2*n),(3*n),(n**(1/2)))) print('='*20) n1=float(input('Digite o primeiro número')) n2=float(input('Digite o segundo número')) media=(n1+n2)/2 if media >= 5: print('Aprovado') if media < 5: print('Repr...
58ff082e4767aa3ed269ee667adb3e42268bc9c7
sergiofagundesb/PythonRandomStuff
/metromero.py
260
3.859375
4
m=float(input('Digite a medida em metros')) print('Em km {:.3f}',format(m/1000)) print('Em hm {:.3f}'.format(m/100)) print('Em dam {:.3f}'.format(m/10)) print('Em dm {:.0f}'.format(m*10)) print('Em cm {:.0f}'.format(m*100)) print('Em mm {:.0f}'.format(m*1000))
9e8a295c69f8b75092977b3a02128c15c6672153
iamSumitSaurav/Python-codes
/prime factorization.py
208
4.03125
4
num = int(input("Enter a number")) d = 2 print("The prime factors of {} are:".format(num)) while(num > 1): if(num % d == 0): print(d) num = num / d continue d = d + 1
8fa6fb0f56335852e60aa11fc19a5bc5630ddc6d
iamSumitSaurav/Python-codes
/testing.py
115
3.90625
4
tell = 'Y' while(tell == 'Y' or tell == 'y'): print(5) tell = input("Enter the value of tell")
9c5e64d8e7bc0120085be1a7cb43c397876aba08
litojasonaprilio/CP1404-Practicals
/prac_03/gopher_population_simulator.py
578
3.90625
4
import random POPULATION = 1000 MIN_BORN = 0.1 MAX_BORN = 0.2 MIN_DIED = 0.05 MAX_DIED = 0.25 YEAR_PERIOD = 10 print("Welcome to the Gopher Population Simulator!") print("Starting population:", POPULATION, "\n") for i in range(1, YEAR_PERIOD + 1): print("Year {}".format(i)) print("*****") born = int(ran...
a176dbc8191e0cb82f1e2d93434a87327dfaaad6
litojasonaprilio/CP1404-Practicals
/prac_01/extension_2.py
520
4.125
4
print("Electricity bill estimator 2.0", '\n') TARIFF_11 = 0.244618 TARIFF_31 = 0.136928 tariff = int(input("Which tariff? 11 or 31: ")) while not (tariff == 11 or tariff == 31): print("Invalid number!") tariff = int(input("Which tariff? 11 or 31: ")) if tariff == 11: price = TARIFF_11 else: price = T...
90717c6f92d2e1c2f46294f3e1bff6794c2110c2
ajsmash7/readinglist
/model.py
1,942
3.859375
4
from dataclasses import dataclass, field # TODO add a docstring for this module. ''' This Module contains the object class models to create an instance of: a counter object a book object This module defines the data classes and their class methods as a model for use in book list application. ''' def gen_id()...
ae97ffb8225c5f468058af8d3d3c0b2a50d114a7
ryszardkapcerski/simple-millionaries
/modules/test.py
1,851
3.71875
4
from modules.question import Question import random class Test(object): def __init__(self, username): self.username = username @staticmethod def run_test(): levels = ["500", "1000", "2000", "5000", "10000", "20000", "40000", "75000", "125000", "250000", "1000000"] for l in level...
50810e17266530aa63128b4652621753c6b460bd
Kalaborative/AutoDuolingo
/quicktrans.py
2,626
3.78125
4
# Greetings! In this file, we're going to be using # Google's client library to translate some text # to another language. This is gonna be exciting! from google.cloud import translate from time import sleep from sys import exit api_key = 'AIzaSyAdiQFUXy5Dgr4coKTWwWJllIM5oVRUruc' langcodes = { "arabic": "ar", "czec...
26fb03d7961e7a2d1c34fd0ef19b5ef2f6293061
emeryberger/COMPSCI590S
/projects/project1/wordcount.py
839
4.28125
4
# Wordcount # Prints words and frequencies in decreasing order of frequency. # To invoke: # python wordcount.py file1 file2 file3... # Author: Emery Berger, www.emeryberger.com import sys import operator # The map of words -> counts. wordcount={} # Read filenames off the argument list. for filename in sys.argv[1:]...
f81c7d65da08a974ae86d04b3fb78dafb49bc0ec
royshouvik/6.00SC
/Unit 1/ps3/ps1a.py
269
3.546875
4
balance = float(raw_input("Enter the outstanding balance on your credit card:")) annual_interest_rate = float(raw_input("Enter the annual credit card interest rate as a decimal:")) minimum_monthly_pmt = float(raw_input("Enter the minimum monthly payment as a decimal"))
d60ed325ec0a0ab4eec5bd6da2e27be3a3c4e4d7
christianversloot/keras-visualizations
/autoencoder_encodedstate_sequential.py
2,503
3.515625
4
''' Visualizing the encoded state of a simple autoencoder created with the Keras Sequential API with Keract. ''' import keras from keras.layers import Dense from keras.datasets import mnist from keras.models import Sequential from keract import get_activations, display_activations import matplotlib.pyplot as plt fr...
4a991196f4799b7f8e9dc0d9c59418a2ec2f0da2
cssubedi/DataStructures
/graph/include/directed_graph_data_structures.py
1,300
3.546875
4
from undirected_graph_data_structures import Node, LinkedList class Vertex(object): def __init__(self, element): self.element = element self.visited = False self.parents = LinkedList() self.children = LinkedList() self.interval = [] @property def out_degree(self): ...
2a11fa1a1b0963176e6065bfd78b85602e003bd6
cssubedi/DataStructures
/hashtable/scripts/chaining.py
3,430
3.6875
4
import sys sys.path.append("../include/") from hash_function import * from linked_list import LinkedList class HashFunctionError(Exception): pass class DuplicateInsertionError(Exception): pass class HashWithChaining(object): def __init__(self, size, hash_function="simple"): """ Implementation ...
e60fdb2cde00bb882c750aaeb1dcde96f8d8b313
luisfjf/PracticaJunio2017_201020614
/Practica1EDD/src/listaUsuarios.py
2,542
3.71875
4
# Para la elaboracion de esta lista se tomo de referencia el contenido del siguiente video # https://www.youtube.com/watch?v=c27dIMT9kLE from nodoUsuario import NodoUsuario class ListaUsuarios: #Metodo constructor def __init__(self): self.primero = None self.ultimo = None #Metodo para veri...
5cde8a60863e5bb812b5bec4cef28a8b31207ec2
efeacer/EPFL_ML_Labs
/Lab05/template/least_squares.py
1,189
4
4
# -*- coding: utf-8 -*- """Exercise 3. Least Square """ import numpy as np def least_squares(y, tx): """ Least squares regression using normal equations Args: y: labels tx: features Returns: (w, loss): (optimized weight vector for the model, optimized final loss b...
5bb4299f898d7a3957d4a0fd1ed4eb151ab44b47
efeacer/EPFL_ML_Labs
/Lab04/template/least_squares.py
482
3.5625
4
# -*- coding: utf-8 -*- """Exercise 3. Least Square """ import numpy as np def compute_error_vector(y, tx, w): return y - tx.dot(w) def compute_mse(error_vector): return np.mean(error_vector ** 2) / 2 def least_squares(y, tx): coefficient_matrix = tx.T.dot(tx) constant_vector = tx.T.dot(y) ...
4cccd10c95689842e2fba8d256bd086bec47e32e
tkruteleff/Python
/6 - String Lists/string_lists.py
295
4.125
4
word = str(input("Type in a word ")) word_list = [] reverse_word_list = [] for a in word: word_list.append(a) print("One letter " + a) reverse_word_list = word_list[::-1] if(word_list == reverse_word_list): print("Word is a palindrome") else: print("Word is not a palindrom")
84533ee76a2dc430ab5775fa00a4cc354dfc2238
tkruteleff/Python
/16 - Password Generator/password_generator.py
1,239
4.3125
4
import random #Write a password generator in Python. #Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. #The passwords should be random, generating a new password every time the user asks for a new password. #Include your run-time co...
be0e80a6a6453f5b5283b6121eeeae9d39064d1d
chengfzy/PythonStudy
/vision/resize_image.py
1,391
3.546875
4
""" Read image in folder, resize it and save to file with .jpg format """ import os import argparse import imghdr import cv2 as cv def main(): # argument parser parser = argparse.ArgumentParser(description='Resize Image') parser.add_argument('--folder', type=str, required=True, help='image folder') p...
1857b4149bfd01f3d03a48b006cc685b99ebd4f0
Ajaykushwaha1111/phonebook1
/news/example.py
321
3.78125
4
MyrecordsList=[] class Myrecords: def __init__(self): self.title ='No Title' self.desc ='No Desc' def save(self): MyrecordsList.append(self) m =Myrecords() m.title =input("enter title") m.desc=input("ener desc") m.save() print(m.title) print(m.desc) print(MyrecordsList) ...
a40b0b8ff710ba85b9d98b2cac4cd96f9b3bd0d0
Shubodh/ICRA2020
/pose_graph_optimizer/mlp_in.py
2,745
3.65625
4
from sys import argv, exit import matplotlib.pyplot as plt import math import numpy as np def getTheta(X ,Y): THETA = [None]*len(X) for i in xrange(1, len(X)-1): if(X[i+1] == X[i-1]): if (Y[i+1]>Y[i-1]): THETA[i] = math.pi/2 else: THETA[i] = 3*math.pi/2 continue THETA[i] = math.atan((Y[i+1]-Y[...
ee685039da5f85b6be21bf2d4b5d018d7e073206
Shubodh/ICRA2020
/pose_graph_optimizer/line_fit.py
385
3.5
4
from scipy import stats import numpy as np import matplotlib.pyplot as plt x = np.linspace(1, 10, 100) y = x**2 # ax = plt.subplot(1,1,1) # ax.plot(x, y, 'k-') # plt.show() (slope, intercept, _, _, _) = stats.linregress(x,y) x1 = 1; x2 =10 y1 = slope*x1 + intercept y2 = slope*x2 + intercept ax = plt.subplot(1,1,1)...
f4990db45bfa41fa298cc0c8a4e99d8f93b5a9a9
akash-yadav12/PythonMiniProjects
/hangman.py
3,090
3.96875
4
import random def hangman(): word = random.choice(['akame','arima','tatsumi','shinra','subaru','rem','okabe','elpsycongro','kurisu','hashida','yagamilight']) validletters = 'abcdefghijklmnopqrstuvwxyz' turn = 10 guessMade = '' while len(word) > 0: main = '' for lt in word: ...
501fad69d0fa6ef427e76fb86c07ee2ea8fa36d2
Daniel-Wasnt-Available/Homework-Repository
/pgZero intro/Paint Game.py
941
3.703125
4
#----------------------------------------------------------------------------- # Name: New File Generator (newFile.py) # Purpose: Generates a new file for use in the ICS3U course # # Author: Mr. Brooks # Created: 13-Sept-2020 # Updated: 13-Sept-2020 #---------------------------------------------...
654b28aea8a02c74b12e960d6571fd39cba19bb7
DeoPatt/lab6
/main.py
478
4
4
#this is my first time coding python print("Hello world!") num1 = 5 num2 = 2 mesasge = "new message" sum = num1 + num2 print(sum) diff = num1 - num2 print(diff) prod = num1 * num2 print(prod) quotient = num1/num2 print(quotient) remainder = num1%num2 print(remainder) age = input("enter your age") if (int(age) < 21): ...
9777a2a85ad74c0cad75352fcded12ef838f3eb0
echang19/Homework-9-25
/GradeReport.py
987
4.15625
4
''' Created on Mar 12, 2019 @author: Evan A. Chang Grade Report ''' def main(): studentList={'Cooper':['81','86', '90', '97'],'Jennie':['98', '79','99', '87', '82'], 'Julia':['87', '80','75', '10', '78']} student='' read=input("Would you like to access a student's grades?") read.lower() ...
c0debf3c0f7ed57f46a0005806bf855b10ca284a
echang19/Homework-9-25
/Pg403n7.py
653
3.5625
4
''' Created on Feb 28, 2019 @author: Evan A. Chang Driver's License ''' def main(): cor=0 correct=["A", 'C', 'A', 'A', 'D', 'B', 'C', 'A', 'C', 'B', 'A', 'D', 'C', 'A', 'D', 'C', 'B', 'B', 'D', 'A'] student=open('Test.txt', 'r') #in a loop student.append() x=0 while len(...
848e68fa7274a65beeea2e64e4afa9450167a2e4
drslump/pysh
/pysh/transforms/beta/lazyapply.py
1,293
4
4
""" Converts expressions like: >>> func <<= cat | head > null func << (cat | head > null) The whole expression at the right of the operator is grouped. This allows for callables to receive an argument without using parenthesis. .. Warning:: This transformation **breaks** the standard ``<<=` operator in norm...
485e46e2099548b5398d9e05138b84e5ce7eb357
myselfmonika11/PyPrograms
/String.py
184
4.09375
4
#This is an example of String Concatenation : Fname='Monika' Lname="Singh" print(Fname + ' ' + Lname) #Output: Monika Singh #Note: By default string follows unicode.
3c3947990f2723a64e92180a7de48fb72c38fc15
X3N0N102/P-Uppgift
/P_Uppgift_Arga_Troll/diagonalTest.py
584
3.578125
4
from tkinter import* master=Tk() master.title("Arga troll") master.geometry("500x500") for i in range (5): for j in range(5): button=Button(master, text=i, height = 10, width = 40) button.grid(row=i, column=j) # button1=Button(master,text="B1") # button1.grid(row=1,column=1) # button2=Button(m...
6fd73cc628524cb032dbef9d89539437bf176929
colinaardsma/tfbps
/hashing.py
2,110
3.546875
4
import hashlib, hmac #hmac is more secure version of hashlib (when is this best used?) from dbmodels import Users #import Users class from python file named dbmodels import string import random """ fucntions for hasing and checking password values """ def make_salt(): size = 6 chars = string.ascii_lowercase + ...
2a1846f1de7daa7957dfbf272e16b185c344cfc2
mittal-umang/Analytics
/Assignment-2/MultiplyMatrix.py
1,194
4.3125
4
# Chapter 11 Question 6 # Write a function to multiply two matrices def multiply_matrix(left, right): result = [] for i in range(len(left)): innerMatrix = [] for j in range(len(left)): sum = 0 for k in range(len(left)): sum += left[i][k] * right[k][j] ...
ed4293c4fcc473795705f555a305a4ee7c7a2701
mittal-umang/Analytics
/Assignment-2/VowelCount.py
977
4.25
4
# Chapter 14 Question 11 # Write a program that prompts the user to enter a # text filename and displays the number of vowels and consonants in the file. Use # a set to store the vowels A, E, I, O, and U. def main(): vowels = ('a', 'e', 'i', 'o', 'u') fileName = input("Enter a FileName: ") vowelCount = 0 ...
b4d8a241abc3176839928d2f88f77ef6866cef5e
mittal-umang/Analytics
/Assignment-1/GCD.py
412
4.03125
4
# Chapter 5 Question 16 # Compute the greatest common divisor def main(): num1, num2 = eval(input("Enter two number with comma : ")) if num1 > num2: d = num2 else: d = num1 while d > 0: if num1 % d == 0 and num2 % d == 0: break d -= 1 print("The Greate...
40348bc030ebcb6daf547ae7688cbca81fe066d9
mittal-umang/Analytics
/Assignment-2/Triangle.py
1,849
3.765625
4
# Chapter 12 Question 1 from GeometricObject import GeometricObject from TriangleError import TriangleError class Triangle(GeometricObject): def __init__(self, color, isFilled, side1=1.0, side2=1.0, side3=1.0): super().__init__(color, isFilled) if not (abs(int(side2) - int(side3)) < int(side1) < i...
67593b7fcb04e87730e87066e587576fc3a88386
mittal-umang/Analytics
/Assignment-1/PalindromicPrime.py
1,189
4.25
4
# Chapter 6 Question 24 # Write a program that displays the first 100 palindromic prime numbers. Display # 10 numbers per line and align the numbers properly import time def isPrime(number): i = 2 while i <= number / 2: if number % i == 0: return False i += 1 return True def...
ab73985f340bdcafff532a601e84d268f849a7db
mittal-umang/Analytics
/Assignment-1/RegularPolygon.py
1,258
4.25
4
# Chapter 7 Question 5 import math class RegularPolygon: def __init__(self, numberOfSide=3, length=1, x=0, y=0): self.__numberOfSide = numberOfSide self.__length = length self.__x = x self.__y = y def getNumberOfSides(self): return self.__numberOfSide def getLengt...
cea462ca0b7bf4c088e1a2b035f26003052fcef2
mittal-umang/Analytics
/Assignment-2/KeyWordOccurence.py
1,328
4.40625
4
# Chapter 14 Question 3 # Write a program that reads in a Python # source code file and counts the occurrence of each keyword in the file. Your program # should prompt the user to enter the Python source code filename. def main(): keyWords = {"and": 0, "as": 0, "assert": 0, "break": 0, "class": 0, ...
49837fed1d537650d55dd8d6c469e7c77bc3a4c6
mittal-umang/Analytics
/Assignment-1/ReverseNumber.py
502
4.28125
4
# Chapter 3 Question 11 # Write a program that prompts the user to enter a four-digit integer # and displays the number in reverse order. def __reverse__(number): reverseNumber = "" while number > 0: reverseNumber += str(number % 10) number = number // 10 return reverseNumber def main():...
4bdeb3a2c137e5fa69998ca4503538302082cef0
mittal-umang/Analytics
/Assignment-1/SineCosWave.py
977
4.3125
4
# Chapter 5 Question 53 # Write a program that plots the sine # function in red and cosine in blue import turtle import math def drawLine(x1, y1, x2, y2): turtle.goto(x1, y1) turtle.pendown() turtle.goto(x2, y2) turtle.penup() def main(): drawLine(-360, 0, 360, 0) drawLine(0, -150, 0, 150) ...
c86efaf3ce656c67a47a6df3c036345d6e604001
mittal-umang/Analytics
/Assignment-2/AccountClass.py
1,428
4.1875
4
# Chapter 12 Question 3 class Account: def __init__(self, id=0, balance=100, annualinterestrate=0): self.__id = id self.__balance = balance self.__annualInterestRate = annualinterestrate def getMonthlyInterestRate(self): return str(self.__annualInterestRate * 100) + "%" def...
a818d6ce507d2f268775219810d8e53696653308
pravindra01/DS_And_AlgorithmsPractice
/formatIntArray.py
894
3.875
4
# even numbera at beginning # odd at the end # take time O(n/2) # O(1) space # Input : [1,2,3,4,5,6,7,8,9,10] # Output: [10,2,8,4,6,5,7,3,9,1] def formatIntArray(arr): startIndex = 0 endIndex = len(arr) -1 for _ in range(0,len(arr)): if startIndex > endIndex: break print "STAR...
0171884c3ecadb4d49e762c8fa8718033510e751
MihaChug/PRRIS
/Contacts/main.py
714
3.796875
4
## -*- coding: utf-8 -*- contacts = [] command = "" find = 0 print('If you want to exit - print "exit"') while command != "exit": command = input(">") #Добавляем новый контакт в конец списка c учетом всех возможных сочетаний начальных букв с первой по последнюю if command[0:3] == 'Add': for i in range(l...
104e227416410541282791c06aa53c2fb4f283e0
lbl-kmust/Git-workspace
/Python_study/lemon_82/python _exercises.py
9,251
3.953125
4
# 1. 用户输入一个数值,请判断用户输入的是否为偶数?是偶数输出True,不是输出False # (提示:input输入的不管是什么,都会被转换成字符串,自己扩展,想办法转换为数值类型,再做判段,) # a = int(input("请输入一个整数:")) # print(a) # if a % 2 == 0 : # print("True") # else : # print("False") # 2. 现在有列表 li = [‘hello’,‘scb11’,‘!’],通过相关操作转换成字符串:'hello python18 !'(注意点:转换之后单词之间有空格) # li = ['hello','scb11'...
279e2c3c7a93890b41292507f7b0ee99754fecec
jbesong-su/DeepLearningKeras
/Multiclass classification flower species/irisclass.py
1,805
3.625
4
from pandas import read_csv from keras.models import Sequential from keras.layers import Dense from keras.wrappers.scikit_learn import KerasClassifier from keras.utils import np_utils from sklearn.model_selection import cross_val_score, KFold from sklearn.preprocessing import LabelEncoder #load data set dt = read_csv(...
d6947d35220f814803f795e2cca3ba59377066f8
galustian/Algorithms
/symbol_table.py
2,993
4.09375
4
import queue # Very simple implementation using a binary search tree # Assumes that keys are strings class MapStr: class Node: def __init__(self, key, val): self.key = key self.val = val self.left = None self.right = None def __init__(self): self....
692505ec86ff96fe6e96802c2b2cf6306e11e2e0
mfnu/Python-Assignment
/Functions-repeatsinlist.py
554
4.1875
4
''' Author: Madhulika Program: Finding repeats in a list. Output: The program returns the number of times the element is repeated in the list. Date Created: 4/60/2015 Version : 1 ''' mylist=["one", "two","eleven", "one", "three", "two", "eleven", "three", "seven", "eleven"] def count_frequency(myl...
6cce56a231c2e45d7685793b57e412baf6ac0483
bxnxiong/Lint-Code
/97 validateBinaryTree.py
1,455
4.0625
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: The root of binary tree. @return: True if the binary tree is BST, or false """ def isValidBST(self, root): # write...
419012b91013b1c4a7407962c88a087a50a0f625
bxnxiong/Lint-Code
/159 findMinimumInRotatedArray.py
729
3.640625
4
class Solution: # @param nums: a rotated sorted array # @return: the minimum number in the array def findMin(self, nums): # write your code here n = len(nums) if nums[0] > nums[-1]: if n == 0:return if n == 2 or n == 3: i = 0 ...
fa86f910fd80f768df290210058c4b77d10f7c70
bxnxiong/Lint-Code
/535 houseRobberIII.py
872
3.625
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): sef.val = val self.left, self.right = None, None """ class Solution: # @param {TreeNode} root, the root of binary tree. # @return {int} The maximum amount of money you can rob tonight def houseRobber3(self, root): ...
d8cd23f22958facb0eec42633a92680e8d856093
bxnxiong/Lint-Code
/127 topologicalSorting-DFS.py
965
3.90625
4
# Definition for a Directed graph node # class DirectedGraphNode: # def __init__(self, x): # self.label = x # self.neighbors = [] class Solution: """ @param graph: A list of Directed graph node @return: A list of graph nodes in topological order. """ def topSort(self, graph): ...
12eda60f4cd791043a1fccbb8de014e69489edfc
bxnxiong/Lint-Code
/124 longestConsecutiveSequence.py
924
3.59375
4
class Solution: """ @param num, a list of integer @return an integer """ def longestConsecutive(self, num): # write your code here book = {x:False for x in num} maxLen = -1 for i in book: if book[i] == False: ...
b8b367bfeccd86b3a65afb3194533b0b5b94efa4
bxnxiong/Lint-Code
/123 wordSearch.py
1,827
3.734375
4
class Solution: # @param board, a list of lists of 1 length string # @param word, a string # @return a boolean def exist(self, board, word): # write your code here def dfs(r,c,word): if len(word) == 0: return True else: # up ...
013cb916d56e94c09e5d0451ceff7c532c3a85cd
rustyhu/design_pattern
/python_patterns/builder.py
1,028
4.125
4
"Personal understanding: builder pattern emphasizes on the readability and user convenience, the code structure is not quite neat." class BurgerBuilder: cheese = False pepperoni = False lettuce = False tomato = False def __init__(self, size): self.size = size def addPepperoni(self): ...
82fbec4c59b15ddb8379fb9bc955ab4b12ec26b5
rustyhu/design_pattern
/python_patterns/composite.py
1,297
3.734375
4
""" Composite pattern. client use a group of objects and single object uniformly. """ from abc import ABC, abstractmethod # interface 1 NOT_IMPLEMENTED = "You should implement this." class Graphic(ABC): @abstractmethod def print(self): raise NotImplementedError(NOT_IMPLEMENTED) class CompositeGraphi...
11cd522822a346f626acbab4bb98792ad659fe0b
Nate18464/WorldVaccination
/research/source/DataVisualization/PredictionCreator/data_visualization_file_creator.py
5,318
3.640625
4
""" This modules extracts and cleans the original vaccination data in order to have only the date, country, and people_fully_vaccinated_per_hundred columns Then, it makes predictions and saves them into a pandas dataframe After, it combines these predictions with the original data Finally, it creates a csv file with...
7a7280c364cbe5354fe40681de0df47a8e8c68aa
MikeYu123/algorithms-lafore
/queues/list_deque.py
1,071
3.640625
4
from doubly_linked_list import DoublyLinkedList class ListDeque: # TODO limit size def __init__(self, size = 0): self.list_obj = DoublyLinkedList() # top of the stack is def list(self): return [link.key for link in self.list_obj.array()] def isEmpty(self): return self.list_obj...
8700991ed68dbbf7479c3036095d8024018f1380
MikeYu123/algorithms-lafore
/queues/array_stack.py
841
3.78125
4
class ArrayStack: def __init__(self, size = 10): self.array = [None] * size self.size = size self.max = -1 def isEmpty(self): return self.max == -1 def peek(self): if self.isEmpty(): raise ValueError("Peeking empty stack") return self.array[self....
7f6b51ce83ed4d1231ec2061e7e4df37ed8db8d4
sorata2894/rlcard3
/rlcard3/model_agents/agent.py
553
3.71875
4
""" Agent base class """ from typing import Dict class Agent(object): """ The base Agent class """ def step(self, state: Dict) : """ Predict the action given raw state. A naive rule. Choose the minimal action. Args: state (dict): Raw state from the game Retur...
a5bf298e23f1783bbea3212bb405351708f3e6b4
sorata2894/rlcard3
/rlcard3/games/gin_rummy/card.py
2,669
3.671875
4
''' File name: gin_rummy/card.py Author: William Hale Date created: 2/12/2020 ''' from typing import List class Card(object): ''' Card stores the card_id, rank and suit of a single card Note: The card_id lies in range(0, 52) The rank variable should be one of [A, 2, 3, 4, 5, ...
22da60b435758fa5bbc91c7003fb3fd197a0410e
bilalsay/PersonalDevelopment
/PythonExamples/ex1.py
984
3.5
4
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or "license()" for more information. >>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. pr...
150ca8fba109eeb0301cff54ce0d65b3a8d16c44
anhpt1993/file_storage
/file_storage.py
447
3.921875
4
# file capacity on disk while True: try: byte = int(input("What is your file size (byte): ")) if byte > 0: break else: print("File size shall be greater than 0") print() except ValueError: print("File size shall be integer type, not float type...
b486878c4c86a6c99c2cb69445eddb0bf255eeec
gozeloglu/Input-File-Creator
/create.py
820
3.671875
4
""" *This program creates grid map for Assignment-4 *Enter the number of row and column number that you want to create """ import sys import random fp = open("gameGrid.txt", "w") jewel_list = ["|", "-", "+", "/", "\\", "D","W", "S", "T"] row = int(input("Row number: ")) column = int(input("Column number: "...
12e879ea015afa8c36ec9bfcac08a31139d90d38
Vipinraj9526/Python
/pgm3.py
162
3.53125
4
import csv with open("city.csv","w") as file: writer=csv.writer(file) writer.writerow([1,"max","thrissur"]) # for row in reader: # print(row)
ceb080ee75b09108b07f1cb0dd48037ce315d5c4
Ishikaaa/Python-Assignments
/Assignment-17.py
926
3.5
4
#Q1. from tkinter import * a=Tk() a.title("Ishika Garg") l=Label(a,text="Helo World").pack() b=Button(a,text="Exit",command=quit).pack() a.mainloop() #Q2. from tkinter import * a=Tk() a.title("Ishika Garg") def show(): print("Hello World") l=Label(a,text="Hello World").pack() b1=Button(a,text="Click",command=s...
5490c0ae8130bcbf90dc1c9c6484219148662d47
Ishikaaa/Python-Assignments
/Assignment-5.py
1,376
3.796875
4
#Q1. year=int(input("Enter year=")) if(year%4==0): print(year,"is a leap year") else: print(year,"is not a leap year") #Q2. l=int(input("Enter length=")) b=int(input("Enter breadth=")) if(l==b): print("This is a square") else: print("This is a rectangle") #Q3. a=int(input("Enter age of 1st person=")) ...
cc785e3dfc9bd46ee95987084661527458a5ca58
Ishikaaa/Python-Assignments
/Doubtt.py
915
4.09375
4
# #1.If you want to add more than one numbers at one time # A=[1,2] # for i in range(4): # a=int(input("Enter nunmber=")) # A.append(a) # print(A) # # # A=[1,2] # a=int(input("Enter 1st number=")) # b=int(input("Enter 2nd number=")) # c=int(input("Enter 3rd number=")) # d=int(input("Enter 4th number=")) # A.ext...
3d2d01b1680a3593d937b20b83db444434066264
Rolemodel01291/HackerRank-Python-Solutions
/python_find_the_runner_up_score.py
1,142
4
4
""" HACKERRANK FIND THE RUNNER UP SCORE URL: https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list/problem TASK: Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given n scores. Store them in a list and fi...
9bdb5c2fe74b8a35849cb7821786fbdea3c50495
Rolemodel01291/HackerRank-Python-Solutions
/python_nested_list.py
1,702
3.9375
4
""" HACKERRANK NESTED LIST URL: https://www.hackerrank.com/challenges/nested-list/problem TASK: Given the names and grades for each student in a Physics class of N students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. Note: If there are...
0bc906ba43c194a9a29110e57f5b23d1c12c6a9a
tharaniramesh/player2
/index_char.py
69
3.609375
4
s=input() d="" for i in range(0,len(s),3): d=d+s[i] print(d)
624970ae073636353570a48f6efbd4df4b7b66e2
Bobowski/TestRepo
/test.py
166
3.625
4
for i in range(10): print(i) print("Hello World!") class someClass_Name: def __init__(sel, a): self.a = a def foo(self): return self.a