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 |
|---|---|---|---|---|---|---|
81a8da064afb686af81277a2d63b1b25d31b9fb8 | alexanderturinske/chef-scheduler | /chef.py | 1,064 | 3.671875 | 4 | class Const:
SUN = 0
MON = 1
TUES = 2
WED = 3
THURS = 4
DAYS = [SUN, MON, TUES, WED, THURS]
class Chef:
days_in_week = 5
def __init__(self, name, unavailable=[], since=6, times=0):
self.name = name
self.unavailable = unavailable
self.since = since
self.... |
ec2ae4d1db1811fcca703d6a35ddf1732e481e2a | riteshrai11786/python-learning | /InsertionSort.py | 1,600 | 4.40625 | 4 | # My python practice programs
# function for sorting the list of integers
def insertion_sort(L):
# Loop over the list and sort it through insertion algo
for index in range(1, len(L)):
# define key, which is the current element we are using for sorting
key = L[index]
# Move elements of a... |
b26f89c4ea3913caa3c538f8f8fa0405f21a5122 | walkerlangley/google-foobar | /Challenge-1/1.py | 650 | 3.53125 | 4 | def solution(x,y):
if len(x) > len(y):
longest = sorted(x, key=lambda x: int(x))
shortest = sorted(y, key=lambda x: int(x))
else:
longest = sorted(y)
shortest = sorted(x)
for i, x in enumerate(longest):
yval = shortest[i]
if yval == x:
continue
... |
75f392b1741856a675d633b922321c6d9f713394 | andrewstuart/data-science-from-scratch | /mycode/vector.py | 1,058 | 4.09375 | 4 | def v_add(v, w):
"""Add two vectors
:v: List 2
:w: List 1
:returns: A new vector
"""
if len(v) != len(w):
raise Exception('Illegal vector addition')
return [vi + wi
for vi, wi in zip(v, w)]
def v_sub(v, w):
"""Subtracts two vectors
:v: List 1
:w: List 2
... |
ca2a4f8ef3d6c1c0161711b3bb51443fdf77d3bc | jjyynn/practice | /leetcode_#2.py | 722 | 3.65625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
#l1과 l2가 linked list가 아니라 list 일때 가능한 solution
# In[1]:
def twosum(l1,l2):
a_list = []
b_list = []
return_list = []
for i in l1 :
a = i * (10 ** int(l1.index(i)))
a_list.append(a)
a_sum = sum(a_list)
for ii in l2 ... |
6eac0ed7e5d7f881942d5443a0a2a6ad3dd63754 | Bikram-Gyawali/pythonprojectsdaily | /passwordgenerator/passwordgenerator.py | 586 | 3.953125 | 4 | import string
import random
characters=list(string.ascii_letters+string.digits+"!@#$%^&*()")
def generateRandomPassword():
# take length of pasword from user
length=int(input("Enter the length of the passoword:_"))
# suffle the characters taken above
random.shuffle(characters)
# pick random char... |
77e71c7795ae58d92f40241943a739022f9f1b5e | ShaderLight/dice-visual | /generate_die.py | 293 | 3.5625 | 4 | from die import Die
def generate_die(die_num, msg_3):
die_num = int(die_num)
dielist=[]
for num in range(1, die_num+1):
d_value = input(msg_3 + str(num)+" ")
d_value = int(d_value)
dice = Die(d_value)
dielist.append(dice)
return dielist
|
2b92d6cee00cc125ef1052da9e31414d7a9bb41b | jingmouren/coral-ordinal | /coral_ordinal/loss.py | 3,780 | 3.625 | 4 | import tensorflow as tf
#import tensorflow.python.ops as ops
import numpy as np
# The outer function is a constructor to create a loss function using a certain number of classes.
class OrdinalCrossEntropy(tf.keras.losses.Loss):
def __init__(self,
num_classes,
importance_weights = Non... |
484d4c31ca2bb09f86c481e51480f93ff87cb627 | anudeike/PreSave | /genData.py | 2,317 | 3.609375 | 4 | import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
np.random.seed(7)
def generatePrices(n, vol=0.06, init_price=10):
prices = [init_price]
for x in range(1,n):
rnd = np.random.rand()
vol = 0.02
old_price = prices[x-1]
change_percent = ... |
ad2a9e7d7696c0f62a1f989344f98ebcea07abdd | murilonerdx/exercicios-python | /Exercicio_Lista/exercicio_15.py | 507 | 4.25 | 4 | nome = input("Digite o nome: ")
nota1 = float(input("Digite a sua primeira nota: "))
nota2 = float(input("Digite a segunda nota: "))
nota3 = float(input("Digite a terceira nota: "))
nf = float(input("Digite o numero de faltas: "))
notaresult = (nota1+nota2+nota3)/3
faltas = 0,25 * nf
if (notaresult >= 7 and fa... |
3ebd5cff055db8b20bb632970430fac39c6fbe66 | murilonerdx/exercicios-python | /repe.py | 438 | 3.90625 | 4 | tabuada = 0
numero = 0
tipo = 0
def tabulando(numero):
if (numero <=10):
tabuada = 0
numero += 1
print("==============================================")
while (tabuada <= 10):
print("{0} x {1} = {2}".format(numero, tabuada, tabuada*numero))
tabuada =... |
f754db04243df03806e5b44228e7d50da1365684 | murilonerdx/exercicios-python | /Exercicio_Lista/exercicio_5.py | 336 | 4.03125 | 4 | num1 = float(input("Digite o primeiro valor: "))
num2 = float(input("Digite o segundo valor: "))
num3 = float(input("Digite o terceiro valor: "))
if ((num1 > num2 and num2 > num3)):
print("Os números não foram digitados em ordem crescente")
else:
print("Os números foram digitados em ordem crescente")
... |
9859be27e9f67512d2385531427d13ee650a691b | cmeslo/leetcode | /solution/652. Find Duplicate Subtrees/652.py | 653 | 3.75 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def findDuplicateSubtrees(self, root: Optional[TreeNode]) -> List[Optional[TreeNode]]:
def dfs(node)... |
9f1d64f1e34e96d78fd65f75151e4c18f84c6beb | matrixhacker0001/Gener | /gener.py | 2,178 | 3.515625 | 4 | import sys
arr = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f']
fin = []
def help():
print " A Hex Character List Generation tool"
print " ==========================================="
print " Usage: ./gener.py [options]"
print ""
print " all - print complete list with all hex values"
print "... |
e8a9872fc63530806411ace9b0245ba3831114ef | KotenUnder/OReillyDeepLearning1 | /DeepLearning_common/Layers.py | 2,320 | 3.609375 | 4 | import numpy as np
from DeepLearning_common import NeuralNetwork as nn
class MultipleLayer:
def __init__(self):
self.x = None
self.y = None
def forward(self, x, y):
self.x = x
self.y = y
return x * y
# z = x*y
# x微分はy, y微分はx
def backward(self, delta_out):
... |
21ae458dea7418dd523ec925dbf632b7f48ad662 | VivianaMontacost/Parcial_1 | /Uri1045_opcion2.py | 876 | 3.96875 | 4 | medidas=input("")
(x,y,z)=medidas.split(" ")
x=float(x)
y=float(y)
z=float(z)
if (x==y==z):
A=x
B=y
C=z
elif (x>=y and x>=z and y>=z):
A=x
B=y
C=z
elif (x>=y and x>=z and z>=y):
A=x
B=z
C=y
elif (y>=x and y>=z and z>=y):
A=y
B=x
C=z
elif (y>=x and y>=z and z>=x):
A=y
... |
f3adfc057d765512df9460bd2cbbe2be9c1cdfb2 | arokasprz100/Advent-Of-Code-2020 | /solutions/day15/solution.py | 937 | 3.84375 | 4 | from solutions.common.file_reader import FileReader
def get_nth_spoken_number(starting_numbers, n):
spoken_numbers = {number: turn + 1 for turn, number in enumerate(starting_numbers[:-1])}
last_spoken_number = starting_numbers[-1]
for current_turn in range(len(puzzle_input), n):
next_number = 0 if... |
e45c0e07e49aba0f7dca7520fc5c4e1b0bce0f50 | adowmandek/opp.py2 | /bank.py | 1,412 | 3.796875 | 4 |
class Account:
def __init__(self,phoneNumber, id,name):
self.phoneNumber=phoneNumber
self.id=id
self.name=name
self.balance=0
self.loanLimit=loanLimit
def name(self):
return f"hello this is {self.phoneNumber}, {self.id} {self.name}"
def... |
61c86418cc179f3f211e109a4be54a743540d932 | johnxiaohe/PythonPractice | /generator.py | 3,182 | 3.703125 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
from pracitse.collectionsPractise import Iterable
#列表生成器 列表数量大 使用即时演算推出,不保存实际内容
#一边循环一边计算的机制,称为生成器:generator
#第一种方法很简单,只要把一个列表生成式的[]改成()
L=[x**2 for x in range(1,11)]
print(L) #[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
g=(x**2 for x in range(1,11))
print(g) #<generator objec... |
ae5037146564d5db07f284cdc59e04a1114589ba | johnxiaohe/PythonPractice | /pracitse/hightStyleClass.py | 9,242 | 3.8125 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
from types import MethodType
#面向对象高级特性
#定义一个class之后 可以给该class绑定任何属性 动态语言的灵活特性
class Student(object):
pass
s=Student()
s.name = "jem"
print(s.name)
del s.name #这会删除该类的name属性
#print(s.name)#会报错 没有该属性'Student' object has no attribute 'name'
#方法其实也是变量可以赋值给变量 所以可以将方法绑定到... |
d62b4c36aacab2b6f8c89b9a23a3b72b6798cc24 | johnxiaohe/PythonPractice | /dao/connDateBase.py | 860 | 3.6875 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import mysql.connector
"""连接mysql"""
#执行INSERT等操作后要调用commit()提交事务
conn = mysql.connector.connect(user='root',password='root',database='world')
cursor=conn.cursor()
#创建User表
# cursor.execute('create table user (id varchar(20) primary key ,name varchar(20) )')
#插入记录 支持占位符 ... |
2ad7cd4b99f1aeb823706f0c00be85b665dece9b | GeroVeni/ChessGame | /chessBoard.py | 1,295 | 3.890625 | 4 | """ Utility functions and class about game board """
from player import *
from pieceType import *
from chessPiece import *
class ChessBoard:
""" Chess board class """
def __init__(self):
self.makeBoard()
def __iter__(self):
return iter([(self.board[i][j], (i, j)) for i in range(1, 9) for... |
0ed93c1715ad12eed349e07c831704277856b0cf | Thilagaa22/pythonsql | /5.py | 239 | 3.59375 | 4 | dict={'I':1,'II':2,'III':3,
'IV':4,'V':5,'VI':6,
'VII':7,'VIII':8,'IX':9,'X':10,
'XI':11,'XII':12,'XIII':13,
'XIV':14,'XV':15,'XVI':16,
'XVII':17,'XVIII':18,
'XIX':19,'XX':20}
s = input()
print(dict[s])
|
3ce7349775211266e4b31e0241b4ccf8df956773 | lucasca95/fundamentals_of_statistical_signal_processing_estimation_theory_Kay | /python_code/code/types_of_variables/sets.py | 194 | 3.9375 | 4 | s1 = {1, "a", 3.78}
print(s1)
s1 = {1, "a", 3.78, 1, 1, 1, "a"}
print(s1)
s1.add("Hola")
print(s1)
# update considere que lo que le damos es una lista
s1.update("chau", ["Chau!"])
print(s1)
|
5039b50e27f7f317758628fdcfeace2c3f78199c | erolerdogan/Company-Hours-Analysing | /Caught_You.py | 3,339 | 3.65625 | 4 | import pandas as pd
week4 = pd.read_excel("4_week.xlsx") # Column 13 is the data which we can use
week3 = pd.read_excel("3_week.xlsx") # Column 13 is the data which we can use
Jan_1week = pd.read_excel("Jan_1-week.xlsx") # Column 15 is the data which we can use
def create_table(data):
# Variables
must_tim... |
4b5c48f3602eac801ad7d8cb134c70b3fe70e02b | Keyrat06/Mini-Challange | /Model_CRAZY.py | 4,719 | 3.96875 | 4 | import numpy as np
import tensorflow as tf
import math
#-------------------HELPER FUNCTIONS-------------#
def _two_element_tuple(int_or_tuple):
"""Converts `int_or_tuple` to height, width.
Several of the functions that follow accept arguments as either
a tuple of 2 integers or a single integer. A single intege... |
3022c2e5d1f1221dd03a4c0de2ef080f9fb16844 | karin-jpg/trab1-aed2 | /respiradoresPorEstado.py | 2,913 | 3.53125 | 4 | import csv
import pandas as pd
import matplotlib.pyplot as plot
def countingSort(quantidade, fornecedores, exp):
n = len(quantidade)
output = [0] * (n)
output2 = [0] * (n)
count = [0] * (10)
for i in range(0, n):
index = (quantidade[i] / exp)
count[int(index % 10)] +=... |
6ac20d5712f9a00d7b90e8c3b1c56cebc4858577 | BobbChen/Python-Study-Notes | /PyCharm/7.循环语句.py | 223 | 3.984375 | 4 | #!/usr/bin/env python3
# 遍历数字序列
for i in range(5):
print(i)
# 指定区间的值
for i in range(5,9):
print(i)
# 从0开始,增量为3,直到小于等于20
for i in range(0,20,3):
print(i)
|
bf9920748710b7b0daf69b84f68091eeacd08bd1 | mlanjula94/Leetcode_Interview_questions_1 | /FizzBuzz.py | 432 | 3.703125 | 4 | class Solution:
def fizzBuzz(self, n: int) -> List[str]:
FBArray = []
for n in range( 1, n+1):
if n % 3 == 0 and n % 5 ==0:
FBArray.append("FizzBuzz")
elif n % 3 == 0:
FBArray.append("Fizz")
elif n % 5 ==0:
... |
7cab7eb87510e0655a52dea0c093739fb28d68af | candaceyw/graphs_lecture | /island_finder.py | 3,671 | 4.03125 | 4 | """
Write a function that takes a 2D binary array and returns the number of 1 islands.
An island consists of 1s that are connected to the north, south, east or west. For example:
islands = [[0, 1, 0, 1, 0, 0],
[1, 1, 0, 1, 1, 0],
[0, 0, 1, 0, 0, 0],
[1, 0, 1, 0, 0, 0],
[1, 1... |
41ced1ba556908447ddd1aa8988e0a1bd361d2fd | semonalbertyeah/flask_with_keystonemiddleware | /kapp/utils/dict_util.py | 1,237 | 3.8125 | 4 | # -*- coding:utf-8 -*-
def is_subdict(con, sub):
"""
usage:
is_subdict({'a':1, 'b':2}, {'a':1}) # True
is_subdict({'a':1, 'b':2}, {'a':1, 'c':3}) # False
"""
for key, value in sub.iteritems():
if not con.has_key(key):
return False
if con[key] != ... |
e3d27efaa49d0ce181e558f12b99c370f50caa92 | aungkhinemin89/Week04Assignment | /inventroy_app.py | 3,806 | 3.75 | 4 | from Category import Category
from Stock import Stock
# Method(01)
def addNewCategory():
category = Category()
category.name = input("Enter category name for new category : \n")
category.save()
category.display()
# Method(02)
def addNewStock():
stock = Stock()
stock.name = input("Enter st... |
397a6b557c529b95c4084680b596d8781efd8244 | NatalieMiles/shopping_list_project | /shopping_list_project.py | 1,833 | 4.40625 | 4 |
# target_list = ["socks", "soap", "detergent", "sponges"]
# bi_rite_list = ["butter", "cake", "cookies", "bread"]
# berkeley_bowl_list = ["apples", "oranges", "bananas", "milk"]
# safeway_list = ["oreos", "brownies", "soda"]
shopping_list = {
"target": ["socks", "soap", "detergent", "sponges"],
"bi_rite": ... |
88ed8b49c143f8c3ddfd5acc680fb14f3afa6dde | shuhsienhsu/X-Village-2018-Exercise | /Lesson03-Module and Package/ex2.py | 133 | 3.515625 | 4 | import datetime
def print_next_day():
print((datetime.date.today() + datetime.timedelta(days = 1)).isoformat())
print_next_day() |
5f16bbb18c53ad032049878a91c37d536d119627 | shuhsienhsu/X-Village-2018-Exercise | /Lesson08-Regular Expression/ex3.py | 924 | 3.609375 | 4 | import re
class CheckSystem():
def check_account(self, acc):
pattern = r'(?P<Account>[A-Z][a-zA-Z0-9]{5,12})'
match = re.search(pattern, acc)
if(match):
return True
else:
print("The format of your account is wrong! You have input:", acc)
return Fa... |
cea24b3e27d1bf539a8354b50c83a113bb889534 | eddieverity/DojoAssignments | /Python/PythonFundamentals/mult_sum_avg/mult_sum_avg2.py | 86 | 3.5 | 4 | #use for loop to print 5-1000000 by mult of 5
i = 5
while i<1000000:
print i
i=i+5 |
6a450cc1ab272c71733ba7e97a260129da83788e | eddieverity/DojoAssignments | /Python/Python_OOP/bike_chain.py | 683 | 3.90625 | 4 | import random
class Bike(object):
def __init__(self, price, max_speed):
print 'New Bike'
self.miles=0
self.price=price
self.max_speed=max_speed
def displayInfo(self):
print 'Price:', self.price
print 'Maximum speed:', self.max_speed
print 'Miles:', self.miles
return self
def rid... |
b302134c805d5af4ae4443ccc97dd372f90264b6 | eddieverity/DojoAssignments | /Python/Python_OOP/dragon.py | 340 | 3.53125 | 4 | from animal import Animal
class Dragon(Animal):
def __init__(self, name):
super(Dragon, self).__init__(name)
self.health=170
super(Dragon, self).displayHealth()
print "I'm a dragon!"
def fly(self):
self.health-=10
return self
dragon1=Dragon('dragon')
dragon1.walk().walk().walk().fly().f... |
981224e05657a11874d0b02cc76d6a264e7d54dd | eddieverity/DojoAssignments | /Python/Python_OOP/human.py | 619 | 3.5 | 4 | import random
class Human(object):
def __init__(self, clan=None):
print 'New Human!!!'
self.health = 100
self.clan = clan
self.strength = 3
self.intelligence = 3
self.stealth = 3
def taunt(self):
print "You want a piece of me?"
def attack(self):
self.taunt()
luck = round(random... |
c67e75a00756840a02603b0cdc3f43da5f0e29d7 | MartinThoma/hwrt | /hwrt/spacial_relationship.py | 2,557 | 3.5 | 4 | """Functions to estimate the spacial relationship of two symbols."""
def estimate(s1, s2):
"""
Estimate the spacial relationship by
examining the position of the bounding boxes.
Parameters
----------
s1 : HandwrittenData
s2 : HandwrittenData
Returns
-------
dict of probabilit... |
0ef4973d2ec3bcd01950a8d02a72389b2b72053a | yeongseon/PyCon-KR-2019 | /05-Mock/src/calculator_2.py | 941 | 3.78125 | 4 | """
"""
import logging
logging.basicConfig(level=logging.INFO)
class Calculator():
"""Calculator class"""
def __init__(self):
self.logger = logging.getLogger(self.__class__.__name__)
"""
def add(self, a, b):
self.logger.info(
"add {a} to {b} is {result}".format(
... |
44e125e44cdf49730f4195cbc078291a4d9893b6 | LenaSpevak/programming | /homework01/vigenere.py | 4,077 | 4.125 | 4 | def encrypt_vigenere(plaintext: str, keyword: str) -> str:
"""
Encrypts plaintext using a Vigenere cipher.
>>> encrypt_vigenere("PYTHON", "A")
'PYTHON'
>>> encrypt_vigenere("python", "a",)
'python'
>>> encrypt_vigenere("ATTACKATDAWN", "LEMON")
'LXFOPVEFRNHR'
"""
ciphertext = ""
... |
63af9f683354d8ba09cf62d789d434d305b38ab6 | laristra/python-ci | /mytan.py | 270 | 3.953125 | 4 | import math
import sys
def mytan(x):
'''mytan is a home grown tan function that relies on math.sin and math.cos'''
y = math.sin(x)/math.cos(x)
return y
if __name__ == "__main__":
arg=float(sys.argv[1])
print ("Tan of %s is %s" % (arg, mytan(arg)))
|
93481419afcb5937eca359b323e038e7e29c6ad9 | rzfeeser/20200831python | /monty_python3.py | 1,075 | 4.125 | 4 | #!/usr/bin/python3
round = 0
answer = " "
while round < 3:
round += 1 # increase the round counter by 1
answer = input('Finish the movie title, "Monty Python\'s The Life of ______": ')
# transform answer into something "common" to test
answer = answer.lower()
# Correct Answer
if answe... |
795b37370fef700198a56ed8f90e8646bb05db9c | dmcinerney/pytt | /pytt/preprocessing/raw_dataset.py | 636 | 3.703125 | 4 | # handles loading from csv file using pandas
import pandas as pd
class RawDataset:
"""
Acts as a handle for a dataset in a csv file, using pandas to read it
"""
def __init__(self, filename):
"""
Reads in dataframe from csv using pandas
"""
self.df = pd.read_csv(filename)... |
56d5939ad14df786f9a20e788f38726c3d33af7b | macsf/Twittorials | /Requests_Selenium_jcchouinard_com/6-check_redirects.py | 3,559 | 3.71875 | 4 | #!/usr/bin/env python
'''
Make a Redirection Report
@author: Jean-Christophe Chouinard.
@role: Sr. SEO Specialist at SEEK.com.au
@website: jcchouinard.com
@LinkedIn: linkedin.com/in/jeanchristophechouinard/
@Twitter: twitter.com/@ChouinardJC
What it does:
Crawl a list of URLs.
Count the number of redir... |
c5724caf14a81b3acc069975a018f0bd08600e60 | aishwaryapothula/pbox | /matrix.py | 458 | 3.828125 | 4 | #AishwaryaPothula
#Learning to work with matricies using numpy
import numpy
a=numpy.array([[1,2,3,13],[4,5,6,11],[7,8,9,10],[15,0,4,0]])
b=numpy.ones((4,4))
r=numpy.zeros((4,4))
#Operations on Matrix
print(type(a))
print(a.shape)
print(a)
#Slicing
print(a[1:3,2:3])#prints 6,9
#Integer Array Indexing
print(a[[1,2,3... |
325a0aa3650c79861f2f692638ef9ddcb7710ad9 | TaranSonkar/day2task-internity-taransonkar | /day2task.py | 6,345 | 4.40625 | 4 | #INDEXING WITH SEQUENCE
'''index into a sequence is to retrieve a single member by specifying an integer index
that indicates the place of that member in the sequence:seq[index].
Python uses a zero-based indexing system, meaning that the first element in a sequence is located at position 0.'''
#string indexing:
a='i... |
dd5c67434029390a63bf6e32444a9f24c38ca467 | lelilia/Project_Markov_Simulation | /01_data_analysis/save_days_in_supermarket.py | 1,153 | 3.65625 | 4 | '''
Takes the data from the weekdays and saves it in a file called supermarket
It adds a number to the customerID so they are distinguishable from each other on different days
'''
import pandas as pd
import matplotlib.pyplot as plt
monday = pd.read_csv('../data/monday.csv', sep = ';', index_col = 'timestamp')
t... |
ac0f95c68b877699a5bf7389634e7cf0bf6d049d | codelight2711/Python-Hackerrank-Solutions | /Nested Lists.py | 527 | 3.59375 | 4 | final=list()
for i in range(int(input())):
lst=[]
name = input()
score = float(input())
lst.append(name)
lst.append(score)
final.append(lst)
k=list()
for i in range(len(final)):
k.append(final[i][1])
x=min(k)
k1=[]
for i in range(len(k)):
if x!=k[i]:
... |
da766409f07dd620c26cb04e10c0acb2d67d3b61 | chimble/currencycalculator | /Currency.py | 1,409 | 3.609375 | 4 | #from CurrencyConverter import CurrencyConverter
class Currency():
def __init__(self, currency_code, amount = 0):
if amount == 0:
if currency_code[0] == '$':
self.currency_code = 'USD'
self.amount = float(currency_code[1:])
elif currency_code[0] == '€... |
2140419ad48b0042f5f0b366ac8fef277825f4cf | Shakarbek/ICT-task1 | /10.py | 182 | 3.875 | 4 | s=input()
t=False
if s.isupper():
t=True
print(s[0]+s[1:].lower())
elif s[0].islower() and s[1:].isupper():
print(s[0].upper() + s[1:].lower())
else:
print(s) |
943693f2d27294c8735d556277080b38d8de0203 | Shakarbek/ICT-task1 | /137.py | 315 | 3.609375 | 4 | points = {
"A": 1, "B":3, "C":3, "D":2, "E":1, "F":4, "G":2,\
"H":4, "I":1, "J":2, "K":5, "L":1, "M":3, "N":1,\
"O":1, "P":3, "Q":10, "R":1, "S":1, "T":1, "U":1, \
"V":4, "W":4, "X":8, "Y":4, "Z":10
}
s= input()
s=s.upper()
score=0
for i in s:
score=score+points[i]
print(score) |
2145383f82a9fca0f4c2a564b3170fb20447d7ad | ashley-honn/homework5 | /task1.py | 880 | 3.578125 | 4 | #scores file for students
FILENAME = 'scores.txt'
WRITE_MODE = 'w'
with open(FILENAME, WRITE_MODE) as scores_file:
scores_file.write('Alice 69\n')
name = 'Bob'
score = 89
scores_file.write(f'{name} {score}\n')
scores_file.write('Cindy 79\n')
#define the average for 3 students
def cal_average(n... |
29760c5fa5ecbff5f58e381d3c9834cd1a5f782c | SnehaliM/poolsand | /prog1.py | 9,077 | 3.84375 | 4 |
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 9 15:08:31 2018
@author: student
"""
print ('enter length')
l=int(input())
print ('enter breadth')
b=int(input())
if l==b:
print('it is a square')
else:
print('it is not a square')
print('enter an integer')
n1=int (input())
n2=inpu... |
d8a38ab279c2243f8a5155d916a654a06c28487d | johanmcquillan/conquest_stm | /conquest_stm/vector.py | 5,611 | 3.515625 | 4 |
import numpy as np
__author__ = 'Johan G. McQuillan'
__email__ = 'johan.mcquillan.13@ucl.ac.uk'
class Vector(object):
"""3D Cartesian vector.
Attributes:
x (float): Component value in x direction.
y (float): Component value in y direction.
z (float): Component value in z direction.
... |
4f40e7c264e5c1f3a7d70cfc07e50252a90c7247 | wangduizhang/pg100 | /pg13_1.py | 285 | 3.5625 | 4 | #!/usr/bin/python
#_*_coding:utf-8_*_
#打印出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身.
for i in range(100,1001):
n1 = i / 100
n2 = i /10 % 10
n3 = i % 10
if n1**3 + n2**3 + n3**3 == i:
print i
|
f5877cd5f5e1ef970a69aac2b9248e27fd742b18 | carleton-cs257-fall-2018/assignments-broadbentc | /books/books1.py | 6,913 | 3.984375 | 4 | # This is Phase 1 of Books Assignment:
# @author Charlie Broadbent
# @author Will Thompson
import sys
#Global Variables
list_of_books = []
list_of_authors = []
dict_names = {}
dict_books = {}
#Read the file and collect the data form the file.
def read_file(some_file):
csv_file = open(some_file, 'r')
... |
4c5a2f9b26e6d4fa7c3250b3043d1df5865b76c8 | g-boy-repo/shoppinglist | /shopping_list_2.py | 2,162 | 4.5 | 4 | # Have a HELP command
# Have a SHOW command
# clean code up in general
#make a list to hold onto our items
shopping_list = []
def show_help():
#print out instructions on how to use the app
print("What should we pick up at the store?")
print("""
Enter 'DONE' to stop addig items.
Enter 'HELP' for this help... |
b30c5e8c18a921e986c571dff5c439eec1bf55a9 | JKBlomer/PythonPractice | /higher_order_functions.py | 221 | 3.765625 | 4 | def square(x):
return x * x
def my_map(func, arg_list):
result = []
for i in arg_list:
result.append(func(i))
return result
squares = my_map(square, [2,4,5,6,7,8])
print(squares)
|
35b57f37782963111a65a7f84f051b79b7d7fae4 | soumyasen1809/MIT_Computational_Thinking | /MITCourseWare Computational Thinking and Data Science/Understanding Experimental Data/Temperature_US.py | 2,034 | 3.546875 | 4 | # https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0002-introduction-to-computational-thinking-and-data-science-fall-2016/lecture-slides-and-files/MIT6_0002F16_lec10.pdf
import numpy as np
import random
from matplotlib import pyplot as plt
class TempData(object):
def __init__(self,... |
b8c62ed80572b0946552cf79e19fb5433c53a38a | qd9500805/py | /learn1.py | 420 | 3.96875 | 4 | car = ['audi','b','benchi']
print(car)
print('hello w')
value = '7'
if value == '7':
print('The value is 7')
elif value == '8':
print('the value is 8')
else:
print('the value is not in')
value = input ('would you like to continue?')
if value =='y' or value =='yes':
print('continuing....')
print('ok... |
1522a16f973d9d112ecccca8219199e09a4e5e3f | vivek28111992/python-for-algo-and-ds | /missingElement_Sol1.py | 724 | 3.703125 | 4 | #Missing Element Solution
from nose.tools import assert_equal
def finder(arr1, arr2):
#Sort the arrays
arr1.sort()
arr2.sort()
# Compare elements in the sorted arrays
for num1, num2 in zip(arr1, arr2):
if(num1 != num2):
return num1
# Otherwise return last element
retur... |
249486130480f1ef3eeeed8c8f09c9a48042e1c1 | AlexanderSenf/ga4gh_compute_trial | /pro_tes/pro_tes/utils/utils.py | 975 | 3.75 | 4 | """General purpose utitlity functions."""
from typing import (Any, Dict, List)
def missing_from_dict(
*args: Any,
dictionary: Dict,
) -> List:
"""
Validates the existence of dictionary keys. Returns a list of arguments
that were _NOT_ found in the dictionary.
:param *args: The existence of ea... |
e3c1cceca6cad5974358a50bdde4537581ea959e | maheshnikki/python | /for_sample.py | 277 | 3.6875 | 4 | import random
for x in range(1, 100, 10):
print(x)
a = ["mahesh", "nikki", 'maheshnikki', 'nikkimahesh']
print(a)
if 'mahesh' in a:
print("yes it is present in the array\n")
else:
print("not present\n")
arr = [1, 2, 3, 4, 5, 6]
for arr in arr:
print(arr[2]) |
93f1c6b3d5fb609e6a66d78fec4c33bd2c333eae | sankar-vs/Python-and-MySQL | /RDBMS/Indexing/main.py | 1,374 | 3.84375 | 4 | '''
@Author: Sankar
@Date: 2021-04-26 08:46:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-26 09:38:09
@Title : Main for Indexing in MySQL
'''
import Indexing as index
from log import logger
def features():
'''
Description:
Performs features on indexing in MySQl
Parameter:
None
... |
92a724a1454d3a676fc4cadfe8653c7db5d88537 | sankar-vs/Python-and-MySQL | /Data Structures/Strings/11_Reverse_string.py | 268 | 4.0625 | 4 | '''
@Author: Sankar
@Date: 2021-04-12 07:55:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-12 07:59:09
@Title : Strings_Python-11
'''
'''
Write a Python program to reverse a string.
'''
str1 = 'the quick brown fox jumps over the lazy dog.'
print(str1[::-1]) |
4d72217ab9e954da6c6d7e0051a922decb456e29 | sankar-vs/Python-and-MySQL | /OOPS/src/Cards.py | 3,644 | 4 | 4 | '''
@Author: Sankar
@Date: 2021-04-06 09:46:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-06 12:50:09
@Title : Deck of Cards
'''
import random
class Card:
'''
Class:
Card
Description:
Creates a card
Functions:
show() -> str
Variable:
None
'''
d... |
ad1035e8625ce30aa71c83c15f5bb57b921a3edd | sankar-vs/Python-and-MySQL | /Numpy/1_Convet_to_numpy.py | 442 | 3.890625 | 4 | '''
@Author: Sankar
@Date: 2021-04-13 16:19:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-13 16:35:09
@Title : Numpy_Python-1
'''
'''
Write a Python program to convert a list of numeric value into a one-dimensional
NumPy array.
Expected Output:
Original List: [12.23, 13.32, 100, 36.32]
One-dimensional numpy... |
ca370e380ff6b3387cdad65b5cc39b64e73de801 | sankar-vs/Python-and-MySQL | /Data Structures/Dictionary/5_Generate.py | 456 | 4.03125 | 4 | '''
@Author: Sankar
@Date: 2021-04-09 09:06:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-09 09:11:09
@Title : Dictionary_Python-5
'''
'''
Write a Python script to generate and print a dictionary that contains a
number (between 1 and n) in the form (x, x*x).
Sample Dictionary ( n = 5) :
Expected Output : {1... |
5f4fcc700cf58ab9dd92a2a83559f6f5437385da | sankar-vs/Python-and-MySQL | /Data Structures/Basic Program/4_Print_docs.py | 382 | 3.9375 | 4 | '''
@Author: Sankar
@Date: 2021-04-07 19:18:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-07 19:25:09
@Title : Basic_Python-4
'''
'''
Write a Python program to print the documents (syntax, description etc.) of Python built-in
function(s).
Sample function : abs()
Expected Result :
abs(number) -> number
Retur... |
e5dbac6cd3ba92049b640e62c1bf96fb61b6ca03 | sankar-vs/Python-and-MySQL | /Data Structures/Tuple/6_Check_element_exists.py | 280 | 4.1875 | 4 | '''
@Author: Sankar
@Date: 2021-04-11 09:27:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-11 09:32:09
@Title : Tuple_Python-6
'''
'''
Write a Python program to check whether an element exists within a tuple.
'''
tuple = ("Heyya", False, 3.2, 1)
print("Heyya" in tuple) |
3edf29f645ecb4af1167359eab4c910d47c40805 | sankar-vs/Python-and-MySQL | /Data Structures/Basic Program/41_Convert_to_binary.py | 519 | 4.3125 | 4 | '''
@Author: Sankar
@Date: 2021-04-08 15:20:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-08 15:27:09
@Title : Basic_Python-41
'''
'''
Write a Python program to convert an integer to binary keep leading zeros.
Sample data : 50
Expected output : 00001100, 0000001100
'''
decimal = 50
print("Convertion to bin... |
edcb24efd1f229f07a94b4912145e6d15e341cc5 | sankar-vs/Python-and-MySQL | /Data Structures/Dictionary/12_Check_keys.py | 321 | 4.03125 | 4 | '''
@Author: Sankar
@Date: 2021-04-09 10:22:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-09 10:30:09
@Title : Dictionary_Python-12
'''
'''
Write a Python program to check multiple keys exists in a dictionary.
'''
dict = {1:1, 2:2, 3:3, 4:4}
if {1,2} <= dict.keys():
print("True")
else:
print("False"... |
67bdb85c94a8874623c89d0ac74a9b1464e5c391 | sankar-vs/Python-and-MySQL | /Data Structures/List/8_Find_list_of_words.py | 739 | 4.5 | 4 | '''
@Author: Sankar
@Date: 2021-04-09 12:36:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-09 12:42:09
@Title : List_Python-8
'''
'''
Write a Python program to find the list of words that are longer than n from a
given list of words.
'''
n = 3
list = ['Hi','Sankar','How','are','you',"brotha"]
def countWord... |
1e16341185e46f060a7a50393d5ec47275f6b009 | sankar-vs/Python-and-MySQL | /Data Structures/List/3_Smallest_number.py | 440 | 4.15625 | 4 | '''
@Author: Sankar
@Date: 2021-04-09 12:07:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-09 12:13:09
@Title : List_Python-3
'''
'''
Write a Python program to get the smallest number from a list.
'''
list = [1,2,3,4,6,10,0]
minimum = list[0]
for i in list:
if (minimum>i):
minimum = i
print("Min... |
08a53c3d25d935e95443f1dfa3d2cefdd10237fb | sankar-vs/Python-and-MySQL | /Data Structures/Array/4_Remove_first_element.py | 482 | 4.1875 | 4 | '''
@Author: Sankar
@Date: 2021-04-09 07:46:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-09 07:51:09
@Title : Array_Python-4
'''
'''
Write a Python program to remove the first occurrence of a specified element from an
array.
'''
array = []
for i in range(5):
element = int(input("Enter Element {} in arr... |
da61300a4b60645dd76c9a78bbf4142b60dc4048 | sankar-vs/Python-and-MySQL | /Data Structures/Dictionary/6_Remove_key.py | 364 | 4 | 4 | '''
@Author: Sankar
@Date: 2021-04-09 09:13:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-09 09:17:09
@Title : Dictionary_Python-6
'''
'''
Write a Python program to remove a key from a dictionary.
'''
dict = {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
for i in dict.keys():
if i == 2:
del dict[i]
br... |
2b3f22bb3fcad13848f40e0c938c603acb2f3959 | sankar-vs/Python-and-MySQL | /Functional Programs/Distance.py | 1,357 | 4.28125 | 4 | '''
@Author: Sankar
@Date: 2021-04-01 09:06:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-02 12:25:37
@Title : Euclidean Distance
'''
import re
def num_regex_int(x):
'''
Description:
Get input from user, check whether the input is matching with the pattern
expression, if True then re... |
fdabe5dfd162eddbf40b0c567a7b1caebcd1ebd2 | sankar-vs/Python-and-MySQL | /Data Structures/List/12_Difference_in_list.py | 412 | 4.0625 | 4 | '''
@Author: Sankar
@Date: 2021-04-10 07:22:25
@Last Modified by: Sankar
@Last Modified time: 2021-04-10 07:30:09
@Title : List_Python-12
'''
'''
Write a Python program to get the difference between the two lists.
'''
list1 = [10, 15, 20, 25, 30, 35, 40]
list2 = [25, 40, 35]
list = [i for i in list1+list2 if i not in l... |
f10257b08a9d16adeda59f33a5705517c7ffd2a1 | aliktl/TOPIK | /TOPIK.py | 1,669 | 3.53125 | 4 | from collections import Counter, defaultdict
f = open("vocabulary2.txt", encoding="utf8")
f2 = open("all_words_topik_level_1_11-34_listening_text+reading.txt", encoding="utf8")
f3 = open("all_words_topik_level_1_35-52_listening_text+reading.txt", encoding="utf8")
f4 = open("all_words_topik_level_2_11-34_listening... |
24dabefa487061626c9e918487c7b43552facac6 | Dilshodbek23/Python-lessons | /even_num_test.py | 259 | 3.5625 | 4 | import unittest
from even_num import even_n
class NameTest(unittest.TestCase):
def test_even_n(self):
formatted_name = even_n([2, 3, 4, 5, 7, 10, 12])
self.assertEqual(formatted_name, [2, 4, 10, 12])
unittest.main()
|
55f9b7cd0aa5a2b10cd819e5e3e6020728e2c670 | Dilshodbek23/Python-lessons | /38_4.py | 366 | 4.4375 | 4 | # Python Standard Libraries
# The user was asked to enter a phone number. The entered value was checked against the template.
import re
regex = "^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$"
phone = input("Please enter phone number: ")
if re.match(regex, phone):
print(f"phone: {phone}")
el... |
1deba6bc7cf38944cb257e5c6d3e5bc7dfcdab59 | Dilshodbek23/Python-lessons | /17_1.py | 158 | 3.609375 | 4 | while True:
a=input("kitobingizni kiriting(kitoblarni kiritib bolsangiz 'exit'ni bosing): ")
if a=='exit':
break
print("Thank you!")
|
ba8f64aa2170f2ec1d089fee9f4dc3c8054ab0f7 | Dilshodbek23/Python-lessons | /25.py | 1,591 | 4.0625 | 4 | import random as r
print("Let's play to find the number you think about.")
answer=1
while answer:
num_com = r.randint(1, 10)
print("I came up with a number from 1 to 10. Can you find it?:")
i=0
while True:
num=int(input('>>'))
if num>num_com:
print("Error. My number... |
eb46d9ab3af679ac19d6194e7796475fc3b881e9 | vs5553uf/Basic-Networking | /Group2_PE2_Part_4.py | 4,280 | 4.03125 | 4 | import random
# This is a change to the file
# This is another change to the file
def main():
exit = False
difficulty = setdifficulty()
option = getoperation()
while not exit and option != 5:
awser = createquestion(difficulty, option)
exit = checkanswer(awser)
optio... |
c9526a5c65709e137d03770347536532c3d9b924 | mlaug/Sudoku-Solver | /game.py | 3,473 | 3.515625 | 4 | import random
import sys
from square import SquareAbstract
from square import Square
class Game(SquareAbstract):
def __init__(self):
SquareAbstract.__init__(self)
#add count square to gmae
for sqc in xrange(0,9):
x,y = self.getFreeSlot()
square = Square(self,x,y)
sel... |
2bb53fc1c66467036b928ca15206cba70de218ab | Stephanie9349/2021_1-Grass | /210516.py | 154 | 3.65625 | 4 | n=int(input())
output=0
number=int(input())
if n<=100 and n>=1:
for i in range(n):
output+=int(number%10)
number/=10
print(output) |
38c79868e60d20c9a6d5e384b406c3656f565ffb | Haldgerd/Simple_coffee_machine_project | /main.py | 2,305 | 4.5 | 4 | """
An attempt to simulate a simple coffee machine and it's functionality. This version is used as in depth exercise, before
writing same program using OOP later within the programming course.
The main requirements where:
1. Output a report on resources.
2. Receive user input, referring to type of coffee they want.
3.... |
2370915fa2514143fc56ea1e055b70805d22d170 | samaracanjura/Coding-Portfolio | /Python/Shapes.py | 996 | 4.375 | 4 | #Samara Canjura
#shapes.py
#Finding the area and perimeter of a square, and finding the circumference and area of a circle.
import math # Python Library needed for access to math.pi and math.pow
def main():
inNum = getInput("Input some number: ")
while inNum != 0: #Loop ends when zer... |
7bd0888085542859d08f395731cbfdfc04d1edf7 | evaristofm/curso-de-python | /pythonteste/aula08.py | 267 | 4.15625 | 4 | from math import sqrt
import emoji
num = int(input('Digite um número: '))
raiz = sqrt(num)
print('A raiz de {} é igual a {}'.format(num, raiz))
print(emoji.emojize("Olá, Mundo :alien:", use_aliases=True))
print(emoji.emojize('Python is :cry:', use_aliases=True)) |
739de01d0f5ed3272f97c179ee8339dfb6c7eb7d | evaristofm/curso-de-python | /PythonExerciocios/ex025.py | 108 | 3.75 | 4 | nome = input('Digite seu nome: ')
print('Seu nome tem SILVA? Resposta: {}'.format('SILVA' in nome.upper()))
|
2b608c4351d9996a9595bc0fc6dab17a6c0efc68 | evaristofm/curso-de-python | /PythonExerciocios/ex029.py | 270 | 3.859375 | 4 | velo = float(input('Informe a velocidade: '))
if velo > 80:
print('MULTADO! Você excedeu o limite permitido que é de 80km/h')
multa = (velo - 80) * 7
print('O total da multa é de R${:.2f}'.format(multa))
else:
print('Dentro da velocidade permitida!')
|
752b529bd4fb9441f47e475cb84325015435714e | anushkagarg5653/Python | /Structured Programming/Q3.py | 435 | 3.6875 | 4 | stack = []
x = "(2+4*[89-5(78+16)]-6"
for i in x:
if i =="{" or i=="[" or i=="(":
stack.append(i)
elif i =="}":
if stack[len(stack)-1]=="{":
stack.pop()
elif i =="]":
if stack[len(stack)-1]=="[":
stack.pop()
elif i ==")":
if stack[len(s... |
2e7cb10cf0d633470a0e3a60186cbbc15ecbc7a2 | KelseyCortez/4.1.20-pm | /degree_conversion.py | 127 | 3.625 | 4 | Temp = float(input('Temperature in C? '))
Cels_to_Fare = (Temp * (9/5)) + 32
result = f'{Cels_to_Fare} F'
print(result)
|
6f66bb1b9d3db1ad247b28ce5b35b32b8532cab3 | TogrulAga/Web-Scraper | /Topics/Elif statement/Calculator/main.py | 372 | 3.84375 | 4 | # put your python code here
number_1 = float(input())
number_2 = float(input())
operator = input()
if operator == "mod":
operator = "%"
elif operator == "pow":
operator = "**"
elif operator == "div":
operator = "//"
if operator in ['/', '//', '%'] and number_2 == 0.0:
print("Division by 0!")
else:
... |
f08c07b42b7571aa08ff63bf0f96032801b8d246 | TogrulAga/Web-Scraper | /Topics/For loop/Vowel count/main.py | 182 | 4.09375 | 4 | string = "red yellow fox bite orange goose beeeeeeeeeeep"
vowels = 'aeiou'
count_vowels = 0
for char in string:
count_vowels += 1 if char in vowels else 0
print(count_vowels)
|
844d70c9ee13813b63bea4c5325e0e0112cabebe | guiaugusto/data_structures_examples | /Interpolation_Search/is_python_simple.py | 906 | 3.84375 | 4 | # Uniformly distributed elements
elements = [i for i in range(0, 100, 2)]
print(elements)
selected_element = int(input('Say a number to find in the array container: '))
inferior = 0
superior = len(elements)
found = False
latest = inferior
meio = inferior
if selected_element < superior:
while True:
late... |
bebe5df57ffb85baadd8a380688e8b29db461976 | skaftisveins/Python-Mail-Merge-Day-24 | /main.py | 1,137 | 3.75 | 4 | PLACEHOLDER = "[name]"
# Open invited_names.txt for reading
with open("input/names/invited_names.txt", mode="r") as names_file:
names = names_file.readlines()
# Open starting_letter.txt for reading
with open("input/letters/starting_letter.txt", "r") as body_file:
# Read the entire contents of the... |
74c00f287ec85a3a8ac0b3b9fd8f3d0bd6babe70 | psmzakaria/Practical-1-2 | /Practical2Q1.py | 478 | 4.125 | 4 | # Question 1
# Write codes for the incomplete program below so that it sums up all the digits in the integer variable num (9+3+2) and displays the output as a sum.
num = int(input("Enter your Number Here"))
print(num)
# Getting the first digit number
digit1 = int(num/100)
print(digit1)
# Getting the second digit n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.