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 |
|---|---|---|---|---|---|---|
c588c1411455ae72f52a24e85580a4bec6d86e25 | shao1chuan/regression | /优化算法/优化算法 CSDN课程/梯度下降.py | 1,011 | 3.875 | 4 | import numpy as np
import matplotlib.pyplot as plt
#生成2行100列数据
X = np.array([np.ones(100), np.random.rand(100)])
y = np.dot([4, 3], X) + np.random.rand(100)
print(X.T.shape,X.shape,y.shape)
plt.scatter(X[1, :], y)
plt.show()
alpha = 0.01
num_iters = 1000
def gradient_descent(theta, X, y, alpha, num_iters):
loss... |
92da467db61be55a1d364f96017301b101986bde | shao1chuan/regression | /深度学习/扩展pytorch/最简单梯度下降扩展/最简单函数求极值tensor.py | 742 | 3.53125 | 4 | import torch
import torch.optim
import matplotlib.pyplot as plt
def f(x):
return x**2-3
def df(x):
return 2*x
def plotf(loss):
x = range(len(loss))
plt.plot(x,loss)
plt.xlabel('Iteration')
plt.ylabel('Loss')
plt.show()
def main():
x = torch.tensor([15.],requires_gra... |
183108eaa3f981073786ff82ac9a92db9ff35bef | danidhenga/My-Favourite-Projects-for-Learning-Python | /Mad Libs game.py | 398 | 3.796875 | 4 | #Mad Libs Game!
print("Welcome to Pandeni's game!")
name = input("Enter your name: ")
age = input("Enter your age: ")
colour = input("Type a colour: ")
violets = input("Type a plural item: ")
who = input("Type something you love: ")
print(name.capitalize())
print(age)
#the actual game:
print("Roses are " + colour)
pr... |
086b3eb6ae76de9ed2d965c884dbdb3645a17612 | danidhenga/My-Favourite-Projects-for-Learning-Python | /Reading Files with Python.py | 475 | 3.84375 | 4 | #Read from Random File.txt
#use comma and r = read; w = write; a = append (add); r+ = read & write
#store open into variable
employee_file = open("Random File.txt", "r")
#print employeefile.readable to test file
#print employeefile.readline to read first line
#print employeefile.readlines to read specific lines
prin... |
548a32f4dfeae8c6ce3d07b232bc7d16bea8e274 | shuiai31/game-corpus-multi-turn-dialogue | /tf_load_data.py | 1,064 | 3.796875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
# Load training data set from CSV file
training_data_df = pd.read_csv("game_question_answer_training.csv", dtype=float)
X_training = training_data_df.drop('question', axis=1).values
Y_training = training... |
3bd7669d52cd5669ece6b162b481fb493a9f4850 | janproch/datadmin | /tools/multilic.py | 260 | 3.578125 | 4 | import sys
def format(num):
return int(num + 0.5)
price = int(sys.argv[1])
print '1-3:', format(price)
print '4-10:', format(price * 0.9)
print '11-20:', format(price * 0.8)
print '21-50:', format(price * 0.7)
print '51 and more:', format(price * 0.6)
|
b99624a93dc9fcf881230db3d74c32421588a013 | matrixd11111/production_cod | /minigames/settings/loto_game.py | 3,752 | 3.5 | 4 | import random
# создание класса мешка с боченками
class BarrelBag():
def __init__(self):
self.barrel_list = []
self.barrel_pop = []
self.barrel_other = 111
"""Создание мешка с бочонками"""
def create_barrel(self):
for i in range(1, 100):
self.barrel_list.appe... |
5855c6bb6e6364ea01f53eb845579507a2af9ff0 | calruro/py_carrera | /py_Unacional/c.py | 1,333 | 3.765625 | 4 | # print("c", end='')
# import a
# import b
# print(__name__)
# print(len((1, )))
# print("a", "b", "c", sep="'")
# class A:
# def __init__(self, name):
# self.name = name
# a = A("class")
# print(a)
# class A:
# pass
# class B:
# pass
# class C(A, B):
# pass
# print(issubclass(C, A) and... |
851dfd74a4dd011050645db72cba119ca57f9249 | federicodiazgerstner/sd_excercises_uade | /Ejercicio 5.15.py | 812 | 4 | 4 | # Ejercicio 15: Escribir una función que reciba como parámetros dos números enteros y devuelva
# la concatenación de ambos. Por ejemplo concatenar(123,456) devuelve
# 123456. Tener en cuenta que el primer número puede
def concat(a, b):
#determinar signo
if a < 0:
signo = -1
a = -a
else... |
d590c127175cad5e8ab19d68b823e2bcaf91173c | federicodiazgerstner/sd_excercises_uade | /Ejercicio 6.01.py | 874 | 4.03125 | 4 | # Ejercicio 1: Escribir una función para ingresar desde el teclado una serie de números entre 1
# y 20 y guardarlos en una lista. En caso de ingresar un valor fuera de rango el
# programa mostrará un mensaje de error y solicitará un nuevo número. Para finalizar
# la carga se deberá ingresar -1. La función no recibe nin... |
567c955b90649f12f5751158ef91ddb81b4c119f | federicodiazgerstner/sd_excercises_uade | /Ejercicio 3.5.py | 331 | 3.96875 | 4 | base = float(input("Insertar base del triángulo:"))
altura = float(input("Insertar altura del triángulo:"))
superficie= base*altura/2
if base>0 and altura>0:
print("La superficie es de", superficie)
else:
print("Un triángulo no puede tener una superficie de", superficie, "ya que al menos uno de los lados es neg... |
b6587aace2006e8cca1e4e546b3bc4bb716fcfa0 | federicodiazgerstner/sd_excercises_uade | /Ejercicio 4.07.py | 542 | 4.21875 | 4 | #Realizar un programa para ingresar desde el teclado un conjunto de números y
#mostrar por pantalla el menor y el mayor de ellos. Finalizar la lectura de datos
#con un valor -1.
n = int(input("Insertar un número, o -1 para terminar: "))
menor = n
mayor = n
while n != -1:
if n > mayor:
mayor = n
elif n ... |
767cad3a5d7e6213b459662e0c61e03bd3d4b0cc | federicodiazgerstner/sd_excercises_uade | /Ejercicio 3.1.py | 148 | 3.875 | 4 | a = int(input("Ingresar numero a: "))
b = int(input("Ingresar numero b: "))
if a>b:
print("El mayor es", a)
else:
print ("El mayor es", b)
|
6e52cae2a24bb44de8fe36a5cb83c72faaad8b87 | federicodiazgerstner/sd_excercises_uade | /Ejercicio 5.08.py | 285 | 3.921875 | 4 | def maxComunMultiplo (a , b):
while a != b:
if a>b:
a = a - b
else:
b = b - a
return a
x = int(input("Inserte primer numero: "))
y = int(input("Inserte segundo numero: "))
print("El MCM de", x, "y", y, "es", maxComunMultiplo (x, y)) |
29fcb2830e18f32609e8c0a71572f4cdd205e569 | federicodiazgerstner/sd_excercises_uade | /Ejercicio 5.07.py | 279 | 4.09375 | 4 | def factorial (a):
multiplicador = 1
total = 1
while multiplicador <= a:
total = total * multiplicador
multiplicador = multiplicador + 1
return total
x = int(input("Inserte un número: "))
print("El factorial es: ", factorial (x))
|
02168574e323a4e29c1730b7329b000cb2a06e6f | federicodiazgerstner/sd_excercises_uade | /Ejercicio 5.05.py | 169 | 4.09375 | 4 | def max (a, b):
if a > b:
return a
else:
return b
x = int(input("Inserte número a: "))
y = int(input("Inserte número b: "))
print (max (x, y)) |
3924654f505a200706d4b2730dd1cc6ee967effa | cykzht/PythonCode | /瞎球写/Day3.py | 1,073 | 4.03125 | 4 | #if的用法
#单向判断
stonenumber=6
if stonenumber>=6:
print('你拥有了毁灭宇宙的力量')
#双向判断
stonenumber=3
if stonenumber>=6:
print('你拥有了毁灭宇宙的力量')
else:
print('带着卡魔拉去沃弥尔星寻找灵魂宝石')
#多向判断
stonenumber=5
if stonenumber>=6:
print('你拥有了毁灭宇宙的力量')
elif 0<stonenumber<=5:
print('绯红女巫需要亲手毁掉幻视额头上的心灵宝石')
else:
pri... |
afb896338490d28c3baa001df68cdfb9229e257a | itzkriish/MyCaptain | /Task3.py | 204 | 3.65625 | 4 | first_term = 0
second_term = 1
print(first_term, second_term, end=" ")
for i in range(11):
term = first_term + second_term
print(term, end=" ")
first_term = second_term
second_term = term
|
6a3f79144fb7553183244b7f1bda8ff75f124f84 | Stephen-Montague/architecture-mvc-pattern | /calculator_MVC_pattern.py | 7,752 | 3.96875 | 4 | """
Stephen Montague
CPSC-61200 Software Architecture
Fall 2019 - Term 2
Week 3 - Lab 3
A school-provided implementation of a calculator
using the Model-View-Controller design pattern.
Updated by student to handle multiple expressions,
added a new backspace key, added a decimal key,
added the ability to ha... |
aa6e89d58bae51ffab5f87a51b4d7fbe3c702277 | linchengzeng/day7 | /test_file/test_class.py | 769 | 3.96875 | 4 | # -*- coding:utf-8 -*-
# Author:aling
class Person(object):
def __init__(self,name,age): #self = b, self.name = b.name
self.name = name
self.age = age
def talk(self):
print('person is talking.....')
class BlackPerson(Person):
def __init__(self,name,age,power):#先继承,再重构
P... |
969f07d7e499b322bdec7893b9389542c41a6d2e | linchengzeng/day7 | /test_file/cs.py | 586 | 3.5 | 4 | # -*- coding:utf-8 -*-
# Author:aling
class Role(object):
def __init__(self,name,role,tool,wages=1000):
self.NAME = name,
self.ROLE = role,
self.TOOL = tool,
self.WAGES = wages
def teach(self):
print("%s 在上课"%self.NAME)
def texercises(self):
print("%s在改作业"%... |
52ec4ce947ac6a9b9a423ed7491e491e1fb5a95b | bhargav-s-271100/Python-Programs | /Sum,Average and Count of positive or neagitive Inetgers.py | 376 | 3.953125 | 4 | a=int(input("enter the number or enter 999 to exit : "))
pos=0
neg=0
sum=0
i=0
while(a!=999):
if(a>0):
pos+=1
elif(a<0):
neg+=1
sum+=a
i+=1
a = int(input("enter the number or enter 999 to exit : "))
avg=float(sum/i)
print("sum = ",sum," average = ",avg)
print("Positive... |
11d53956ee5844db459788f17b93d07b8594243d | bhargav-s-271100/Python-Programs | /Calculator using OOPS concept.py | 1,081 | 4.1875 | 4 | class calculator:
def __init__(self,a,b):
self.c=a
self.d=b
def add(self):
return self.c+self.d
def subtract(self):
if self.c>self.d:
self.c-self.d
else:
return self.c-self.d
def multiply(self):
return self.c*self.d
... |
096bb687d79731ea6c7cfef9aace76be77c63dba | bhargav-s-271100/Python-Programs | /Checking_Validity_of_Password.py | 950 | 3.953125 | 4 | #A valid Password must follow the rules below:
# 1) It must contain at least 2 uppercase English alphabet characters.
# 2) It must contain at least 3 digits (0-9).
# 3) It should only contain alphanumeric characters (a-z , A-Z & 0-9).
# 4) No character should repeat.
# 5) There must be exactly 10 characters in ... |
a8e35e6af76379ee6ed36e521753e3ca723b9b65 | bhargav-s-271100/Python-Programs | /Exception Handling.py | 257 | 3.875 | 4 | #to add an exception to certain exceptions
try:
a=10
b=int(input("Enter the value : "))
c=a/b
print(c)
except ZeroDivisionError:
print("division by zero is not possible")
#this concept can be used to chcek the presence of modules |
bc50aa899477cfcfa1cf2400afb5a07c3c53972a | bhargav-s-271100/Python-Programs | /Alphabet A using For loop.py | 276 | 4.09375 | 4 | print("Printing alphabet A ")
for i in range(5):
print("\n")
for j in range(7):
if (i==0)or(i==1 and (j==0 or j==6))or(i==2)or(i==3 and (j==0 or j==6))or(i==4 and (j==0 or j==6)):
print("*",end="")
else:
print(" ",end="") |
0f8915c6f19c73619e5b568643b9daf214ac8791 | bhargav-s-271100/Python-Programs | /NUMPY.py | 891 | 3.96875 | 4 | #Lists are scalar datatypes and cannot be added
import numpy as np
vector_row=np.arange(10)
print(vector_row)
#matrices can be made as below
matrix=np.arange(1,10).reshape(3,3)
print(matrix)
matrix=np.arange(1,5).reshape(4,1)
print(matrix[:2])
print('\n')
print(matrix[::-1])
print('\n')
print(matrix.shape... |
5918500fa16a5982a18a9e779f0f18dd13a9dcc9 | mixotroph/FUB_SWP-2013 | /FightSystem.py | 1,435 | 3.71875 | 4 | import random
from math import exp
maxXp = 20
print("")
pxp = int(input("Your initial XP = "))
php = float(input("Your initial HP = "))
pw = [0.5, 10]
print("Your max weapon strength: "+str(pw[1])+" and its precision: "+str(pw[0]))
print("")
enxp = pxp + random.randint(0,3)
ehp = php - random.randint(0,3)
print (... |
149c3f88e1a1460c2065158c955698439e3b0467 | hayaki821/atcode | /中級者/paiza/2.py | 216 | 3.59375 | 4 | def main():
T = list(input())
if T[0] == "?":
T[0] = "D"
for i in range(1, len(T)):
if T[i] == "?":
T[i] = "D"
print("".join(T))
if __name__ == '__main__':
main()
|
9620fa9f06d5f2f5b93d5ecc08202cf52efdba0a | wogus3602/study | /윤석주/day9/JOI와IOI.py | 190 | 3.625 | 4 | string = input()
joi = 0
ioi = 0
for i in range(len(string)-2):
if string[i:i+3] == 'JOI':
joi+=1
elif string[i:i+3] == 'IOI':
ioi+=1
print(joi)
print(ioi) |
c407edbdae87dde67b53a5b2909bd7b941b94b37 | wogus3602/study | /윤석주/day4/소수 찾기.py | 512 | 3.78125 | 4 | import math
def solution(n):
answer = 0
primes = [False]*(n+1)
for number in range(2,n+1):
if primes[number]:
continue
else:
if isPrime(number):
answer+=1
for i in range(number+number,n+1,number):
primes[i] = True
return a... |
08bffcb940a10134ee5ac6a8ffe202974950fcf0 | wogus3602/study | /윤석주/day2/탑.py | 344 | 3.5625 | 4 | def solution(heights):
answer = []
for i in range(len(heights)):
height = heights[i]
step = i - 1
while step >= 0:
if heights[step] > height:
answer.append(step+1)
break
step -= 1
if step < 0:
answer.append(0)
... |
bba98a339cc3fe159b5db7a6979f37a1e6467eee | shridharkute/sk_learn_practice | /recursion.py | 668 | 4.375 | 4 | #!/usr/bin/python3
'''
This is recursion example.
recursion is method to call itself while running.
Below is the example which will create addition till we get 1.
Eg.
If we below funcation as "tri_resolution(6)" the result will be
Rcursion example result
1 1
2 3
3 6
4 10
5 15
6 21
But in the background it will execu... |
09152200002dc09e4b560002d8e68e5c654a5f12 | shridharkute/sk_learn_practice | /tasks/practice6.py | 377 | 4.09375 | 4 | #!/usr/bin/python3
'''
Question 6: Given a list of numbers, Iterate it and
print only those numbers which are divisible of 5
'''
# Solution 1
LST = input("Please type input:")
X = LST.split(",")
def DEV_5(list):
print("Below numbers are dv=ivisible by \"5\"")
for i in list:
J = int(i)
if (J % ... |
24faba36552efc52dd49b41bd20e119e661d9879 | shridharkute/sk_learn_practice | /tasks/try_ur_luck.py | 443 | 3.5 | 4 | #!/usr/bin/python3
import random
'''
Testing something
'''
USR_INPUT = int(input("Please type any fev number between 1-6 :"))
#print(random.__doc__)
#X = dir(random)
#print(X)
def jk():
KK = random.randrange(1,7, step=1)
if USR_INPUT == KK:
print(f"Ye..... . Same to same user:{USR_INPUT} rand... |
d49c5fb4f655e9040793deb412a32313db17c233 | shridharkute/sk_learn_practice | /scrap.py | 228 | 3.703125 | 4 | #!/usr/bin/python3
class myparents:
def __init__(self, name, age):
self.name = name
self.age = age
def printname(self):
print(self.name, self.age)
X = myparents("shridhar", 35)
X.printname()
|
9f5f201f15b253db6631bf333ee5b821de23ea97 | shridharkute/sk_learn_practice | /iterator.py | 566 | 4.09375 | 4 | #!/usr/bin/python3
import time
mytuple = ("shri", "kavi", "harsha")
myit = iter(mytuple)
print(next(myit))
time.sleep(1)
print(next(myit))
time.sleep(1)
print(next(myit))
time.sleep(1)
mystr = "shridhar"
myitr = iter(mystr)
print(next(myitr))
print(next(myitr))1754/
print(n... |
521b61d372e351a005221c1919dc4bacf070fe51 | shridharkute/sk_learn_practice | /if_else.py | 432 | 4.15625 | 4 | #/usr/bin/python3
a = int(input("Please type number :"))
b = int(input("Please type number :"))
if a < b:
print("%d is smaller than %d" % (a,b))
elif a < b:
print("%d is grater than %d" % (a,b))
else:
print("%d is equal to %d" %(a,b))
if a < b or a == b:
print("%d is smaller or equal to %d" %(a,b))
... |
3a4bd0defe08a0c646a07bff0f47df3c3590efc2 | cairait/flaskpractice | /app.py | 1,313 | 3.84375 | 4 |
from flask import Flask, request, render_template
app = Flask(__name__) #dunder methods are a set of predefined methods you can use to enrich your classes
# @app.route('/potato') #declerator = if you visit our website at the base directory the function below will run
# def welcome():
# return 'This is my first... |
03759dce817c59a41453e9fe44e0add24acf1103 | milchmann2/advent_of_code_2020 | /day4/day_4.py | 2,607 | 3.515625 | 4 | import re
# group each passport to a single consecutive string
# removes the new lines
def group_all_passports(passport_file):
all_passports = ['']
for line in passport_file:
line = line.rstrip()
if len(line) == 0:
all_passports.append('')
all_passports[-1] += ' ' + lin... |
38fbf765856290535759398843f111d564ad5f9a | wesjones15/numberexercise | /phonenumbers.py | 1,134 | 3.875 | 4 | # takes in phone number
# convert number into array
# convert each number into 3 possible letters
# find words from the letters
import itertools
wordFile = open('words.txt', 'r')
lines = wordFile.read().split()
def sentence_maker(phoneNumber):
numberList = [int(d) for d in str(phoneNumber)]
letterList = ["", ... |
2452a8192a32b543ed58c2e65a91c2c3b4f5b8e9 | ximenshaoshao/Learn_python | /quadratic.py | 605 | 3.96875 | 4 | import math
def main():
print("Let us finds the solutions to a quadratic\n")
a, b, c = eval(input("Do enter the coefficents (a, b, c) in (ax*x + bx + c): "))
delta = b*b - 4 *a *c
if a == 0:
x = -b/c
print("\nThere is an solution",x)
elif delta < 0:
print("\nThe equation has ... |
a47979ccf0368c5ebe3777128e6fd738c7096787 | ximenshaoshao/Learn_python | /function_exercise_structure.py | 582 | 3.859375 | 4 | def createTable(principal, apr):
for year in range(1, 11):
principal = principal * (1 + apr)
print("%2d"%year, end = '')
total = calculateNum(principal)
print("*" * total)
print(" 0.0K 2.5K 5.0K 7.5K 10.0K")
def calculateNum(principal):
total = int(principal*4/10... |
ae7ab4c88f39498c7a29026456deb0c4805a781f | AdilYunus/Class5-Python-Module-Week3 | /3-alphabetical_order.py | 109 | 3.5625 | 4 | def sirala():
list1 = map(str, input().split('-'))
print("-".join(i for i in sorted(list1)))
sirala() |
3b65b2d228b0c9ca5cb33a94d33ea1303b52afb3 | VarunDhanak/hadoop-mapreduce | /src/05-mrjob-runners/wordcount.py | 472 | 3.5 | 4 | __author__ = 'alexcomu'
from mrjob.job import MRJob
import re
# Word frequency from book
# File: 04_book.txt
# regular expression used to identify word
WORD_REGEXP = re.compile(r"[\w']+")
class MRWordFrequency(MRJob):
def mapper(self, _, line):
# use regex instead simple split
words = WORD_REGEX... |
62ede4e3898bf4bade1748f3b2f3006722d64568 | aspcodenet/iot-loops | /PythonLabbarLoops/Labb8.py | 321 | 3.859375 | 4 | def GetIntValue():
while True:
try:
val = int(input("Ange ett värde"))
return val
except:
print("Ange ett TAL för sjutton")
tal = GetIntValue()
if tal > 30:
print("Du har matat in ett ogiltigt tal")
else:
for i in range(tal,30):
print(i+1)
|
600409d5897e5a6a2a8fa5900a8ca197abf294f7 | DAVIDCRUZ0202/cs-module-project-recursive-sorting | /src/searching/searching.py | 798 | 4.34375 | 4 | # TO-DO: Implement a recursive implementation of binary search
def binary_search(arr, target, start, end):
if len(arr) == 0:
return -1
low = start
high = end
middle = (low+high)//2
if arr[middle] == target:
return middle
if arr[middle] > target:
return binary_search(ar... |
1e4ecc5c66f4f79c0f912313acd769edb3a92008 | harshal-jain/Python_Core | /22-Lists.py | 1,980 | 4.375 | 4 | list1 = ['physics', 'chemistry', 1997, 2000]
list2 = [1, 2, 3, 4, 5, 6, 7 ]
"""
print ("list1[0]: ", list1[0]) #Offsets start at zero
print ("list2[1:5]: ", list2[1:5]) #Slicing fetches sections
print ("list1[-2]: ", list1[-2]) #Negative: count from the right
print ("Value available at index 2 : ", list1[2])
list1[... |
fef7b1b328a3642bd8b88832c320f70c2c85a4c5 | harshal-jain/Python_Core | /14E3-pass.py | 207 | 3.828125 | 4 | # for i in range(1,10):
# if(i==5):
# pass
#
# print(i)
for i in 'Python':
if i == 'h':
pass
print ('This is pass block')
print ('Current Letter :', i)
print ("Good bye!") |
c39ffe4f4cad9f6c4104cb6c5685a87bc5bc15b1 | harshal-jain/Python_Core | /30D-PointerPosition.py | 462 | 3.828125 | 4 | # Open a file
fo = open("foo.txt", "r+")
str = fo.read(10)
print ("Read String is : ", str)
# Check current position
position = fo.tell()
print ("Current file position : ", position)
# Reposition pointer at the beginning once again
# seek(character position , file position 0= beginning of the file and 1 =current posi... |
b3a4e8465efd619fda8f45fc63902119d69f02c1 | harshal-jain/Python_Core | /3E5-AreaOfCircle.py | 75 | 3.828125 | 4 | r=input("Enter the radius of circle")
area = 3.14*int(r)*int(r)
print(area) |
f773bee12c1c94be5a6de0ef55a6a707df847cbd | harshal-jain/Python_Core | /7-OperatorBiteise.py | 835 | 3.90625 | 4 | # a=0b1011
# b=0b1000
# print(a&b)
# print(bin(a&b)) #Binary AND
# print(bin(a|b)) #Binary OR
# print(a^b) # XOR
# print(bin(a^b)) #Binary AND
# print(bin(~a)) #Binary Ones Complement
# print(bin(a<<2)) #Binary Left Shift
# print(bin(a<<4))
# print(bin(a>>2)) #Binary Right Shift
# print(bin(a>>4))
#
a = 10 ... |
45e4c37e0779ab67aa6e64c141839f51b31c04d0 | harshal-jain/Python_Core | /Rough1.py | 506 | 3.90625 | 4 | class Employee:
empcount=0
name=''
salary=0
def __init__(self):
Employee.empcount+=1
def displayCount(self):
print("Total number of count:%d"%Employee.empcount)
def displayEmployee(self):
print("Name:",Employee.name,"Salary=%d"%Employee.salary)
emp1=Employee()
emp2=E... |
7e83b820781b6c392f72c9bd3163ff1605abdef0 | harshal-jain/Python_Core | /15E5-table_of_n.py | 95 | 3.796875 | 4 | n=int(input("Enter the number of which u want the table"))
for i in range(1,11):
print(n*i) |
133084437676122b864830178de1376bb283c02b | shaunharker/pyCHomP | /src/pychomp/Braids.py | 5,833 | 3.609375 | 4 | ### Braids.py
### MIT LICENSE 2016 Shaun Harker
from pychomp._chomp import *
from collections import defaultdict
import matplotlib.pyplot as plt
import numpy as np
class BraidDiagram:
def __init__(self, braid_skeleton):
"""
Inputs:
braid_skeleton : a list of lists such that
braid_skeleton[i... |
545d738bf8bac07fde579ce8b31fc303c2dac9ff | jlramalheira/sudoku | /sudoku/coloring.py | 11,193 | 3.78125 | 4 | """Graph coloring algorithms."""
import networkx as nx
from math import sqrt
from queue import *
import random
def welsh_powell(graph):
"""Runs the Welsh-Powell algorithm to color a graph.
Arguments:
graph (networkx.Graph): a graph.
"""
def _welsh(graph):
for node in graph.node:
... |
55914980f3a0157d3d7c88a9ff619b87f66c3213 | hyeinlee725/Python_2018 | /Temperature/temperature.py | 741 | 3.640625 | 4 | from tkinter import *
def f2c(): #화씨->섭씨
temp = float(e1.get())
mytemp = (temp-32)*5/9
e2.insert(0, str(mytemp))
def c2f(): #섭씨->화씨
# 아래를 완성하시오.
temp = float(e2.get())
mytemp = (temp*9/5)+32
e1.insert(0, str(mytemp))
window = Tk()
l1 = Label(window , text="화씨")
l2 = Label(window,... |
50a5094f20a22db55e53f9e160b5363e9a4abdee | hyeinlee725/Python_2018 | /Practice Python/calc_xy.py | 233 | 3.828125 | 4 | x=int(input("x:"))
y=int(input("y:"))
print("두 수의 합: ",x+y)
print("두 수의 차: ",x-y)
print("두 수의 곱: ",x*y)
print("두 수의 평균: ",(x+y)/2)
print("큰 수: ", max(x,y))
print("작은 수: ",min(x,y))
|
dad02d4fccdf46a130dd59c375cceb36ce7341b7 | syamilisn/Python-Files-Repo | /WillPower/tryexcept.py | 465 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun May 3 18:41:08 2020
@author: shyam
Try & Except
"""
#divide by zero error
try:
a=12
b=0
c=a%b
print(c)
#not recommended
except:
print("Invalid")
try:
a=12
b=0
c=a/b
print(c)
#recommended
except ZeroDivisionError:
print("deno... |
629d8492145a44ec0158c7cde99fc7683eaf52ba | syamilisn/Python-Files-Repo | /WillPower/crowdcomp.py | 1,886 | 3.65625 | 4 | """
Crowd Computing
Estimation of average trimmed mean
IMPORTING LIBRARIES
"""
#importing mean function
from statistics import mean
from scipy import stats
import matplotlib.pyplot as plt #last lines
import statistics #last lines
list=[100,212,90,78,2323,67,342,12,34,565,45,78,123,678,345,123,765,234,123,234,432,56,34,... |
a9086d675b546fc89956992bc8e6f99986d4c71a | syamilisn/Python-Files-Repo | /WillPower/decision.py | 1,089 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun May 3 17:39:28 2020
@author: shyam
if-else stat
comparison operators
"""
#simple if-else
c=30
if(c>20):
print("c is greater than 20")
else:
print("c is lesser than 20")
if(True):
print("print")
if True:
print("print")
yes= True
no= False
Maybe= Tru... |
99fc48aa598fc473abbbf456d35fb705994c1b52 | syamilisn/Python-Files-Repo | /WillPower/mathmod.py | 530 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun May 3 15:23:16 2020
@author: shyam
functions user-defined and built-in
"""
#math is one of the module
from math import *
#Defining a function
def add():
a=input("Enter value 1: ")
b=input("Enter value 2: ")
print(int(a)+int(b))
#calling the function
ad... |
e578e16ee1cf342a67e195d3d1cf2c0b5a120c00 | syamilisn/Python-Files-Repo | /systemSoftware/sample.py | 83 | 3.515625 | 4 | dict={1:"we",2:"i"}
print(dict)
a=4
asval="they"
dict.update({a:asval})
print(dict) |
2e724ad683c629a8a4a46a9341b12223948fac9c | pdecks/ajax-db-example | /model.py | 3,614 | 3.640625 | 4 |
"""Sample file demonstrating SQLAlchemy joins & relationships."""
from flask_sqlalchemy import SQLAlchemy
# This is the connection to the SQLite database; we're getting this
# through the Flask-SQLAlchemy helper library. On this, we can find
# the `session` object, where we do most of our interactions
# (like commi... |
71356cbfce0df685f7b02f7b719289bd3b395b21 | Sarayin/Ejercicios-de-trabajo | /ejercicio 12.py | 559 | 4.125 | 4 | '''Escribir una función que, dado un string,
retorne la longitud de la última palabra.
Se considera que las palabras están separadas
por uno o más espacios. También podría haber espacios
al principio o al final del string pasado por parámetro.'''
def lenramiro(frase):
if len(frase)==0:
return 0
... |
0a9e0166f97ef212f4cd5ce703f42713934c6766 | Sarayin/Ejercicios-de-trabajo | /ejercicio 1.py | 298 | 3.96875 | 4 | def validar(email):
caracterBuscado="@"
emailValido=False
for c in email:
if c==caracterBuscado:
return True
return False
direccion=input("Tu email: ")
if validar(direccion):
print("Dirección válida")
else:
print("Dirección inválida") |
67d27dc65ff584319cbb0f977ee1fb5a58182ab9 | mikonnikova/Noun_groups | /find_noun_groups.py | 3,872 | 3.953125 | 4 | import pickle
import sys
# find a group for a given noun
# takes in:
# position of a noun
# list of trios (word, its root, POS tag) for all words in a sentence
# returns:
# a noun group as a sorted by numbers list of positions of its members
def make_group(roots, noun):
group = [noun] # mem... |
9d46e9c0e579f3d4c13252004ffb4130c1bb9491 | shraykay/interview | /nopsec/listSorting.py | 5,235 | 4.125 | 4 | import argparse
import os
import re
import sys
from collections import OrderedDict
class list_sorting(object):
""" Class sorts a list based on its type of data and writes to output file
For example: 1, 5, dog, 3, cat, 0
Results in: 0, 1, cat, 3, dog, 5
Command line arguments:
Input file, Out... |
7684f48a7398a74e3746eea3d59c26571460fc1e | shraykay/interview | /getAround/math.py | 1,843 | 3.609375 | 4 | import re
def removeval(list, x):
return [value for value in list if value != x]
line = '5*6/3+1'
regex = '(\*|\/|\+|\-)'
store = re.split(regex, line)
for x in range(len(store)):
if '.' in store[x]:
store[x] = float(store[x])
elif store[x].isdigit():
store[x] = int(store[x])
print store
def div(stores)... |
3effe1cdf5abbdbc582e6f8d55a3bcb808cd10f6 | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 06/ProgrammingExercises/08_prime_numbers.py | 770 | 3.96875 | 4 | # A prime number is a number that is only evenly divisible by itself and 1.
# For example, the number 5 is prime because it can only be evenly divided by
# 1 and 5. The number 6, however, is not prime because it can be divided
# evenly by 1, 2, 3, and 6.
#
# Write a Boolean function named is_prime which takes an intege... |
67394454fb2e9a74589d10e212c5e5735fd77881 | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 07/7-01_file_write.py | 376 | 3.796875 | 4 | # This program writes three lines of data
# to a file.
def main():
# Open a file named animalsounds.txt.
outfile = open('animalsounds.txt', 'w')
# Write the sounds of three animals
# to the file.
outfile.write('Moo.\n')
outfile.write('Woof.\n')
outfile.write('Meow.\n')
# Close the file... |
b253f828fc56c2f9e7148e13ae2a910c542f1249 | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 05/ProgrammingExercises/03_budget_analysis.py | 1,540 | 4.40625 | 4 | # Write a program that asks the user to enter the amount that they have
# budgeted for a month. A loop should then prompt the user to enter each of
# their expenses for the month, and keep a running total. When the loop
# finishes, the program should display the amount that the user is over
# or under budget.
def budg... |
88cfb1d6b2746e689d6a661caa34e5545f044670 | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 04/ProgrammingExercises/09_shipping_charges.py | 1,098 | 4.4375 | 4 | # The Fast Freight Shipping Company charges the following rates:
#
# Weight of Package Rate per Pound
# 2 pounds or less $1.10
# Over 2 pounds but not more than 6 pounds $2.20
# Over 6 pounds but not more than 10 pounds $3.70
#... |
4d24d83ec69531dd864ef55ed900a6d154589fd8 | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 03/ProgrammingExercise/04_automobile_costs.py | 1,248 | 4.34375 | 4 | # Write a program that asks the user to enter the monthly costs for the
# following expenses incurred from operating his or her automobile: loan
# payment, insurance, gas, oil, tires, and maintenance. The program should
# then display the total monthly cost of these expenses, and the total
# annual cost of these expens... |
4225bff6ebb5315e317f5ea02af48e5943045d04 | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 05/ProgrammingExercises/10_pattern2.py | 239 | 3.984375 | 4 | # Write a program that uses nested loops to draw this pattern:
# ##
# # #
# # #
# # #
# # #
# # #
NUM_STEPS = 6
for r in range(NUM_STEPS):
print('#', end='')
for c in range(r):
print(' ', end='')
print('#')
|
36e179b5db4afaf4b7bc2b6a51f0a81735ac2002 | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 06/ProgrammingExercises/01_feet_to_inches.py | 521 | 4.40625 | 4 | # One foot equals 12 inches. Write a function named feet_to_inches that
# accepts a number of feet as an argument, and returns the number of inches
# in that many feet. Use the function in a program that prompts the user
# to enter a number of feet and then displays the number of inches in that
# many feet.
def main()... |
a8bf3cc39005180b6d3b2d18a751c43f3665ec23 | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 07/ProgrammingExercises/09_exception_handling.py | 348 | 4.125 | 4 | # Modify the program that you wrote for Exercise 6 so it handles the following
# exceptions:
# • It should handle any IOError exceptions that are raised when the file is
# opened and data is read from it.
# • It should handle any ValueError exceptions that are raised when the items
# that are read from the file are... |
8b5c16af801a7e159f898ff9c30bc2f955c9ee9e | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 03/ProgrammingExercise/05_property_tax.py | 809 | 4.03125 | 4 | # A county collects property taxes on the assessment value of property,
# which is 60 percent of the property’s actual value. For example, if
# an acre of land is valued at $10,000, its assessment value is $6,000.
# The property tax is then 64¢ for each $100 of the assessment value.
# The tax for the acre assessed at $... |
3d4cba89be0858b757da7c59a4845ab4360d28d3 | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 06/ProgrammingExercises/05_kinetic_energy.py | 1,110 | 4.40625 | 4 | # In physics, an object that is in motion is said to have kinetic energy (KE).
# The following formula can be used to determine a moving object’s kinetic
# energy:
#
# KE = (1/2) * m * v^2
#
# The variables in the formula are as follows: KE is the kinetic energy in
# joules, m is the object’s mass in kilogr... |
d1c70ad3f6c14cebeb38524f706b6142b2d5f95c | cosmos512/PyDevoir | /StartingOutWithPy/Chapter 06/ProgrammingExercises/10_future_value.py | 849 | 3.734375 | 4 | # Suppose you have a certain amount of money in a savings account that earns
# compound monthly interest and you want to calculate the amount that you will
# have after a specific number of months. The formula is
#
# F = P * (1 + i)^t
#
# The terms in the formula are as follows:
# • F is the future value of the... |
8244b00f39011e8813d49fd26c81c73174ba65e7 | kescalante01/learning-python | /PBJGoal4Solution.py | 710 | 4.0625 | 4 | print "How many slices of bread do you have"
bread = raw_input()
print "How many scoops of peanut butter do you have?"
peanut_butter = raw_input()
print "How many scoops of jelly do you have?"
jelly = raw_input()
bread = int(bread)
peanut_butter = int(peanut_butter)
jelly = int(jelly)
print "So you have %s slices of ... |
8cccedbab97b4439c53bbec5f443011066947897 | kescalante01/learning-python | /Address.py | 867 | 4.28125 | 4 | #Use raw_input() to allow a user to type an address
#If that address contains a quadrant (NW, NE, SE, SW), then add it to that quadrant's list.
#Allow user to enter 3 addresses; after three, print the length and contents of each list.
ne_adds = []
nw_adds = []
se_adds = []
sw_adds = []
address1 = raw_input("Whats y... |
fc2d736d883a7d0c123b770f45b03f0550bee167 | nicolair/IPT2 | /Cmultruss.py | 303 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 11 17:17:38 2017
@author: remy
"""
def multruss(a,b):
m = 0
while b > 0:
if b % 2 == 1:
m += a
b -= 1
else:
a *= 2
b = b //2
return m
print(multruss(6,7)) |
b38cd1340af90a954a479232182ee4cbe95ed3d5 | nicolair/IPT2 | /intronumer.py | 595 | 3.765625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 25 20:58:51 2018
@author: remy
"""
# Numération par les quotients.
b = 10
x = 200
#p puissance de b
#recherche du plus gd p <= x
p = 1
q = p * b
while q <= x:
p = q
q = p * b
#formation du dvloppement
resultat = ''
while p >= 1:
resulta... |
2e1f64b66ec5e93bfe23c50d166457e4d4ce799f | doboy57/CSV | /sitka 2.py | 831 | 3.53125 | 4 | import csv
import matplotlib.pyplot as plt
from datetime import datetime
open_file = open("sitka_weather_07-2018_simple.csv", 'r')
csv_file = csv.reader(open_file, delimiter=',')
header_row = next(csv_file)
print(type(header_row))
for index, column_header in enumerate(header_row):
print(index, column_header)
myd... |
d8cf0566540447620b93cf40f0a3a7cb25726e90 | xxxxxxxxzhang/Wannafly-zzx | /python/chapter01/spider_book.py | 721 | 3.765625 | 4 | from chapter01.spider_JD import spider as jd
from chapter01.spider_dangdang import spider as dd
def main(sn):
""" 图书比价工具"""
book_list = []
# 当当网的图书数据
dd(sn, book_list)
print('当当网数据爬取完成')
# 打印所有数据列表
# 京东网数据
jd(sn, book_list)
print('京东网数据爬取完成')
for book in book_list:
pri... |
cd61a6239f60a67670face87221aa28761e38624 | MarwaQabeel/Data-Structures-and-Algorithms-Nanodegree | /3. Problems vs. Algorithms Project/rearrange_array_digits.py | 1,594 | 3.875 | 4 | def rearrange_digits(input_list: list):
input_list = sorting_function(input_list)
num1: str = ""
num2: str = ""
for i in range(0, len(input_list), 2):
num1 = str(input_list[i]) + num1
try:
num2 = str(input_list[i + 1]) + num2
except ... |
15e748a72d65e156856ef84264c8700e9e7e3c83 | uciharis/Udemy-dletorey | /Python Programming Masterclass/Python/Squences/joining_things.py | 228 | 4.125 | 4 | flowers = [
"Daffodil",
"Crocus",
"Iris",
"Tulip",
"Rose",
"Lily",
]
# for flower in flowers:
# print(flower)
separator = " | "
output = separator.join(flowers)
print(output)
print(",".join(flowers)) |
c35d5a53082c8b2a8267fe886557c316129a2efd | uciharis/Udemy-dletorey | /Python Programming Masterclass/Python/HelloWorld/repFields.py | 398 | 4.0625 | 4 | age =50
print("My age is " + str(age) + " years") # str(age) coerces an integer into a str
print("My age is {0} years".format(age))
print("there are {0} days in {1}, {2}, {3}, {4}, {5}, {6} and {7}"
.format(31, "jan", "Mar", "May", "July", "Aug", "Oct", "Dec"))
print("J: {2}, F: {0}, M: {2}, A: {1}, M: {2}, J: {1... |
cc0870047f7b2545f7103433afefdf6542e5b02b | uciharis/Udemy-dletorey | /Python Programming Masterclass/Python/FlowControl/trueFalse.py | 709 | 4 | 4 | # day = "Saturday"
# temperature = 30
# raining = False
#
# if (day == "Saturday" and temperature > 27) and not raining: # the brackets show precedence
# print("Go swimming")
# else:
# print("Learn Python")
# exercise 53 Truthy Values
# if 0:
# print("True") #this will never happen because in a condition ... |
e310082843d26385b715939fb6690365b8864576 | uciharis/Udemy-dletorey | /Python Programming Masterclass/Python/Squences/challenge_120.py | 426 | 3.53125 | 4 | generated_list = ['9', '234', '5343', '2214', '32', '324', '23423', '54']
print(generated_list)
print([int(val) for val in generated_list])
print(generated_list)
print("-" * 10)
integer_values = []
for value in generated_list:
integer_values.append(int(value))
print(integer_values)
print("-" * 10)
for index in r... |
cdb990241974642808e6f9928e2ac4385ee00942 | cotutubo/test | /procces.py | 778 | 3.578125 | 4 | # -*- coding: utf-8 -*-
import re
import sys
import random , time, commands
from threading import Thread
start_time = time.time()
def main():
def aho(a,b):
if b == 0: return a
return aho(b, a % b)
print aho(167,100)
def kuso(a,b):
while b > 0:
a,b = b, a % b
... |
6d72e4e2ce4447de1dfee99def28204c089f7faf | riteshsingh1/learn-python | /string_function.py | 406 | 4.34375 | 4 | string="Why This Kolaveri DI"
# 1
# len(string)
# This function returns length of string
print(len(string))
# 2
# In Python Every String is Array
string = "Hello There"
print(string[6])
# 3
# index()
# Returns index of specific character / Word - First Occurance
string="Python is better than PHP."
print(string.inde... |
da502fbe84cb80545766d60f6fd73ae88c35bbca | BIRlz/Machine-Learning | /LinearRegression/LinearRegressionWithMultiple/LinearRegressionwithMultiple.py | 3,836 | 3.53125 | 4 |
# coding: utf-8
# ## 多变量线性回归(Linear Regression with Multiple Variables)
# In[4]:
#初始化工作
import random
import numpy as np
import matplotlib.pyplot as plt
# This is a bit of magic to make matplotlib figures appear inline in the notebook
# rather than in a new window.
#get_ipython().magic('matplotlib inline')
plt.fig... |
7e43196833d60a58207c5c7a5a0f13249021080f | petterho/INF200-2019-Exersices | /src/petter_bøe_hørtvedt_ex/ex04/myrand.py | 1,809 | 3.921875 | 4 | # -*- coding: utf-8 -*-
__author__ = 'Petter Bøe Hørtvedt'
__email__ = 'petterho@nmbu.no'
import time
class LCGRand:
"""
A class for a linear congruential generator
"""
def __init__(self, seed=time.time()):
"""
Initialisation
Parameters
----------
seed: floa... |
5c86a20cfe8e494467250510838def937ccfff24 | petterho/INF200-2019-Exersices | /src/petter_bøe_hørtvedt_ex/ex01/comp_to_loop.py | 218 | 3.90625 | 4 | def squares_by_comp(n):
return [k**2 for k in range(n) if k % 3 == 1]
def squares_by_loop(n=10):
squares = []
for k in range(n):
if k % 3 == 1:
squares.append(k**2)
return squares
|
004151a07dfb24282092f4deff39b88f83815e17 | luani86/Introduction-to-data-science | /py_data_science/week_3/3_3_group-by.py | 1,992 | 3.609375 | 4 | ########################## Spliting the data
import numpy as np
import pandas as pd
df = pd.read_csv('census.csv')
df = df[df['SUMLEV'] == 50]
df = df.set_index('STNAME')
# Does not work!!!
# for state in df['STNAME'].unique():
# avg = np.average(df.where(df['STNAME'] == state).dropna()['CENSUS2010POP'])
... |
9913ccfcd4b12de34d954b307f7c1dc17d2e491b | dzupin/pythonPostgres | /createPostgresDatabase.py | 1,097 | 3.53125 | 4 | # -*- coding: utf-8 -*-
# reference link: http://zetcode.com/db/postgresqlpythontutorial/
import databaseProperties
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
Host=databaseProperties.Host
User=databaseProperties.User
Password=databaseProperties.Password
Dbname=databaseProperties.DbnameDe... |
5a5da98295e5efb7edbd09119b0650eb205aa087 | wright-group/WrightTools | /examples/map-variable.py | 1,217 | 3.65625 | 4 | """
Map-Variable
============
An example of how map-variable works.
"""
import numpy as np
from matplotlib import pyplot as plt
import WrightTools as wt
# create original arrays
x = np.linspace(1, 5, 11)[:, None]
y = np.linspace(1, 5, 11)[None, :]
arr = np.exp(-1 * (((x - 3) / 0.6) ** 2 + ((y - 3) / 0.6) ** 2))
# cr... |
d48c031141179f22a16901dfbbf0697721e858be | j4grmeister/algo-trader | /test.py | 446 | 3.609375 | 4 | from threading import Thread
import time
MAX = 1000
delay = .02
class TestThread(Thread):
def __init__(self, n):
super().__init__()
self.n = n
def run(self):
time.sleep(self.n*delay)
while(True):
print(self.n)
time.sleep(MAX*delay)
threads = []
fo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.