1樓:
#!/usr/bin/python
# -*- coding:utf-8 -*-def lev(num):
atype = isinstance(num, (int, float, long))
if atype is true:
if 90 <= num <= 100:
return 'a'
elif 80 <= num < 90:
return 'b'
elif 70 <= num < 80:
return 'c'
elif 60 <= num < 70:
return 'd'
elif num < 60:
return 'e'
else:
return '請輸入正確分數'
if __name__ == '__main__':
student_num,anum = input(u'請輸入學生學號及考試成績,以英文逗號相隔:')
result = lev(anum)
if result not in 'abcde':
print result
else:
print u'學生的成績的等級是:'.format(student_num, result)
急求大神幫忙做一道python題,真的超級超級簡單!!!
2樓:
def fun(n):
l1=[1/((x+1)*(x+2)) for x in range(0,n,2)]
l2=[-1/((x+1)*(x+2)) for x in range(1,n,2)]
return sum(l1)+sum(l2)def main():
n=int(input("請輸
入n的值"))
print("sum=",fun(n))
main()
求大神幫忙做下這道題 python小白實在不會 python2.7
3樓:匿名使用者
import random
def hb():
n=100
s=0while n >=0:
i= random. randint(1,10)s= s+1
n= n-i
print '第
copy% s個人bai
,收du
到zhi% s,剩餘
dao% s'%( s, i, n-i)
有一道python題求大神幫忙!!
4樓:英雄傻小
最後一次假如不夠10元的話就會出問題,還有判斷money應該大於0,不是大於等於。下面**可用
money = 100
i = 0
while money <=100 and money > 0:
a = random.randint(1,10)if money < 10:
a = random.randint(1,money)money = money - a
i = i + 1
print "第%s個人,收到%s元,還剩%s元" %(i,a,money)
一道python的題,求大神幫忙
5樓:礻斤丶
#!/usr/bin/python
#coding: utf-8
occur = {}
file = open('hw6 problem 6.txt')lines = [list(line) for line in file.readlines()]
for line in lines:
for character in line:
if character not in occur:
occur[character] = 0
occur[character]+=1
for i in range(26):
key = chr(97+i)
key = chr(65+i)
if key in occur:
print key, occur[key]if key in occur:
print key, occur[key]隨便找了一個文章測試專,測試結果:屬
求大神幫忙做兩道python題?
6樓:匿名使用者
from random import randintwith open('d:/num1.txt','w+') as f1:
for x in range(100):
if x<99:
f1.write('%d\n' % randint(10,99))else:
f1.write(str(randint(10,99)))f1.seek(0)
arr=sorted(f1.read().split())print(arr)
with open('d:/num2.txt','w') as f2:
f2.write('\n'.join(arr))
求大神幫忙做下這道python的程式設計題 據說很簡單的就大概幾分鐘時間 朋友要考試了 我沒學過這
7樓:匿名使用者
inp = raw_input("")
n = int(inp)
sum = (1+n)*n/2
print "sum =",sum
一道python的題,求大神幫忙
usr bin python coding utf 8 occur file open hw6 problem 6.txt lines list line for line in file.readlines for line in lines for character in line if ch...
關於python的一道題,求大神解答
回inputfile open filename,r 答dict word count if inputfile none print error unable to read file filename return else for line in inputfile line line.str...
一道python題求大神回答感激不盡
def link zip s,t p pairnode s.a,t.a,none s1,t1,p1 s.nxt,t.nxt,p.nxtwhile s1 and t1 p1 pairnode s1.a,t1.a,none s1,t1,p1 s1.nxt,t1.nxt,p1.nxt 怎麼用python畫...