1樓:礻斤丶
#!/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題求大神幫忙!!
2樓:英雄傻小
最後一次假如不夠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題,真的超級超級簡單!!!
3樓:
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的題目,求大神解答
4樓:匿名使用者
def createworddict(filename):
res = {}
with open(filename) as fp:
for word in fp.read().split():
if word in res:
res[word] += 1
else:
res[word] = 1
return res
求大神幫忙做一道python題,簡易程式,python2.7.13 100
5樓:
#!/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題
6樓:紫薇參星
按照題目要求編寫的python程式如下
n=1i=1
m=1print(" ".format("n","square"))while n<=25:
print(" ".format(n,m))i=i+2
m=m+i
n=n+1
源**(注意源
版**的權縮排)
一道python題 求大神回答 感激不盡 10
7樓:匿名使用者
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的一道題,求大神解答
8樓:匿名使用者
回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.strip('\n')if not line: continuewords = [word for word in line.split()]
for word in words:
if word in dict_word_count:
dict_word_count[word] += 1else:
dict_word_count[word] = 1print(dict_word_count)
一道python題。
關於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題,簡易程式,Python
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 nu...
一道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畫...