blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
fbe95cda2cecaa83679659e6672a5ce8eb48c30e | jingong171/jingong-homework | /李鑫屿/2017310393-李鑫屿-第五次作业-金工17-1/10.6 7.py | 281 | 3.84375 | 4 | while True:
num1=input("请输入第一个数字")
num2=input("请输入第二个数字")
try:
num1=int(num1)
num2=int(num2)
except ValueError:
print("只可以输入数字")
continue
else:
print(num1+num2)
break
|
cfacc8e336bcbc7ed87f7297cd6e441e538f7762 | jingong171/jingong-homework | /程佳昕/2017310402第五次作业金工171程佳昕/2017310402第五次作业金工171程佳昕/8,9/silent cats&dogs.py | 902 | 3.828125 | 4 | #10—8
print('cats&dogs')
def animal_names(filename):
"""打印文件储存的动物名"""
#捕捉FileNotFound'错误并打印友好的信息
try:
with open(filename) as file_obj:
contents=file_obj.read()
print(contents+'\n')
except FileNotFoundError:
message="没有找到"+filename
print(message)
fil... |
8a69125ed90d22be73a01ff4223902b0c6210e30 | jingong171/jingong-homework | /苏兰/2017310419第四次作业 金工17-1 苏兰/2017310419第四次作业 金工17-1 苏兰/restaurant.py | 2,214 | 4.34375 | 4 | """一组用于表示餐厅和冰激凌餐厅的类"""
class Restaurant():
"""创建一个restaurant类"""
def __init__(self,restaurant_name,cuisine_type):
"""初始化属性name,type"""
self.restaurant_name=restaurant_name
self.cuisine_type=cuisine_type
self.number_served=0
def describe_restaurant(self):
"""打印r... |
cea3c5ac7c2c7f24a9494370f2f2a0e150ca7855 | jingong171/jingong-homework | /樊宇宸/2017310401樊宇宸第二次python作业/2.py | 391 | 3.515625 | 4 | #输入两个正整数m,n
m=int(input())
n=int(input())
#将m,n赋值给a,b
a=m
b=n
#对a,b进行辗转相除求的最大公约数p
while(a!=0)and(b!=0):
if a>b:
a=a%b
else:
b=b%a
if a==0:
p=b
else:
p=a
print(p)
#p是m,n的最大公约数,那么显然m/p,n/p是m,n的互质的因数,三者相乘必为最小公倍数
print(int(p*(m/p)*(n/p)))
|
e73e46764a242e31fdc2d95ace09d3e42889bdca | jingong171/jingong-homework | /尤焕雄/2017310411 尤焕雄 第三次作业 金工171/日历.py | 1,815 | 3.921875 | 4 | def getdaysofcertainyear(year):
"""求某一年的天数"""
if year%4==0 and year%100!=0:
a=366
elif year%100==0 and year%400==0:
a=366
else:
a=365
return a
def getdaysofyears(year):
"""求到1990年的整年部分的天数"""
if year==1990:
return 0
else:
return getdaysofcertainyear... |
c26f76ff99d88f37e10f5b26bd012569bed4fa8c | jingong171/jingong-homework | /曾程/2017310414-第三次作业-金工171-曾程/日历.py | 2,704 | 3.859375 | 4 | LeapYearMonthDays=[31,29,31,30,31,30,31,31,30,31,30,31]#闰年各月天数
MonthDays=[31,28,31,30,31,30,31,31,30,31,30,31] #非闰年各月天数
Months=["Januray","February","March","April","May","June",
"July","August","September","October","November","December"]#各月名称
def getMonthStartDay(TotalDays):#计算给定月第一天是星期几
return 1+... |
0db94c41b76102f8eacf5c4b17f14c199e15967e | jingong171/jingong-homework | /樊宇宸/第一次作业/第一次作业-金融工程17-1-2017310401-樊宇宸/1.py | 161 | 3.53125 | 4 | w=60
h=1.78
t=w/h**2
if t < 18:
print('低体重')
elif t <= 25:
print('正常体重')
elif t <= 27:
print('超重体重')
else:
print('肥胖')
|
b63dacb4f0ae676cb0bf1a26eb7300aad85de185 | jingong171/jingong-homework | /曹雨晗/2017310394-曹雨晗-第四次作业-金工17-1/2017310394-曹雨晗-第四次作业-金工17-1/骰子.py | 334 | 3.5625 | 4 | class Die():
def __init__(self,sides):#规定骰子的面数以及默认面数
self.sides=6
def roll_die(self):#编写一个摇骰子的方法
from random import randint
x=randint(1,self.sides)
print(x)
die=Die("6")#定义一个骰子的类
for i in range(1,11):
die.roll_die()
i=i+1
|
2a5755f34c84b911c0182544fab1e4d395ef773b | jingong171/jingong-homework | /曹雨晗/第一次作业/第一次作业-金工17-1-2017310394-曹雨晗/水仙花数.py | 127 | 3.671875 | 4 | for a in range(1,10):
for b in range(0,10):
for c in range(0,10):
d=a*100+b*10+c
if d == a**3+b**3+c**3:
print(d)
|
5b134f1d9157c85a83c462dcb65047a1c261233f | jingong171/jingong-homework | /程佳昕/2017310402第五次作业金工171程佳昕/2017310402第五次作业金工171程佳昕/11,12/10-11/10-11-1.py | 239 | 3.515625 | 4 | #要求用户输入一个最喜欢的数字并把这个数字储存起来
import json
fav_num=input("请输入一个你最喜欢的数字:")
filename='favorite_number.json'
with open(filename,'w')as f_obj:
json.dump(fav_num,f_obj)
|
ce4cef7891dd20d77764e1e5e386c1f36f108816 | jingong171/jingong-homework | /龚鑫/第一次作业/第一次作业-金工一班-2017311575-龚鑫/体重指数.py | 252 | 3.71875 | 4 | w=eval(input("请输入你的体重: "))
h=eval(input("请输入你的身高: "))
t=w/(h**2)
if t<18:
k="低体重"
if t>=18 and t<=25:
k= "正常体重"
if t>27:
k= "肥胖"
print("你的体重指数为{},属于{}".format(int(t),k))
|
26d826b5d08dd52aefbbe53bac1734a47d08bd46 | jingong171/jingong-homework | /张璟玥/第一次作业/第一次作业 张璟玥 2017310399/3.py | 246 | 3.734375 | 4 | numbers=[]
for x in range(100,1000):
a = (x - x%100)/100 #获取百位数字
c = (x - 100*a)%10 #获取个位数字
b = (x - c - a*100)/10 #获取十位数字
if x == a**3 + b**3 + c**3:
numbers.append(x)
print(numbers) |
75277b43782ca8c2a11f0abd2e5aef1db774ee78 | jingong171/jingong-homework | /邓阳馨/2017310412第五次作业金工17-1邓阳馨/cats_dogs.py | 674 | 4.25 | 4 |
def show_names(filename):
"""show the name in txt"""
try:
with open(filename)as file_object:
contents=file_object.read()
except FileNotFoundError:
msg = "Sorry, the file " + filename + " does not exist."
print(msg)
else:
print(filename+"\n"+contents)
##沉默的猫和... |
be77ec07900245b59ab066bba8d9670e6f757469 | jingong171/jingong-homework | /孔怡/2017310397 孔怡 第二次作业 金工17-1/question_1.py | 110 | 3.703125 | 4 | numbers = []
for value in range(3,31,3):
number = value**2
numbers.append(number)
sum(numbers)
|
559ca43598b4d3f01148e1195919dae0177ff0a2 | jingong171/jingong-homework | /王中昊/第二次作业/第三题.py | 218 | 3.75 | 4 | for num in range(1,2001):
numbers_2=[]
for num_2 in range(1,2000):
if num>num_2:
t=num%num_2
if t==0:
numbers_2.append(num_2)
if num==sum(numbers_2):
print(str(num)+',')
|
b07786a4479a707cd3103b9bf9f88e31cbdecccd | jingong171/jingong-homework | /王中昊/2017310389第三次作业金工17-1王中昊.py | 3,169 | 4.09375 | 4 | year=int(input("请输入年:"))
month=int(input("请输入月份:"))
#输入年月
months={1:'January',2:'Feburary',3:'March',4:'April',5:'May',6:'June',7:'July',8:'August',9:'September',10:'October',11:'November',12:'December'}
#设置月份对应的英文
monthday={1:31,2:0,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
#设置除2月外每月对应的天数
print(" \t"+str... |
f3977acf3cc17f50f114a73fa5c38e2764df6920 | jingong171/jingong-homework | /曹雨晗/2017310394-第五次作业-金工17-1-曹雨晗/2017310394-第五次作业-金工17-1-曹雨晗/加法运算&加法计算器.py | 497 | 4.03125 | 4 | while True:
print('Enter q to quit')
firstnumber = input('Please enter the first number:')
if firstnumber == 'q':
break
secondnumber = input('Please enter the second number:')
if secondnumber == 'q':
break
#下面进行ValueError的错误处理
try:
sum = int(firstnumber) + int(secondn... |
a34f0ec779650491789288b7cb56ed0cfe09072b | jingong171/jingong-homework | /王琨/第一次作业 金工17-1 2017310410 王琨/第四题.py | 160 | 3.59375 | 4 | prime_n=[];
a=2
for a in range(2,100):
b=2
for b in range(2,a):
if a%b==0:
break
else:
prime_n.append(a)
print(prime_n)
|
baa4b19cdbadc62046e591a5341c699962d7a073 | jingong171/jingong-homework | /王瑾喆/第二次作业/1.py | 138 | 3.578125 | 4 | squares=[value**2 for value in range(3,31,3)]
sum_square=sum(squares)
print(sum_square)
|
b05cb654dde91edcc0cbd0a2bb2b93904c584f58 | jingong171/jingong-homework | /吴松奇/第一次作业/第一次作业—金工17-1—2017310395—吴松奇/水仙花数.py | 173 | 3.734375 | 4 | numbers=list(range(100,1000))
for number in numbers:
a=number//100
b=(number-100*a)//10
c=number-100*a-10*b
if number==a**3+b**3+c**3:
print(number)
|
1347cdbe1d4f7ca7d13ce1ac413e195db2fc9104 | jingong171/jingong-homework | /孙林轩/2017310392 孙林轩 py第二次作业/完数.py | 232 | 3.5 | 4 | all_num=list(range(1,2001))
num=3
perfect_num=[]
for num in all_num:
k=0
for i in list(range(1,num)):
rest=num%i
if rest==0:
k=k+i
if k==num:
perfect_num.append(num)
print(perfect_num) |
f387bc5f9a049798ebb39eca240fc17cac82dca6 | jingong171/jingong-homework | /樊宇宸/2017310401樊宇宸第二次python作业/4.py | 606 | 3.953125 | 4 | cities={
'Beijing':{
'country':'China',
'population':'2173w',
'fact':'famous'
},
'Tokyo':{
'country':'Japan',
'population':'1350w',
'fact':'quiet'
},
'Paris':{
'country':'France',
'population':'1100w',
'fact':'romantic'
... |
816481715c6f682fa01eb586568faf96d8c71dc9 | jingong171/jingong-homework | /夏丽平/第一次作业/第一次作业-金工17-1 -2017310413--夏丽平/夏丽平 金工17-1 2017310413/zy1.py | 162 | 3.609375 | 4 | w=48
h=1.53
t=w/(h**2)
if t<18:
print("低体重")
elif t<=25:
print("正常体重")
elif t<=27:
print("超重体重")
elif t>27:
print("肥胖")
|
3e08185745c7ae440ff123095a618fb465029949 | jingong171/jingong-homework | /邓阳馨/2017310412金融工程17-1邓阳馨第二次作业/字典列表.py | 629 | 3.984375 | 4 | cities={
'Chengdu':{
'country':'China',
'population':'1604.47万',
'fact':'capital of Sichuan Province',
},
'Tokyo':{
'country':'Japan',
'population':'4200万',
'fact':'capital city of Japan',
},
'Madrid':{
'country':'Spain',
'popul... |
90f73c8136e6ac25e34a5e15e3b618a2e62ebecf | jingong171/jingong-homework | /樊宇宸/2017310401第四次作业金工17-1樊宇宸/2017310401第四次作业樊宇宸/ice_cream_stand.py | 699 | 3.640625 | 4 | from restaurant import Restaurant
#从restaurant.py中导入Rsetaurant类
class IceCreamStand(Restaurant):
"""创建冰淇淋站类,并继承饭店类"""
def __init__(self,restaurant_name,cuisine_type,flavors):
"""创建冰淇淋站类的init方法"""
super().__init__(restaurant_name,cuisine_type)
#初始化父类属性
self.flavors=flavors
... |
f9c6d2311c04dfd46c79d8c3a58b091fa10b2285 | jingong171/jingong-homework | /曾志坚/2017310409-第四次作业-金工17-1-曾志坚/die.py | 513 | 3.71875 | 4 | from random import randint
class Die():
"""sides为骰子面数,times为投掷次数"""
def __init__(self,sides=6,times=0):
self.sides=sides
self.times=times
def roll_die(self):
x = randint(1,int(self.sides))
print("You get a "+"'"+str(x)+"'.")
def consistant_rolling(self):
for i i... |
1e3e6460238bfde206ec5f3be9de12fcc6b9be96 | jingong171/jingong-homework | /闫凡/2017310390-闫凡-第五次作业-金融工程17-1/10-8猫和狗.py | 335 | 3.59375 | 4 | #尝试打开文件
files=['cats.txt','dogs.txt']
#使用for循环读取文件
for file in files:
try:
with open(file) as file:
file_read=file.read()
print(file_read.title())
#处理文件不存在的错误
except FileNotFoundError:
#输出提示信息
print('文件'+str(file)+'不存在')
|
ae72658c8f68cdea3f245cc43c208be6a24ccf56 | jingong171/jingong-homework | /韩飞云/2017310420 韩飞云 第二次作业 金工17-1/第四题.py | 511 | 3.53125 | 4 | cities={
'foshan':
{'country':'China','population':'20万','fact':'Liukaicheng住的地方'},
'xining':
{'country':'China','population':'210万','fact':'Hanfeiyun的家乡'},
'qujing':
{'country':'China','population':'650万','fact':'Zhangingkang的家乡'}}
for city,message in cities.items():
print("Citie is "+city ... |
cf80cb9a836d8dc7b75ab622b02a92367e4eab4f | jingong171/jingong-homework | /刘恺诚/2017310423第四次作业金工17-1刘恺诚/骰子.py | 309 | 3.640625 | 4 | class Die():
"""A small Die"""
def __init__(self,sides=6):
self.sides=sides
def roll_die(self):
print(int(randint(1,self.sides)))
from random import randint
sides=int(input("请输入骰子的面数"))
myDie=Die(sides)
for i in range(1,11):
myDie.roll_die()
|
5f28e1f8ec995b5c6f27b40c0aed8ca99eae1a3b | jingong171/jingong-homework | /程佳昕/第一次作业/第一次作业 17-1金工 2017310402 程佳昕/4素数判断.py | 206 | 3.59375 | 4 | n=[];
a=2
for a in range(2,101):
b=2
for b in range(2,a):
if(a%b==0):
break
else:
n.append(a)
print(n)
input("请输入回车键退出")
|
14529998ed41625acbb3bb26e2689b8772023097 | jingong171/jingong-homework | /王子叶/2017310388 第五次作业 金工17-1 王子叶/2017310388 第五次作业 王子叶 金工17-1/10-12.py | 486 | 3.765625 | 4 | import json
filename = "favorite_number.json"
try:
with open(filename) as favorite_object:
favorite_number = json.load(favorite_object)
except FileNotFoundError:
favorite_number = input("What's your favorite number?")
with open(filename,'w') as favorite_object:#读取#
json.dump(favorite_number,favorit... |
38ea14dfe3a967932aa088fa97f7ceba5a649884 | jingong171/jingong-homework | /王子叶/2017310388 第四次作业 金工17-1 wangziye/2017310388 第四次作业 金工17-1 wangziye/类的继承,类和模块的导入.py | 776 | 3.90625 | 4 | class Restaurant(object):
def __init__ (self,name,types):
self.restaurant_name=name
self.cuisine_type=types
self.number_served=0
def describe_restaurant(self):
print("Rsetaurant name is %.\n Cuisine type is %s."%(self.restaurant_name,self.cuisine_type))
def open_restaurant(self):
print("Ope... |
634a221ba9e3510d35b09ebd9e943909fb15b252 | jingong171/jingong-homework | /唐聿澍/第一次作业/第一次作业-金融工程17-1-2017310404-唐聿澍/素数.py | 134 | 3.640625 | 4 | for n in range(2,100):
a = 2
while (n%a) != 0 :
a += 1
if a == n :
print("素数是:" + str(a) + ".\n")
|
3f65a83b2ffd3b9adcac51dc8b0e307298385e29 | jingong171/jingong-homework | /龚鑫/第一次作业/第一次作业-金工一班-2017311575-龚鑫/质数.py | 216 | 3.734375 | 4 | list1=[]
list2=[]
for i in list(range(2,100)):
for k in list(range(2,i)):
if i%k==0:
list1.append(i)
for m in list(range(2,100)):
if m not in list1:
list2.append(m)
print(list2)
|
31e4743f345eeee19a66f7b22bf53516cf2e7e1f | jingong171/jingong-homework | /孙金萌/第一次作业/第一次作业-金工17-1-2017310407-孙金萌/第三题:水仙花数方法一.py | 188 | 3.53125 | 4 | list=[]
for i in range(1,10):
for j in range(0,10):
for k in range(0,10):
if i*i*i+j*j*j+k*k*k==100*i+10*j+k:
list.append(100*i+10*j+k)
print(list)
|
1877608caa203dc081689d7ba58a4bbf06cac93d | jingong171/jingong-homework | /张庭康/2017310416张庭康金工17-1第四次作业/2017310416张庭康金工17-1第四次作业/作业2/restaurant.py | 964 | 3.984375 | 4 | class Restaurant():
"""用于打印出餐馆的信息"""
def __init__(self,restaurant_name,cuisine_type):
"""初始化类reataurant的属性"""
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
self.number_served = 0
def describe_restaurant(self):
"""打印餐馆的名称和菜种"""
print... |
e133ea5a383afdeed1d952740019ce96553c0bf5 | jingong171/jingong-homework | /吴秋姊/第一次作业/2017310422吴秋姊第一次作业/体重2.py | 197 | 3.625 | 4 |
w=49
h=1.65
t=w/(h**2)
if t<18:
print("轻体重"+str(t))
elif t<=25:
print("正常体重"+str(t))
elif t<=27:
print("超重体重"+str(t))
else:
print("肥胖体重"+str(t))
|
7a3551e951f6d0232791982837bf4a6bf759c1b3 | jingong171/jingong-homework | /程佳昕/第二次作业 2017310402 17-1金工 程佳昕/第一题.py | 76 | 3.53125 | 4 | i=3
summary=0
while i<=30:
summary=summary+i*i
i=i+3
print(summary)
|
fb3bc535bdf16f3da2b7e01bd23247481da74267 | jingong171/jingong-homework | /夏丽平/2017310413-夏丽平-第二次作业-金工17-1/zy-4.py | 639 | 4.0625 | 4 | cities={
'Beijing':{
'nation':'China',
'population': 13000000,
'fact':'capital',
},
'Paris':{
'nation':'France',
'population': 1000000,
'fact':'Effel Tower',
},
'New York':{
'nation':'America',
'population': 700000,
... |
b81df61b45bed63d30d1c0638dfce361b4ca19da | jingong171/jingong-homework | /李许靓/第一次作业/第一次作业-金工17-1-2017310720-李许靓(1)/第一次作业-金工17-1-2017310720-李许靓/1.py | 214 | 3.625 | 4 | w=52
h=1.68
t=w/h**2
print("你的体重指数是"+str(t))
if t<18:
print("你是低体重")
elif t<=25:
print("你是正常体重")
elif t<=27:
print("你是超重体重")
else:
print("你肥胖")
|
4dd126f3687fd8976dbb232ed6963832910f2483 | jingong171/jingong-homework | /李鑫屿/2017310393-李鑫屿-第五次作业-金工17-1/10.8 9.py | 268 | 3.75 | 4 | def read_text(filename):
try:
with open(filename) as f_obj:
contents=f_obj.read()
except FileNotFoundError:
pass
else:
print(contents)
animal_list=["cats.txt","dogs.txt"]
for animal in animal_list:
read_text(animal)
|
e3a09aee57f1e66f2bbca9bd41d73fc354f030da | jingong171/jingong-homework | /马一舒/第一次作业/第一次作业 金工17-1 2017310417 马一舒/第四题.py | 179 | 3.6875 | 4 | digits=[]
for n in range(2,101):
count=0
for i in range (2,n+1):
if n %i != 0:
count=count+1
if count==n-2:
digits.append(n)
print(digits)
|
d04ba10c777c3e3de3f73da1c2943841b485f2a8 | jingong171/jingong-homework | /沈书颖/2017310398-沈书颖-第二次作业-金工17-1/4.py | 539 | 4.28125 | 4 | cities={
'Beijing':{'country':'China','population':'21730000','fact':'It has a long history.'},
'London':{'country':'England','population':'8280000','fact':'It has The London Eye.'},
'NYC':{'country':'America','population':'8510000','fact':'It is a international metropolis.'}}
#创建字典中嵌套字典的信息
for city_name,ci... |
ca6ce79339a56a95c94d5dcb28b26cfcdfe1566b | jingong171/jingong-homework | /沈书颖/2017310398-沈书颖-第二次作业-金工17-1/2.py | 497 | 3.515625 | 4 | num1=45
num2=54#定义两个数字
num=[num1,num2]#创建一个两个数字的列表
for i in range(1,min(num)+1):#遍历由1到两个数字中较小的数字
if (num1%i==0)and(num2%i==0):#公约数是除两数余数都为0
GCD=i#GCD的赋值会被不断覆盖,最终取得最大公约数
LCM=int((num1*num2)/GCD)#最小公倍数=两数相乘除以最大公约数
print("这两个数字的最大公约数是"+str(GCD))
print("这两个数字的最小公倍数是"+str(LCM))
|
f208319abed3376de51000392cc2a8557da4578d | jingong171/jingong-homework | /陈佳伟/2017310391-第三次作业-金工17-1-陈佳伟.py/2017310391-第三次作业-金工17-1-陈佳伟.py.py | 1,255 | 4.03125 | 4 | def daysofmonth(year,month):
dayofmonth={1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
if year%4==0 and year%100!=0 or year%400==0:
dayofmonth[2]=29
return dayofmonth[month]
def getMonthStartDay(year,month):
TotalDaysFrom1990=0
for thisyear in range(1990,year):
year... |
5eb9ad39d59480992a29c36d0aa4674169c5a79c | jingong171/jingong-homework | /曾程/2017310415-第四次作业-金工171-曾程/restaurant.py | 334 | 3.796875 | 4 | class Restaurant(): #定义Restaurant类
def __init__(self,name,number_served):
self.number_served=number_served
self.name=name
print("The number of people being served in the restuarant "
+str(self.name.title()) +" is "+str(self.number_served)+".\n")
#打印餐厅服务人数
|
122c9b5527a2e2d2680cf97ac686791b91d4a85e | jingong171/jingong-homework | /周久悦/2017312547 周久悦 金工17-1 第二次作业/3.py | 181 | 3.65625 | 4 | for m in list(range(1,2001)):
sum=0
for x in list(range(1,m)):
if m%x==0:
sum=sum+x #因子和
if sum==m:
print(str(m)+"是一个完数。")
|
114617f76e46e24a57b783fa7caf5df33255d4a0 | LennartElbe/PythOnline | /scripts/sheet5/5.2.py | 1,402 | 4.46875 | 4 | """Definition: this module defines whether a number is palindromic and what the
largest palindromic number derived from products of any 3 digit numbers
author: Lennart Elbe (lenni.elbe@gmail.com)
"""
def palindromic(n): # number to string and then string is flippped
"""
determines if given int n is a palin... |
3a8b5995f7a363b6a5b1d6890e7be8c8e8209ca3 | LennartElbe/PythOnline | /scripts/sheet8/8.1.py | 2,766 | 3.75 | 4 | import pytest
LETTERS = ("abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜäöüß")
def _next_word_helper(s):
"""Helper function for next_word.
Recursive calls for [1:] (the rest of the string) ensure that
the entire string is processed.
args:
s {str} -- The string t... |
4e9772f7b99434407f2be764344618f8794638ab | Yashvishnoi/Python | /Loops/Loop_Question1.py | 377 | 4.25 | 4 | # Make a list which contain all the thing like number, string etc.
# Now detect wheather it is number or not and it should be greater than 6 then print it.
# =======================================================================
list = ["harry" , 1 ,78 , "Hey" , 'A' , 85 , 74 , 2 , 20 , 8, 5]
for item in list:
i... |
72e1277c09e2ee1a84bef3e3ec4a53c133d8f5c6 | Yashvishnoi/Python | /Assignment of Coursera/Assingnment_2.3.py | 518 | 4.1875 | 4 | # Write a program to prompt the user for hours and rate per hour using input to
# compute gross pay. Use 35 hours and a rate of 2.75 per hour to test the program
# (the pay should be 96.25). You should use input to read a string and float() to
# convert the string to a number. Do not worry about error checking or bad u... |
581376d67bcaee3fd7a686ce838be0c8d8b42576 | Yashvishnoi/Python | /String.py | 689 | 4.5 | 4 | mystr = "harry is A coder"
print(mystr)
print(len(mystr))
print(mystr[0:5])
print(mystr[:5])
print(mystr[0:])
print(mystr[::3]) # it will escape 3 characters
print(mystr[-4:-2]) # it will start counting from right hand side
print(mystr[::-1]) # it will reverse the string
print(mystr. endswith("boy")) # it will give tru... |
9e8a375da3d599374a94d62b977f5fefdf9d82cc | crystal-mullins/fsw-200 | /week5/lamda.py | 833 | 3.96875 | 4 | # adder = lambda x, y: x + y
# print (adder (11, 22))
# #What a lambda returns
# x='some kind of a useless lambda'
# (lambda x : print(x))(x)
# sequences = [10,2,8,7,5,4,3,11,0, 1]
# filtered_result = map (lambda x: x*x, sequences)
# print(list(filtered_result))
# from functools import reduce
# sequences = [1,2,3,4... |
67923b23d0e24e25df761a6ef28a3d1dc442e8f2 | crystal-mullins/fsw-200 | /week4/guessingGameOne.py | 392 | 3.9375 | 4 | import random
a = random.randint(1,9)
b = " is the number"
num = int(input("Guess a number: "))
if (num == a) :
print("{0} you guessed right YOU WIN".format(num))
else:
print("{0} Sorry that is not the number YOU LOSE".format(num))
if (num > a) :
print("{0} You guessed to high!".format(num))
elif (num < a):
... |
87106fda57b16031bb224da79c6024351c4440f2 | mdonahoe/pj | /pj.py | 1,628 | 3.703125 | 4 | #!/usr/bin/python
"""
pj.py
2013-05-17
by Matt Donahoe
Pretty-print json from the command line
View a file
$> cat test.json | pj
{
"foo":1
"bar":2
}
Read a key
$> cat test.json | pj foo
1
View all keys
cat test.json | pj --keys
[
1,
2
]
"""
import sys
import json
import argparse
parser = argparse.ArgumentPars... |
822c5656de7e84a12ed49dc8a62a811bb94bd8cf | Peace-Song/Playground | /toys/Collatz_conjecture/give_me_num.py | 197 | 3.84375 | 4 | n = int(input(">>> "))
curr_n = n
while True:
if n % 2 == 1:
n = 3*n + 1
else:
n = n // 2
if n == 1:
print("success!")
break
else:
print("current on {n}".format(n=n))
|
f428c4109d5f7cde0eb10f95abab11f7c74b84ba | srj737/sbailie-aoc-2020 | /ingest_file.py | 4,355 | 3.515625 | 4 | def int_on_lines(filename):
results = []
with open(filename, 'r') as infile:
for line in infile:
results.append(int(line))
return results
def strings_on_lines(filename):
results = []
with open(filename, 'r') as infile:
for line in infile:
results.append(line... |
7e2717c164e95cd2eaaa96ddc3bdf311529d14a8 | taiswelling/ifpi_algoritimos | /SEMANA 5/uri_1038.py | 359 | 3.859375 | 4 | codigo = int (input('Digite o código: '))
quantidade = int(input("Digite a quantidade: "))
if codigo == 1:
valor = 4*quantidade
if codigo == 2:
valor = 4.5*quantidade
if codigo == 3:
valor = 5*quantidade
if codigo == 4:
valor = 2*quantidade
if codigo == 5:
valor = 1.5*quan... |
90bae6f88de97f8f73d236dcc66957e1f44b5b14 | taiswelling/ifpi_algoritimos | /SEMANA 3 E 4-questões URI/URI_1011.py | 102 | 3.546875 | 4 | raio = float(input(''))
vol = (4.0/3) * 3.14159 * (raio**3)
print('VOLUME = {:.3f}'.format(vol)) |
7e2b577b32245b76f36290f827b987e280d9092b | taiswelling/ifpi_algoritimos | /SEMANA 5/uri_1046.py | 322 | 3.65625 | 4 | inicio = int(input('inicio do jogo: '))
fim = int(input('fim do jogo: '))
duracao = fim- inicio
duracao2 = (24-inicio)+fim
if fim>inicio:
print(f' O JOGO DUROU {duracao} HORAS')
if inicio > fim:
print(f' O JOGO DUROU {duracao2} HORAS')
if inicio==0 and fim==0:
print(f' O JOGO DUROU 24 HORAS... |
d890e839448e0d15918e9e3fede343cb7223ef9a | ffhound/findr | /deprecated/workqueue/makeFlowMaker.py | 1,111 | 3.75 | 4 | '''
Created on Oct 4, 2015
Purpose: These methods will take a dictionary of light and dark images and create a makeflow script based on those programs
Input: Dictionary containing science image keys with dark image values
Output: A file containing the makeflow instructions named "task.makeflow"
@author: Ryan Jicha
''... |
3f41d41006a23942807e4e5942cf929570a5000d | suganthicj/gre | /gre.py | 115 | 3.75 | 4 |
X1=int(input())
Y1=1
Z1=0
for Z1 in range(X1,0,-1):
Y1=Y1*Z1
if X1==0:
print("1")
else:
print(Y1)
|
ff5a8a42f5b397813342b1f9c77bdf5a17e4ce1c | simon23rus/python-da | /HW/Task3/palindromes.py | 456 | 3.6875 | 4 | def main():
n = int(input())
import re
for ind in range(n):
row = input()
new_row = (re.sub('\W', '', row.lower()))
new_row = new_row.replace('ё', 'е')
is_palindrom = True
for j in range(len(new_row) // 2):
if new_row[j] != new_row[-(j + 1)]:
... |
415f1222963bc8f6822ea43ec38fcf4b33859fbe | JJMats/python_katas | /data_structures_and_algorithms/005_recursion/fibonacci_loop.py | 349 | 3.78125 | 4 | def getFib(position):
if position == 0:
return 0
if position == 1:
return 1
first = 0
second = 1
next = first + second
i = 2
while i < position:
first = second
second = next
next = first + second
i += 1
return next
print(getFib(0))
prin... |
57c339b55caaa90b04720d56b97d3ee4aada4968 | Geetanjali1129/python | /datatype.py | 82 | 3.53125 | 4 | a=input('enter a number')
b=input('enter a number')
print(type(a),type(b),a+b)
|
891455c2ee90e752d580a4ba06a21742669fbd5c | Rwilmes/SML | /ex3/Code/33a.py | 2,132 | 3.5625 | 4 | import matplotlib.pyplot as plt
import numpy as np
def plotArray(X, c):
for i in np.arange(0, X.shape[0]):
plt.plot(X[i, 1], X[i, 2], c)
return
def normalize(X):
# Subtract mean
m = np.array([np.mean(X, 0)])
m = np.repeat(m, X.shape[0], 0)
X = np.subtract(X, m)
# Devide by stan... |
36c89d052b0da1f27055b54cf5af90db41daa879 | iAtec-ua/python_course | /practice 4/Task_4_4_Alphabet.py | 849 | 4.375 | 4 | # The script prints a letter from the alphabet and the letters, located before and after it
# Create a list of letters in alphabet
import string
alphabet = list(string.ascii_lowercase)
input_letter = None
# While input is not a latin letter, keep prompting
while input_letter not in alphabet:
input_letter = inpu... |
f9b913ee722eabeffb55764fb30f118d0e256467 | jeelkhatiwala/Number-100-game | /my_custom_random_odd.py | 206 | 3.578125 | 4 | from random import randint
def my_custom_random_odd():
exclude=[2,4,6,8]
randInt = randint(1,9)
return my_custom_random_odd() if randInt in exclude else randInt
print(my_custom_random_odd())
|
3527b9fcd73666d5ef4a0a92bdc461f95d424e39 | Bhumika1524/Python | /FibonacciNumbers.py | 692 | 4.53125 | 5 | #Program to print Fibonacci Numbers Without Recursion
n=int(input("Enter the value of 'n': "))
#first two terms are first and second
first=0
second=1
sum=0
count=1
print("Fibonacci Sequence: ")
# Count should not be more then n.
while(count<=n):
print(sum)
count+=1
first=second
second=sum
sum=first+secon... |
1b13bad04e6c408e2d24424331e10190f60bc689 | souhaila30/flask_getting_started | /client.py | 890 | 3.703125 | 4 | import requests
def get_name():
"""makes a get request and returns the name"""
r = requests.get("http://vcm-3586.vm.duke.edu:5000/name")
name = r.json()
print(name)
return name
def get_hello_name():
""" makes a get request and returns the message """
r = requests.get("http://vcm-3586.vm.... |
37630024245edc51c5c132a8a79f1019cb752c28 | zachlindsey/easyNN | /babynn.py | 3,200 | 3.859375 | 4 | '''
This is a module for me to learn about/test some basics
about neural nets.
Each of the classes defined in this document is a single
component of a neural net architecture.
'''
import numpy
class maxAct(object):
'''
A RELU gate: computes x -> max(0,x) pointwise on input
'''
def __init__(s... |
87b2f0eb894334aebad9189891f5839ec9194174 | wayfarer1549/ecu-seng-6245-investment-tracker | /hw4/Users/TestEmployees.py | 1,635 | 3.5 | 4 | import unittest
from Employee import Employee
class TestEmployee(unittest.TestCase):
def setUp(self):
first_name = 'John'
last_name = 'Bunyan'
ssn = '123-45-6789'
phone_num = '252-989-5555'
status = True
date = '2020-10-01'
self.new_employee = Employee(
date,
first_name,
last_name,
ssn,
... |
b3883efe50502087f5bd2e2dbc96cf7e9b21f18d | gercunderscore4/convex_hull_3D | /Python/CH3D.py | 16,437 | 3.53125 | 4 | # PROGRAM: CH3D.py
# PURPOSE: Module for 3D convex hull algorithm
# AUTHOR: Geoffrey Card
# DATE: 2014-10-13
# NOTES: Time: O(n^2*log(n)) Algorithm requires sort(n) for each n, hence n*n*log(n).
# Space: O(n)
# Has trouble with non-triangluar facets.
#
# 3D convex hull (written as a low-level... |
98976e9ca4222e5e25ab0dca28f5236cb76e9445 | YaniVerwerft/Python | /Exercises/5_TupleAndList/Exercise_5.py | 788 | 4 | 4 | my_list = [42, 18,17, 0, 37, 0, 2, 19, 20, 5, 14,0]
print(my_list)
for i in range(len(my_list)-1):
if my_list[i] == 0:
largest_odd = 0
my_list[i] = largest_odd
for j in range(i+1,len(my_list)-1):
if my_list[j] > largest_odd and my_list[j] %2 != 0:
largest_odd = ... |
e3e08c4b4c31fa4836253f714d7b39b7c65e4bc6 | YaniVerwerft/Python | /Exercises/2_Selection/Exercise_5.py | 302 | 4.28125 | 4 | number = int(input('Enter a number: '))
if number <= 0:
print('Negative number will not be tested')
else:
digit = int(input('what final digit do you want to test'))
if number % 10 == digit:
print(number,'ends with, digit')
else:
print(number,'does not end with',digit) |
37442d5e21a8b3998a48fa75e7add9bcf1bd0fc1 | YaniVerwerft/Python | /Exercises/7_Files/Exercise_4.py | 363 | 3.921875 | 4 | with open('Files Chapter 7/irish_song.txt') as file:
line = file.readline().rstrip()
shortest = len(line)
sentence = line
while line:
if len(line) < shortest:
shortest = len(line)
sentence = line
line = file.readline().rstrip()
print('The shortest line has', ... |
1200ee403d334b1db8d76c765e5887c84a98bcb8 | YaniVerwerft/Python | /Exercises/4_Strings/exercise_3.py | 133 | 3.796875 | 4 | woord = input('Enter a word with an odd amount of letters: ')
print_start = (len(woord)//2)-1
print(woord[print_start:print_start+3]) |
0b43989113c95b20927e72c47f79562bb23480bc | YaniVerwerft/Python | /Exercises/1_Sequence/Exercise_3.py | 582 | 4.21875 | 4 | #Input
digit_input = int(input("Enter a three-digit number: "))
#Calculations
half = digit_input / 2
double = digit_input * 2
third_power = digit_input ** 3
tenfold = digit_input * 10
#split
first_digit = digit_input // 100
second_digit = (digit_input - (first_digit*100)) // 10 #(number % 100) //10
third_digit = (digit... |
185e45c0faab99201a10a3e213ed1707b035a2b0 | YaniVerwerft/Python | /Exercises/1_Sequence/Exercise_6.py | 213 | 4.25 | 4 | #input
amount_of_repetitions = int(input('Enter a number: '))
text_to_repeat = input('Enter a text: ')
#print
print(str(amount_of_repetitions) + ' times your text is: ' + str(text_to_repeat*amount_of_repetitions)) |
496d4fbd9121d89742d5235cc16a9c122c375b98 | YaniVerwerft/Python | /Exercises/5_TupleAndList/Exercise_4.py | 876 | 3.921875 | 4 | my_tuple = (1, 4, 3, 3, 5, 4, 6, 7, 8)
last_four_location = -1
for find_four in range (len(my_tuple)):
if my_tuple[find_four] == 4:
last_four_location = find_four
print(my_tuple)
if last_four_location == -1:
print('The number 4 does not appear in the Tuple')
else:
new_tuple = my_tuple[last_four_loc... |
c5013cbae6a00f50b896d81c0300967db4e8da66 | YaniVerwerft/Python | /Exercises/7_Files/Exercise_1.py | 388 | 3.734375 | 4 | with open('Files Chapter 7/first_names.txt') as file:
line = file.readline()
name_count = 0
z_count = 0
while line:
name_count += 1
if line.lower().count('z') > 0:
print(line.rstrip())
z_count += 1
line = file.readline()
print('There are', name_count, 'fir... |
63a1795ad7ab6727d25919e8b44b28af086bf700 | Ashwathguru/DATA-STRUCTURES | /HEAP/airport.py | 2,335 | 4.03125 | 4 | # 4. An airport is developing a computer simulation of air-traffic control that handles events such as landings and takeoffs. Each
#event has a time stamp that denotes the time when the event will occur with additional information like, plane number, takeoff or
#landing. The simulation program needs to efficiently per... |
74b346f6da43dfa823ebd2053a433424c9d3b874 | bikrambhurtel/python-training | /week3/class_animal.py | 892 | 3.96875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 30 08:49:35 2019
created calss "Animal"
attributes are defined as name,type,habitat.
method is defined as foodhunt.
@author: bikram
"""
class Animal:
#Attributes of the animal are defined
def __init__(self,name,type,habitat):
... |
d42104e5683d39ae97b401123a3976a6a3f3427b | bikrambhurtel/python-training | /project_euler/problem21.py | 1,073 | 3.875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 3 08:37:01 2019
Project Eular
21) Amicable numbers
"Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and... |
786fc3fedda9b87c8c4f0a1e1516b1152fac01ed | sae13/DataStructureBook | /1-4.py | 251 | 4.09375 | 4 | #!/bin/python
from os import system
system('clear')
array = input("please enter a array: ")
def chapAzAkhar(str):
arz = len(str)
if arz==1:
return str[0]
else:
return str[-1]+chapAzAkhar(str[:-1])
print(chapAzAkhar(array)) |
c23caf42aa0e99d041402c922f213bbdef7204c7 | for-l00p/mlubinsky.github.com | /python/interview.py | 2,054 | 3.84375 | 4 | print " FIND 2 elements in list where sum=target"
l=[6,2,3,4,5,1]
target=6
d={}
for el in l:
if d.has_key(target-el):
print "Found:", el, d[target-el]
else:
d[el]=el
################
print " Dictionary examples"
################
print " dict traversal #1"
for key in d.keys():
print "k... |
beaff7390cba3e0851a6c86a1d8c7628fc3c7fe7 | simrankumar/pythonfiles | /table5input.py | 76 | 3.640625 | 4 | a=int(input())
for b in range(1,11):
print("%s * %s = %s" %(a,b,a*b))
|
a19aab56fe4d029a6ebc1e528fc566d3ec05dcb4 | JohnnyHsieh1020/python_practice | /m02.py | 483 | 3.625 | 4 | def fee(isDiscount, minutes):
total = 0
if isDiscount:
print('減價時段, 分鐘數{minutes}'.format(
isDiscount=isDiscount, minutes=minutes))
total = 300 * (minutes // 60) + 6 * (minutes % 60)
return format(total, ',')
else:
print('非減價時段, 分鐘數{minutes}'.format(
i... |
b557f5b616498b149af412e20bc54f1445721fde | Computersayo/python- | /sorting.py | 414 | 3.8125 | 4 | number=int(input('ENTER YOUR NUMBER'))
one="poor trial"
two="almost there"
three="try again"
four="perfect"
five="number greater than 100"
if number==10:{
print(f"try again { one } play again")
}
elif number==20:{
print(f"try again { two } play again")
}
elif number==60:{
print(f"try again{... |
3db981f830bc48b6a7aeb6608b87c6ab4fb0106e | Computersayo/python- | /else.py | 280 | 3.921875 | 4 | amount=int(input("ENTER THE AMOUNT"))
if amount<1000:
discount=amount*0.08
print("DISCOUNT",discount)
elif amount<5000:
discount=amount*0.10
print("DISCOUNT",discount)
else:
discount=amount*0.15
print("DISCOUNT",discount)
print("NET PAY",amount-discount) |
6590facce355a545d30a54c85460e109cf05e49b | renugambal/guvi | /codekata/14p.rev .py | 193 | 3.53125 | 4 | num=int(input())
string=list(input())
l=['a','A','e','E','i','I','o','O','u','U']
for i in string:
if i in l:
string.remove(i)
s=string[::-1]
for i in range(len(s)):
print(s[i],end="")
|
98af120094f8b27b84401b27425d1ea830d7607c | renugambal/guvi | /codekata/11p.holiday.py | 78 | 3.828125 | 4 | t=input()
if t=="Saturday" or t=="Sunday":
print("yes")
else:
print("no")
|
ec3cc80e0b644d850bad63179a6568fd268a57e0 | renugambal/guvi | /codekata/62.binary.py | 99 | 3.78125 | 4 | a=input()
p=set(a)
s={'1','0'}
if s==p or p=='1' or p=='0':
print("yes")
else:
print("no")
|
ac00e11bb26231b438395452b8634dcae948060a | EstebanC93/python-intermedio | /debugging.py | 813 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 9 10:48:15 2021
@author: Esteban Henao
"""
def divisors(num):
divisors = []
for i in range(1, num + 1):
if num % i == 0:
divisors.append(i)
return divisors
def main():
try: #try para cuando ingresan valores no numerico... |
c9f34ca874a2a453891b656599496e3c97576521 | egalli64/pythonesque | /hr/algorithms/implementation/magic_square.py | 1,055 | 3.515625 | 4 | """
HackerRank Algorithms Implementation Forming a Magic Square
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.hackerrank.com/challenges/magic-square-forming/problem
http://www.mathematische-basteleien.de/magsquare.htm
Given a 3x3 integer matrix
Return its minimal dist... |
edbb6118e5e7f3c7cb8a91b58aa8d2fab68459bc | egalli64/pythonesque | /ce/c065.py | 2,098 | 3.9375 | 4 | """
CodeEval Word Search
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.codeeval.com/open_challenges/65/
Given a 2D board and a word, find if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent cell,
where adjacent cells are those hor... |
f80be259818e04fa541e2a7312528f5244c11bfc | egalli64/pythonesque | /cip/karel/ch07conditions.py | 3,350 | 3.953125 | 4 | """
Karel the Robot - Learns Python
Source: https://compedu.stanford.edu/karel-reader/docs/python/en/intro.html
My notes: https://github.com/egalli64/pythonesque/cip/karel
Chapter 7: Karel Conditions
https://compedu.stanford.edu/karel-reader/docs/python/en/chapter7.html
"""
from stanfordkarel import *
def main():
... |
086a92abefea990f4da8978721c3c4fa19f00689 | egalli64/pythonesque | /ce/c078.py | 1,509 | 3.78125 | 4 | """
CodeEval Sudoku
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.codeeval.com/open_challenges/78/
"""
import sys
from math import sqrt
def solution(size, values):
for i in range(size):
expected = list(range(1, size+1))
for j in range(size):
c... |
53bfa9e9ef12ef599176787e35d462fa6fd8da5c | egalli64/pythonesque | /ce/c177.py | 1,061 | 3.625 | 4 | """
Justify the Text
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.codeeval.com/open_challenges/177/
"""
import sys
def solution(text):
result = []
while len(text) > 80:
pos = 0
while True:
next_pos = text.find(' ', pos + 1)
i... |
bdac9728b563cf130d9c32def47c11bec1475658 | egalli64/pythonesque | /cip/w4/ex_khansole.py | 863 | 3.921875 | 4 | """
Code in Place 2023 https://codeinplace.stanford.edu/cip3
My notes: https://github.com/egalli64/pythonesque/cip
Week 4: Khansole Academy - Three in a row
--------------------
Randomly generate addition problems until the user has gotten 3 problems correct in a row
"""
import random
WINNING_STRIKE = 3
def main():
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.