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
4f02c2a17a40e4ec3fdc3031fa67e05fb57c9c54
jmstudyacc/Cisco_DevNet
/devasc/DevNet_Fundamentals/APIs/http_post_urllib.py
1,983
4.21875
4
""" A virtual library exists. You need query what the books are in the virtual library You've queried the books, but now it's time to ADD a book, how do? """ # Perhaps you cannot download other libraries and only have the standard Python library # You should then use the 'urllib' library that is native to Python impo...
e8f5519ad7b100d6e096dc33e58f8bf7bac2956f
jmstudyacc/Cisco_DevNet
/devasc/3_designing_software/singleton_example.py
1,302
4.15625
4
""" Singleton patterns are useful as they enable global access to an object, without creating a global variable. Globals may seem a neat way to resolve the issue, but they run the significant threat of being overridden. Other content may be erroneously stored in the GLOBAL variable causing unknown amounts of damage. T...
4c4e32936588c1a96f767faeaf73fa9c963be618
jmstudyacc/Cisco_DevNet
/devasc/3_designing_software/UserView.py
1,557
3.828125
4
import UserModel from UserController import SimpleController class UserView: def __init__(self): self.controller = SimpleController(self) # registering a strategy, the controller implementation # controller triggered - displays update def update_display(self, state, msg): # tightly coupled as ...
ef681cca4c7893c402d826b567953cda0d031ad0
jmstudyacc/Cisco_DevNet
/devasc/3_designing_software/playlist.py
1,310
4
4
# the SELF argument in Python classes refers to the current object instance that you are working on # it can be used to access the methods and state of that instance class Playlist: def __init__(self): self.tracklist = [] self._observers_list = [] # implementing the logic required to add a tr...
d9656c0be564add4a20780a034b742569f74354b
blutarche/someone-in-the-maze
/maze_algo.py
979
3.65625
4
from random import shuffle, randrange def make_maze(walk_limit, w=16, h=8): vis = [[0] * w + [1] for _ in range(h)] + [[1] * (w + 1)] ver = [["# "] * w + ['#'] for _ in range(h)] + [[]] hor = [["##"] * w + ['#'] for _ in range(h + 1)] def walk(x, y): vis[y][x] = 1 d = [(x - 1, y), (x, y + 1), (x + 1, y), ...
4585f39c8c3fe95ad22b531001ce71caa1e5c34f
XiaotongMeng/OR_OptwithGurobi
/tindor_dates/tindor_dates.py
13,210
3.96875
4
# coding=utf-8 from gurobipy import * def get_meeting_points_for_student(student, matches, meeting_point): """ function is returning all meetings points that a student has to visit :param student: the student for whom we want to get the meeting points :param matches: all matches that are given by the ...
4ed2f24f716fecaef51e372e81f36c52ff7e3983
grovesys/hello-world
/user-details.py
364
4.0625
4
name = input("What is your name: ") age = int(input("How old are you: ")) location = input("Where do you live: ") telephone = input("What is your telephone number: ") print ("Hi", name, "You are",age, "and you live in",location,"and we can call you on",telephone,".") # Things to address: # Whitespace before and after...
160a1796120e985e80a3ab3046caaf378ebf991a
OmarBandit/Proyecto-Python
/TablasDis.py
851
3.9375
4
int = [1, 0] print('Tabla de disyuncion') print('-'*30) print('p\tq\tr\tp v q') print('-'*30) for x in int: for y in int: print(x, y, x or y, sep = '\t') print() print('Tabla de conjuncion') print('-'*30) print('p\tq\tr\tp ^ q') print('-'*30) for x in int: for y in int: prin...
d1a2185923b90aeb48ad2c3e7d13713ed16af5af
DavidC117/David_Castillo_1560
/Lista_enlazada.py
2,278
3.796875
4
class Nodo: def __init__(self,value,siguiente = None): self.data = value self.next = siguiente #ADT Linked_List class Linked_List: def __init__ (self): self.head = None def is_empty (self): return self.head == None def get_tail (self): cur_nod...
92ed93a50de2d2dc6f956a507f2f41f388a89674
CyberWendy123/pythonCA
/mRandom.py
264
3.9375
4
# Ch 7: Modules (Aug 17, 2019) # via 2. Modules Python Random import random #import the random library # Create random_list below: rList = [random.randint(1, 101) for i in range(101)] # Create randomer_number below: r = random.choice(rList) # Print print(r)
6d7dae76ffc6a25dc5741e02c1a66789463129e3
CyberWendy123/pythonCA
/stringMethods.py
4,296
4.6875
5
# Ch 6: Strings (Aug 15) # String Methods # 2. Formatting Methods # .lower() - returns the string with all lowercase characters # .upper() - returns the string with all uppercase characters # .title() - returns the string in title case # aka the first letter of each word is capitalized # given: poem_title = "...
b64f043c12f1fd4689c41fd8f0c3aa9238fab29c
CyberWendy123/pythonCA
/projects/shipping.py
1,140
3.875
4
# based on Ch 3: Control Flow # by Wendy Xiao (Aug 11, 2019) from __future__ import division # cost of ground shipping def groundShipping(w): #where w = weight if w < 2 : return (1.50 * w) + 20 elif (w > 2) and (w <= 6): return (3 * w) + 20 elif (w > 6) and (w <= 10): return (4 * w) + 20 else: ret...
8a2195673cfb5ae3d4d2d865fa51727ef357f310
isarfarajahmad/Data-Structure-Python
/Search/binary_search_oops.py
465
3.8125
4
pos = 0 def search(arr, item): l = 0 u = len(arr) - 1 while l <= u: mid = (l+u) // 2 if arr[mid] == item: globals() ['pos'] = mid return True else: if arr[mid] < item: l = mid + 1 else: u = mid -1 ret...
9a7b75c650843ab4bf99a528c8588afac5a06f2f
rohitpawar4507/Zensar_Python
/File_Handling/Files.py
731
4.5
4
print("Creating a file for the first time.") #If you open a file in mode x , the file is created and opened for writing – but only if it doesn't already exist '''f1 = open("file1.txt","x") # create a new file print(f1) if f1: print("File created Successfully") else: print("The file is not created") ''' #...
10754746c14c3fce54d95a4b5e75cf81e457c1c7
rohitpawar4507/Zensar_Python
/Dicitionary.py
2,195
4.1875
4
''' Dictionary :: Collection of different element in key value pairs enclosed in {} seprated by comas It is mutable object . # Key -- value pair -- Both number and string are used for key as well as value ''' # Create a dicitionary print("The Program for Dictionary!!!") print("Creating a dictionary and adding eleme...
da0210641908a142375622b05233274c8d90926c
rohitpawar4507/Zensar_Python
/OOPS/Circele_method.py
681
4.1875
4
# Methods : It is regular function # Self : similar to this keyword in java. -> reference to the current object print("Creating a circle class..!") class Circle: def __init__(self): self.radius =1 def area(self): return 2*3.14*self.radius print("Creating the object...") c=Circle() print("Ra...
b22202f29c3b9aa502bc93e9b6bc8f8af84b8eab
rohitpawar4507/Zensar_Python
/OOPS/Circle.py
448
4.0625
4
# Creating class in python print("Let us learn Classes and Object !!:") class Circle: pass # Used -> To Execute Nothing / write nothing print("Circle class block finishied...") # Creating a object print("Creating a Object of class..") my_circle=Circle() # Object_name = Class Name # Creating a instance Variable...
ec802a7910298c721ae62a5e9f8b3c7ded1e445b
rohitpawar4507/Zensar_Python
/OOPS/Circle1.py
757
4.65625
5
# Creating class in python print("Let us learn Classes and Object !!:") class Circle: def __init__(self): self.radius=1 # Creating a object print("Creating a Object of class..") my_circle=Circle() # Object_name = Class Name print("Radius is ..:",my_circle.radius) print("Area of circle is :",2*3.14*my_circ...
490a3d103acac647eefc9d1a7a115266fd906a93
rohitpawar4507/Zensar_Python
/Exception_Handling/Exception2.py
936
4.28125
4
#finally block ''' try except finally first except block execute and then finally executed ''' try: print('Inside try block ') try: a = int(input('Enter no :')) b = int(input('Enter b :')) c = a / b print('a/b=%d' % c) except NameError: print('Except for inner try ')...
786c588ac09a3fbd37f5b35b2cd758e2f246c2f4
MAPSuio/MPC-V15
/birthday_minute/solution.py
1,307
3.78125
4
import math # This follows the reasoning for the original birthday problem # as presented at Harvard Stat 110 Lecture 3: # https://www.youtube.com/watch?v=LZ5Wergp_PA # The key insight is that it is much easier to # calculate the compliment of the event. def compliment_probability(minutes, people): # The compli...
6f8babcfcc3634651aa89f50caae6573c1e79e20
wilsonsujames/linear_regression
/diabete.py
2,323
4
4
import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model from sklearn.metrics import mean_squared_error, r2_score # Load the diabetes dataset #Ten baseline variables, age, sex, body mass index, average blood pressure, # and six blood serum measurements were obtained for eac...
247e6a3c62fc8d58b102d711534f3300591c89d8
tri2sing/PyFP
/higher_order_functions/generator_functions.py
494
3.890625
4
''' Created on Dec 22, 2015 @author: Sameer Adhikari ''' import math def first_match(predicate, collection): '''Apply the predicate to every value in the collection. Return the first_match value for which the predicate is true. ''' for x in collection: if predicate(x): return x def is_p...
5fb3169cff2fa78c90a8bb0ad0ac8ba23b21e689
tri2sing/PyFP
/higher_order_functions/min_max.py
1,362
4.3125
4
''' Created on Dec 19, 2015 @author: Sameer Adhikari ''' # Examples demonstrating the use of max and min as a higher-order function. def getx(point): x, y, z = point return x def gety(point): x, y, z = point return y def getz(point): x, y, z = point return z # The pattern in these points i...
b62ca503bb61cd4cbe5896d3992b5321fbdf20c5
tri2sing/PyFP
/conditionals/strict_ordering.py
658
4.0625
4
''' Created on Feb 10, 2016 @author: Sameer Adhikari ''' # An example of a function with strict ordering. def factorial_strict(n): if n == 0: return 1 elif n == 1: return 1 else: return factorial_strict(n - 1) * n # Same example with relaxation of strict ordering. # Dictio...
08cd6a1815bd9cc6557500934ea1c85af609aa29
RawnaKirahs/InternShip
/Day5_Tasks.py
772
4.34375
4
TASKS : 1)Create a function getting two integer inputs from user. & print the following: Addition of two numbers is +value Subtraction of two numbers is +value Division of two numbers is +value Multiplication of two numbers is +value 2. Create a function covid( ) & it should accept patient name, and b...
4c36aee67ef89ce476a9762a68d387d43af86353
alexro/pypypy
/MosOlymp/test.py
221
3.609375
4
g = { 1: { 2: { 3: None, 4: None }, 5: None } } def walk(g): if g is None: return for key in g: walk(g[key]) print(key) walk(g)
dd7bddf960e50dbe31618d995bdb8550677d9fbb
alexro/pypypy
/code_forces/1180A.py
241
3.546875
4
def find(n): a = [0] * (n + 1) a[1] = 1 for k in range(2, n + 1): a[k] = k * k + (k - 1) * (k - 1) return a[n] def main(): n = int(input()) k = find(n) print(k) def test(): print(find(3)) main()
7555414bf4c8cb2915c5792fb630831ee35c26c3
LawrenceScroggs/School_Python
/student_LScroggs.py
795
3.953125
4
#File:student_LScroggs.py #Description: Finding out if a student is in CS160 #Author: Lawrence Scroggs #Date: 10/15/17 #Compiler: Python 3.6.2 #While testing could not figure out how to exclude integers as invalid #forgot to add exit print("SEARCH FOR A STUDENT""\n\n") student = input("What is the first and las...
f9376e897f65aa9a9e016e3d8bee3e00806a6f1b
kirillanswer/Import.-Modules-packages-import
/module13rot.py
2,685
4.0625
4
# Шахов # кирилл # Задание - На основе кода с выполнением предыдущего задания # реализуйте получение JSON с удаленного хоста и красивый вывод информации на экран. def rot13 ( s ): "" " сдвиг на нужную позицию (тут на 13) " "" result = " " для v в s: c = ord (v) если c > = ord ( ' a '...
0c45d253a9abf140765f6bda3d18ca9c4f61cc65
EshaanDhavala/cryptoquote
/getAuthorAndQuoteCount.py
1,795
3.671875
4
#Program for generating the Crypto Quote #1. Class for representing a single QUOTE # id, quote, author, submitted_by # _repr__ and __str__ class Quote: def __init__(self, id, quote, author, submitted_by): self.id = id self.quote = quote self.author = author self.subm...
d8464499d1aa7f4d7c547f9416f1e780fef79e02
fsbs2/Python
/quadrado.py
140
4
4
x=int(input("Digite o valor correspondente ao lado de um quadrado:")) area=x*x perimetro=4*x print("perímetro:",perimetro,"- área:",area)
2b3da5473fed01670dd51703d388398e2595e262
fsbs2/Python
/maior_primo.py
411
3.59375
4
def ehPrimo(num): divisores = 0 i = 1 while i <= num: if num % i == 0 : divisores = divisores + 1 i = i + 1 if divisores == 2: return True else: return False def maior_primo(x): sent=True y=0 while sent: if ehPrimo(x): y =...
ec76675009e34f2c55f734520399de43d6891acf
rdrabek24/Python-Fundation
/exercicios/ex_aula02c.py
690
3.984375
4
def somar(valor1, valor2): return valor1 + valor2 def subtrair(valor1, valor2): return valor1 - valor2 def dividir(valor1, valor2): return valor1 / valor2 def multiplicar(valor1, valor2): return valor1 * valor2 entrada1 = int(input('Valor 1 = ')) entrada2 = int(input('Valor 2 = ')) res_soma = so...
9baa9330fb6849d65e53b1d9ac94aa3b4ed51f64
ricobafica/pdsnd_github
/bikeshare.py
9,576
4.40625
4
""" This python code provide the following information by exploring US Bikeshare Data from Chicago, New York City and Washington: 1- Popular times of travel (i.e., occurs most often in the start time) most common month most common day of week most common hour of day 2- Popular stations a...
ac9220b8923447115addfb2805a1da7802ca5975
rythm-gade/Home-Prices
/HomePrices/volatility.py
2,270
3.59375
4
""" File: volatility.py Author: Rythm Gade """ from indexTools import * from math import * def average(nums): """ Returns average of given dataset :param nums: list of float values :return: average """ sum = 0 for i in nums: sum += i avg = sum/len(nums) ...
63cbbb1bc4da7e3bdd972e3ed32030e42af5875f
HariKumarValluru/Python
/ContinueBreakElse/continueBreak.py
955
4.25
4
# Continue example # shoppingList = ['milk', 'pasta', 'eggs', 'spam', 'bread', 'rice'] # for item in shoppingList: # if item == 'spam': # continue # print('Buy '+item) # Break example 1 # # shoppingList = ['milk', 'pasta', 'eggs', 'spam', 'bread', 'rice'] # for item in shoppingList: # if item == '...
65493879c1ae2d2db0e3aae4e540d7187abbbbe9
MulengaKangwa/Hello-world
/72AccessingTheGlobalVariable.py
212
3.734375
4
x=123 # This is a global variable. def display(): x=678 #This is a local method print(x) print(globals()['x']) #Use the globals function and the global variable will be displayed print (x) display()
8e680d28d172f63eccbb5315a73050ab850e19d1
FreeTen1/Ship_fight
/classes.py
4,316
3.796875
4
class Ship: def __init__(self, length, row_col): """Создание корабля. length - длинна, row - строка, col - столбец""" self.row = row_col[0] self.col = row_col[1] self.length = length class Desk: def __init__(self): """Создание пустого поля и пустого списка кораблей на п...
44eebe89676adb3384af969fb3a37dd564e1c809
simacna/Project_Euler
/problem25.py
944
3.71875
4
# #1, 1, 2, 3, 5, 8 # from datetime import datetime import time # def fib(n): # if n > 1: # return () # print(fib(3)) # gen = (x for x in range(3)) # print(type(gen)) # # for idx in gen: # # print(idx) # li = [x for x in range(3)] # # for _ in li: # # print(_) # start = time.clock() # print('yo') # def ...
77aeb269d916436a634d8c993d46e4c4a44cc09c
desh-woes/Project-Twitter
/Understanding Tweepy/Hello Tweepy.py
738
3.703125
4
""" This example will download your home timeline tweets and print each one of their texts to the console. Twitter requires all requests to use OAuth for authentication. """ import tweepy # Twitter app Credentials # Consumer API Keys consumer_key = " " consumer_secret = "" # Access token and secret access_token = " "...
94746ca73b7a777490d47da9cc1ab879a2efe63f
PauliSpin/HintsAndTips
/fstrings.py
330
4.125
4
name = 'Rashmi' age = 57 print("Hello my name is", name, "and I am", age, "years old") print("Hello my name is " + name + " and I am " + str(age) + " years old") st = f'Hello my name is {name} and I am {age + 10} years old' print(st) # Capital f makes no difference st = F'Hello my name is {name} and I am {age + 10} y...
dc4f94d6ca74c5501bb2abacbcd74db10633c54d
PauliSpin/HintsAndTips
/unpack.py
743
4.65625
5
x = [1, 2, 3, 4, 5] print(*x) # prints 1 2 3 4 5 # * is theunpack operator and print(*x) prints unpack and prints out the elements of the list # This is used in arguments to functions and can be used # to pass an unlimited number of arguments def func(*args): print(args) func(2, 3) # prints the tup...
326d794e08c0a6cd5d25a2b73db06d665c046d33
PauliSpin/HintsAndTips
/multi assignments.py
297
3.875
4
x, y = 3, 4 print(x, y) # prints '3 4' # Can Decompose tuples x, y, z = (4, 5, 6) print('Decompose tuple') print(f'x = {x}') print(f'y = {y}') print(f'z = {z}') # Also works with lists print() print('Decompose List') x, y, z = [6, 7, 8] print(f'x = {x}') print(f'y = {y}') print(f'z = {z}')
f375711cec2b2e89409d50dc65218424ac7745d8
PauliSpin/HintsAndTips
/ClassAndStaticMethods.py
812
3.671875
4
import sys class Employee: num_of_emps = 0 raise_amount = 1.04 # Class Variable def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last + '@company.com' Employee.num_of_emps += 1 def fullname(...
c573cbd73f3232f5d24dc9a25f8f8a1425a8826c
RedSparx/Introduction-to-AI
/Lab2/L2_EX2_Generate_2D_Data.py
3,316
4.03125
4
"""LABORATORY 2 EXERCISE #2: Synthesize Random 2D Test Data. (a) Write a function that will generate a set of Gaussian random vectors with a a dictionary as input with parameters mean, variance, and size. (b) Generate several different sets of random vectors. (c) Make a scatter plot of the vect...
959009b8c4e35f1b2061d1dad7c9a7734b1508fe
RedSparx/Introduction-to-AI
/Lab3/L3_EX2_Model_Fitting.py
3,663
4.25
4
"""LABORATORY 3 EXERCISE #2: Given a data set, find the best fit model and make a prediction based on it. (a) Perform regression modeling of data against several models: (i)y=a*sin(x)+b,(ii)ln(y)=m*ln(x)+b,(iii)y=ax^3+b*x^2+c (b) Plot all three models with the data. (c) Compute residuals for each model....
977f3d8a84ec62be12d04024e5f6f41116c2c9dd
RedSparx/Introduction-to-AI
/Lab2/L2_EX1_Embedded_Signal.py
1,497
3.75
4
"""LABORATORY 2 EXERCISE #1: Find a signal embedded in noise. (a) Read data from a file and process the stream in frames. (b) Using a sliding frame, compute a closeness score between the frame and a stored signal. (c) Determine the index within the data set that contains the start of the signal. """ ...
e1c2eefb02a1cbdd317e4c874d5af7782a1ccc48
sungwoncho94/SWexpert
/homeworkshop/day_06homeworkshop.py
830
4.59375
5
# workshop ''' class Circle: pi = 3.14 x = y = r = 0 # __init__ : 생성될 때, self.변수 = 변수 로 지정해준다 # self, r, x, y는 인스턴스가 생성될 때 필수로 필요한 변수들 -> 생성될 때 값을 지정해줘야함. def __init__(self, r, x, y): self.r = r self.x = x self.y = y def area(self): return self.pi * self.r * self.r ...
d8f006f6cb997c7ca6f59aa9e3e1f63e73de9668
sungwoncho94/SWexpert
/homeworkshop/day_04workshop.py
833
3.875
4
# x = int(input()) # x = 8 l = 2, u = 3 # for n in range(1, x+1): # while n ** 2 <= x: # n += 1 # lower_num = n - 1 # upper_num = n # print(lower_num, upper_num) # while upper_num - lower_num >= 0.001: # new_num = (upper_num + lower_num) / 2 # if new_num ** 2 > x: # u...
cf6908ab853cb4a901c77153dd47c9c3ff7ad2a2
sungwoncho94/SWexpert
/intermediate/day_14/1244최대상금.py
2,777
3.796875
4
import copy def make_num(num_list): global num_num str_num = '' for i in num_list: str_num += str(i) num_num = int(str_num) return num_num T = int(input()) for t in range(1, T+1): temp_list = list(map(str, input().split())) str_num, change = temp_list[0], int(temp_list[1]) ...
edd5b623c8b8c04994cc5b5a41fb88de9068e6af
ayazwani/tasksrepo
/inher2.py
319
3.578125
4
class parent1(): """docstring for parent1""" def fun1(self): print("this is parent 1") class parent2(object): """docstring for parent2""" def fun2(self): print("this is parent 2") class child(parent1,parent2): def fun3(self): print("this is child class") ob = child() ob.fun1() ob.fun2() ob.fun3()
73d3a312d44a3eef9b9a954188a78c3e8b420d51
gabee1987/Python_basic_exercises
/1_12/main_1_12.py
2,118
3.953125
4
import basics_1_to_12 def main(): result_max = basics_1_to_12.maximum(2, 6) print("result_max: %s" % result_max) result_max_3 = basics_1_to_12.maximum_of_three(10, -5, 32) print("result_max_3: %s" % result_max_3) result_max_list = basics_1_to_12.max_of_list([3, 5, 9, 12, 45]) print("result_m...
4bdade0d95c6ad223e20916e8528fd09bcce7abc
seoljeongwoo/learn
/algorithm/BOJ_10996.py
340
3.953125
4
N = int(input()) if N==1: print('*') exit(0) for i in range(2*N): if i%2 == 0: for j in range(N): if j%2 == 0: print('*',end="") else : print(' ',end="") else: for j in range(N): if j%2 == 0: print(' ',end="") else: print('*',...
900ab82cd9b0bc4757863a3674b9e4f5481ef9c7
shenoyaditya11/Dice-game-Pygame
/dice.py
5,044
3.859375
4
#!usr/bin/python import pygame import random pygame.init() pygame.font.init() user=0 comp=0 userScore=0 compScore=0 quit= False clock= pygame.time.Clock() dispWidth=810 dispHeight=600 image=None gameEnd= False text_show= "Play!" end_text="" waiting= False #display mode py_display= pygame.display.set_mode((dispWidth,...
dd441b3f9a1a0f0c330a32076aa77d87e2e05681
Junseok0211/FootballLover
/test.py
143
3.53125
4
test = [] print('test') for i in range(10): test.append(i) print('바보') for i in test: print('test[' + i + '] = : ' + test[i])
9f2b6a2316ecb4dc8e4ea5e2974c783d5c9d720a
umasood12/python
/dictionary.py
259
3.890625
4
import json data = json.load(open("data.json")) def translate(word): word = word.lower() if word in data: return data[word] else: return("This word does not exist") word = input("Enter word: ") print(translate(word))
643bee9275ad2f4187f083e8d40f0b78378d4872
patelrohan750/python_tutorials_codewithharry
/python_tutorials_code/tut21_operators.py
871
4.59375
5
# operators in python # Arithmetic Operator # Assignment Operator # Comparision Operator # Logical Operator # Identity Operator # Membership Operator # Bitwise Operator # Arithmetic Operator # print("5 + 2 is ",5+2) # print("5 - 2 is ",5-2) # print("5 * 2 is ",5*2) # print("5 ** 3 is ",5**3) # print("5 /...
22a55344060e289a52f60efbc46a30c83d2c8dbf
patelrohan750/python_tutorials_codewithharry
/python_tutorials_code/tut11_example_Apni_dictonary.py
279
4.25
4
# Exrersice:1 # create a dictionary and take input from user and return the meaning of taht word in dictonary dict = {"A": "Apple", "B": "Ball", "C": "Cat", "D": "Dog", "E": "Elephant"} search = input("Enter Word: ") print(f'your word meaning is: {dict[search.upper()]}')
84f68950eaa5849ef7d98001d9922f24f0d0b05b
patelrohan750/python_tutorials_codewithharry
/python_tutorials_code/tut40_Example_snak_water_Gun.py
1,885
3.8125
4
# Snake,Water,Gun # 10times import random game_list = ["Snake", "Water", "Gun"] n = 0 cpu = 0 user = 0 print("\n\t\t\t\t\t\t\t\t\t\t\t Snake-Water-Gun Game\n") while n < 10: user_choice = input("Press S For Snake,W for water,G for Gun: ") cpu_choice = random.choice(game_list) if user_choice.upp...
22244034ec54bd141fd47ca604923b2a8e920e08
patelrohan750/python_tutorials_codewithharry
/python_tutorials_code/tut28_writing_and_appending.py
355
3.5625
4
# f=open("tut28_test.txt","w") # f.write("hello friends how are you!!!!!!!!") # f.close() # f=open("tut28_test.txt","a") # f.write("hello friends how are you\n") # f.close() # read and write both using f=open("tut28_test.txt","r+") print(f.read()) f.write("hello friends\n") f.write("love coding\n") f.w...
7a03a8e59acef6c4e4622f53c8969779e876c84b
Franklin-Wind/piano
/solve_xml.py
728
3.640625
4
#coding=utf-8 import os import zipfile def un_zip(file_name): """unzip zip file""" zip_file = zipfile.ZipFile(file_name) ''' if os.path.isdir(file_name.split(".")[0]): pass else: os.mkdir(file_name.split(".")[0]) ''' for names in zip_file.namelist(): zip...
762bac60a64a2456d02e775b8277912a2661d5ed
farouklee/python-nation
/stack.py
1,440
4.09375
4
class stack: def __init__(self): self.stacker=[] def isempty(self): return self.stacker==[] def push(self, item): self.stacker.insert(0, item) def pop(self): return self.stacker.pop(0) def peek(self): return self.stacker[0] def size(se...
12d4951b82f2b1abac1ccfd9d88f7486fb9f29be
a-falcone/puzzles
/adventofcode/2021/05a.py
2,580
4.40625
4
#!/usr/bin/env python3 """ --- Day 5: Hydrothermal Venture --- You come across a field of hydrothermal vents on the ocean floor! These vents constantly produce large, opaque clouds, so it would be best to avoid them if possible. They tend to form in lines; the submarine helpfully produces a list of nearby lines of ve...
608ec6e9a067217d612acfe719268b48139be203
a-falcone/puzzles
/adventofcode/2021/23a.py
4,267
4.21875
4
#!/usr/bin/env python3 """ --- Day 23: Amphipod --- A group of amphipods notice your fancy submarine and flag you down. "With such an impressive shell," one amphipod says, "surely you can help us with a question that has stumped our best scientists." They go on to explain that a group of timid, stubborn amphipods liv...
fc4a46a34af03432d3da8db0eb6eb2935a201a63
a-falcone/puzzles
/adventofcode/2019/19a.py
6,673
4.125
4
#!/usr/bin/env python3 """ --- Day 19: Tractor Beam --- Unsure of the state of Santa's ship, you borrowed the tractor beam technology from Triton. Time to test it out. When you're safely away from anything else, you activate the tractor beam, but nothing happens. It's hard to tell whether it's working if there's noth...
bfd928849835f0eabb12e29d478d4fd43a106ced
a-falcone/puzzles
/adventofcode/2018/07b.py
5,953
4.1875
4
#!/usr/local/bin/python3 """ --- Day 7: The Sum of Its Parts --- You find yourself standing on a snow-covered coastline; apparently, you landed a little off course. The region is too hilly to see the North Pole from here, but you do spot some Elves that seem to be trying to unpack something that washed ashore. It's qu...
19ea968f9169210de937762ee53489ddd442a20c
a-falcone/puzzles
/adventofcode/2021/12a.py
3,691
4.375
4
#!/usr/bin/env python3 """ --- Day 12: Passage Pathing --- With your submarine's subterranean subsystems subsisting suboptimally, the only way you're getting out of this cave anytime soon is by finding a path yourself. Not just a path - the only way to know if you've found the best path is to find all of them. Fortun...
b9d5d63401b2287c7aaa6865ecd6e68e910e1034
a-falcone/puzzles
/adventofcode/2020/21b.py
3,809
3.59375
4
#!/usr/bin/env pypy3 """ --- Day 21: Allergen Assessment --- You reach the train's last stop and the closest you can get to your vacation island without getting wet. There aren't even any boats here, but nothing can stop you now: you build a raft. You just need a few days' worth of food for your journey. You don't sp...
fa7fa6b8a050f04e59f27186d930386c3f7eef12
a-falcone/puzzles
/adventofcode/2022/08b.py
5,168
4.125
4
#!/usr/bin/env pypy3 """ --- Day 8: Treetop Tree House --- The expedition comes across a peculiar patch of tall trees all planted carefully in a grid. The Elves explain that a previous expedition planted these trees as a reforestation effort. Now, they're curious if this would be a good location for a tree house. Fir...
aa46d0f91d883a1b316a74b286ff256b2a0a0dba
a-falcone/puzzles
/adventofcode/2019/04b.py
1,781
4.21875
4
#!/usr/bin/env python3 """ You arrive at the Venus fuel depot only to discover it's protected by a password. The Elves had written the password on a sticky note, but someone threw it out. However, they do remember a few key facts about the password: It is a six-digit number. The value is within the range given in yo...
efdc15d9d162b6a524aa53652fc4ad05cd84a4ca
a-falcone/puzzles
/adventofcode/2021/08b.py
8,319
3.796875
4
#!/usr/bin/env python3 """ --- Day 8: Seven Segment Search --- You barely reach the safety of the cave when the whale smashes into the cave mouth, collapsing it. Sensors indicate another exit to this cave at a much greater depth, so you have no choice but to press on. As your submarine slowly makes its way through th...
f307e941987f08016880d058d8f688554af2f117
a-falcone/puzzles
/adventofcode/2022/20a.py
2,628
3.5
4
#!/usr/bin/env pypy3 """ --- Day 20: Grove Positioning System --- It's finally time to meet back up with the Elves. When you try to contact them, however, you get no reply. Perhaps you're out of range? You know they're headed to the grove where the star fruit grows, so if you can figure out where that is, you should ...
1950d6496916624f149a8875aaabe256936feab3
M4theus1/Tabuada-v.1
/tabuada.py
234
3.84375
4
n = int(input('Digite um número para ver sua tabuada: ')) cont = 0 print('=' * 18) print('Tabuada do {}'.format(n)) print('=' * 18) while(cont <= 10): print('{} x {} = {}'.format(n, cont, (n * cont))) cont = cont + 1
921e108a26fba876a59d4af371dffdaaaa971d5b
jorvis/AdventOfCode
/2015/day_09_both.py
2,023
3.828125
4
#!/usr/bin/env python3 """ This one is just the traveling salesman problem. I don't think it's in the spirit of the challenge to use existing code, and I haven't the time or expertise to quickly implement an efficient solution that will scale. So, brute force it is. """ distances = dict() cities = list() shortest_pa...
9fcd0c3e42f5301f69993e2530065e2dda9722d4
rawg/levis
/levis/util/hilbert.py
2,251
4.125
4
""" Utilities to map between a 1D Hilbert curve and 2D Euclidian space. See also: - https://en.wikipedia.org/wiki/Hilbert_curve - https://people.sc.fsu.edu/~jburkardt/py_src/hilbert_curve/hilbert_curve.html - https://en.wikipedia.org/wiki/Moore_curve """ from __future__ import division #from builtins import object im...
a2ef075616b8bad4f60045ddda5e00e65161e4c6
vdduong/numerical-computation
/maze_walk.py
1,197
4.40625
4
# maze walking # 0: empty cell # 1: unreacheable cell e.g. wall # 2: ending cell # 3: visited cell grid = [[0, 0, 0, 0, 0, 1],\ [1, 1, 0, 0, 0, 1],\ [0, 0, 0, 1, 0, 0],\ [0, 1, 1, 0, 0, 1],\ [0, 1, 0, 0, 1, 0],\ [0, 1, 0, 0, 0, 2]] # the search function accepts the coordinates...
5ad8073abbff41b8a0f8611b5eb937dc132bafa5
cmaliwal/encryption-In-Python
/encrption_using_ord_and_char.py
249
4.28125
4
#encryption using ord() and char() message = raw_input ("Enter a message to encrypt: ").upper() encrypted = "" for letter in message : if letter == " ": encrypted += " " else: encrypted += chr(ord(letter)+5) print (encrypted)
e7f5f659eae9c2419c467c6de270a80d7dac9529
Atheas/ProjectEuler
/002 - M.py
444
3.65625
4
# Project Euler - Problem 2 # I think it works. n1 = 1 n2 = 2 temp = 0 total_even = 0 def fibonacci(n1, n2): global total_even temp = n1 + n2 if n2 % 2 == 0: total_even += n2 n1 = n2 n2 = temp return temp, n1, n2 def call(n1, n2, temp): while temp < (4*10*...
cab0d6a59b98faa443219954a287952f06160874
FahimSifnatul/online_problem_solving_with_FahimSifnatul_python_version
/cf 483 div 2 C.py
455
3.5
4
from math import gcd t = int(input()) while t: t -= 1 n,d,b = map(int,input().split()) d //= gcd(n,d) while True: g = gcd(d,b) if g == 1: if d > 1: stdout.write('Infinite\n') else: ...
ee12bd731b1cb79c4f97b236559bc96501d1d16c
FahimSifnatul/online_problem_solving_with_FahimSifnatul_python_version
/cf 613 div 2 C.py
345
3.71875
4
from math import sqrt, gcd class LCM: lcm = 0 def ab(self): n = int(sqrt(self.lcm)) + 1 for a in range(n, 0, -1): if not self.lcm % a: b = self.lcm // a if gcd(a, b) == 1: print(a, b) return 0 def main(): solve = LCM() solve.lcm = int(input()) ...
55801b0b765404c47a132d92ccaaf14196cd1313
raghakot/project_euler
/0-50/5.py
727
3.90625
4
from collections import Counter from utils import timeit, prime_factorize @timeit def evenly_divisible(n): """ Idea: - Find factors of numbers 1 to n. Use DP to cache results bottom up. - Amongst all factors, we have to include max counts of prime factors. - For example, in in 1 .. 10, 2 has to be...
668db931429533aaa9c3ad162e0015825e277f70
raghakot/project_euler
/0-50/4.py
643
3.90625
4
from utils import timeit def is_pal(num): return str(num) == str(num)[::-1] @timeit def largest_pal(digits): lower = 10**(digits-1) upper = 10**digits - 1 best = lower * lower + 1 for n1 in range(upper, lower-1, -1): for n2 in range(n1, lower-1, -1): num = n1 * n2 ...
2cbbc1f1cc3587d040ac1fbb9f44ac0dfc0d0024
FilibertoCastagna/ProgettoAPI2020_GeneratoreTest
/generatore.py
4,211
3.578125
4
#!/usr/bin/env python3 from random import choice ''' Precisazione: Nei commenti, viene chiamato "file" l'insieme delle linee di testo che l'editor produce, a prescindere dalla struttura dati utilizzata ''' # Costanti MAXLEN = 1024 letters = ['c', 'd', 'p', 'u', 'r'] ''' Maxfilelen è una lista che tiene traccia conti...
7d76ac3e4b78379fa3466fe803589f9028321dbb
hoi-nx/Python_Core
/Helloworld/Helloworld.py
70
3.984375
4
print("Name: Nguyễn Xuân Hội") x=5 y=8 z=x+y print("{0}+{1}={2}".format(x,y,z))
5a54a683b763f4094cc7d0d71f098268a4f36389
bpandey-CS/Algorithm
/insertion_sort.py
588
3.96875
4
from datetime import datetime def insert_sort(array: list): """ :array - list that needs to be sorted in ascending order """ n = len(array) for j in range(1, n): i = j-1 # insert array[j] into sorted sequence betwwen [1, .. j-1] key = array[j] while(i>=0 and arra...
a4bbc4ba717dde5b315134ef288798ef509e5533
bpandey-CS/Algorithm
/minion.py
2,506
3.765625
4
""" Kevin and Stuart want to play the 'The Minion Game'. Game Rules Both players are given the same string, . Both players have to make substrings using the letters of the string . Stuart has to make words starting with consonants. Kevin has to make words starting with vowels. The game ends when both players have mad...
eb3c43de6292c846f47a398631b05d51ee758872
bpandey-CS/Algorithm
/datastructures/left_view.py
848
4.0625
4
""" left view of a binary tree 1 2 3 --> 1 2 1 2 3 6 --> 1 2 6 """ from tree import TreeNode, inorder maxlevel = 0 def left_view(root, level): # in a way we will be going pre # root left and right if left is null # at each level print only once global maxlevel if r...
30448a7b4f868d52f1cb67b668d55bb1a1cc77f3
bpandey-CS/Algorithm
/problem-solving7.py
529
4.1875
4
# For a given sentence, return the average word length. # Note: Remember to remove punctuation first. def average_word_length(sentence: str): # remove the punctuation fromt he sentences unlikable_chars = ['!','.','?', "'", ",", ";", "."] for uc in unlikable_chars: sentence.replace(uc,'') len_o...
b5dfe2e2323b8191938dd75878fa05381d70d92d
michaelrausch/One-Time-Pad
/onetimepad.py
5,925
3.703125
4
#!/usr/bin/env python """ Simple One Time Pad Library Run this file, or call test() to run tests. Usage in main() """ __author__ = "Michael Rausch" __version__ = "1.0" __email__ = "me@michaelrausch.nz" __status__ = "Alpha" import unittest class OneTimePadTest(unittest.TestCase): def test_alphabet_values(self...
38d1bdc8390687204d195c2d3c5bfce326d4418a
YasiChen/projectpd
/MatplotlibPra.py
3,165
3.765625
4
# this project is for the practice of matplotlib import matplotlib.pyplot as plt import numpy as np import pandas as pd x=[1,2,3,4,5] y=[2,4,6,8,10] # resize the graph plt.figure(figsize=(5,3)) # basic graph plt.plot([1,2,3,4,5],[2,4,6,8,10],label='2x',marker=".", markersize=10) # fmt='[color][marker][line]' # doin...
8c5ba4d17e84954f15ac79428780fd2939f6e649
Shaunwei/shua-shua-shua
/others/email_range.py
1,822
3.515625
4
import heapq class Solution: def __init__(self): pass def solve1(self, input_): ''' Heap Sort ''' pairs_heap = self.build_heap(input_) rets = [] if not pairs_heap: return rets cur_st, cur_ed = heapq.heappop(pairs_heap) while...
ffc4a476d4d384c11b4f3cf15bccb259c91c257b
reidalderson/bioinformatics
/code/search_proteome.py
22,176
3.53125
4
class Proteome(object): """ Search for motifs within proteomes and compare the observed vs. expected motif frequencies.""" def __init__(self): """ Store the amino acids in single-letter format for later use """ self.amino_acids = ['A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L...
71a652032cedf5dd889990cd89bad96b82f0be93
valmsmith39a/u-data-structures-algorithms
/p1-text-calls/Task3.py
5,111
4.1875
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 3: (080) is the area code for fixe...
038fdd194d209b5c867b3388536d9f4db73b34b8
valmsmith39a/u-data-structures-algorithms
/tries.py
2,188
4.125
4
""" Trie: Type of Tree Spell check: word is valid or not One solution is hashmap of all known words O(1) to see if the word exists, but O(n * m) space n: number of words m: length of the word Trie: decrease memory usage, improve time performance """ basic_trie = { 'a': { 'd': { 'd': { ...
ca80be00e5f8b0a709c7c5f4f7df1625c842b78e
MohamedFawzy/course4
/week2/emails-demo.py
732
3.5
4
import sqlite3 conn = sqlite3.connect('emaildb.sqlite') cur = conn.cursor() cur.execute(''' DROP TABLE IF EXISTS counts''') cur.execute(''' CREATE TABLE counts(email TEXT, count INTEGER) ''') fname = raw_input('Enter file name: ') if(len(fname) < 1): fname = 'mbox-short.txt' fh = open(fname) for line in fh: ...
fb5ddcea11c5d3b82d39f7b2da665a770f281273
16sheep/UdacityND1
/Code_your_own_quiz.py
6,513
4.4375
4
import textwrap # -*- coding: utf-8 -*- introduction = "This is a quiz based on Python concepts. \ You can choose between 3 levels of difficulty: \ easy, medium and hard,\ Each of them includes 4 gaps to fill, you can choose \ how many times per gap you c...
d53c19d4439c5fa36837d65406d5ae71a759efc0
matbc92/Random-Things
/BP earning calculation.py
1,685
3.828125
4
# calculador de numero de battle points ganhos no battle maison do pokemon ORAS. # O número de battle points ganhos começa em dois por batalha venida e aumenta em 1 por batalha a cada dez vitorias, # e há uma excessão na batalha de numero 50 que da uma recompensa de 50 battle points ao ser vencida, # a partir de 7 pont...
00597ae6f9cad152fa3a76d94a66030445b4bb64
liumengjun/script-exercise
/py/np_demo/example_plt.py
279
3.546875
4
import numpy as np import matplotlib.pyplot as plt a = 1 def x(t): return a*(2*np.cos(t)-np.cos(2*t)); def y(t): return a*(2*np.sin(t)-np.sin(2*t)) xs = np.fromfunction(x,(300,),dtype=float) ys = np.fromfunction(y,(300,),dtype=float) plt.plot(xs,ys,'r.') plt.show()
f6dd1a7f7b90b36406d9d136279d50b3fa93575f
liumengjun/script-exercise
/py/random_red_package.py
1,136
4.125
4
import random ''' # 微信或支付宝,随机红包(拼手气红包)算法 ''' def random_red_package(total: float, num: int): if total * 100 < num: raise Exception("total is too small") if num == 1: yield total else: # total * 100, unit is fen of RMB。each one has 1 fen at least rest = total * 100 fo...
e396a0d7ebe8df0a97f9f3243811bf9ce439a146
brekelma/dsbox_corex
/dsbox_corex/echo_regression/echo_regression.py
8,393
3.515625
4
""" Echo Regression Sparse linear regression that bounds the information capacity of the learned model using an Echo compression channel. Code is in the style of scikit-learn. Code below by: Greg Ver Steeg (gregv@isi.edu), 2018. """ import numpy as np from scipy import linalg from sklearn.linear_model.base import Lin...