python的小练习。。求给代码答案。

1、让用户输入一个数值,依次判断,如果数值小于60,打印D,如果小于80,打印C ,如果小于90,打印B,否则打印A。
2、分别使用for 和while循环实现打印100次"I love python!"
3、实现比较两个数大小的函数max(m,n),返回其中较大的数。并分别使用参数(3,9)、(5.0,2.0)调用函数max,打印查看结果的正确性。

value=int(raw_input("Enter a number:"))
if value<60:
    print 'D'
elif value<80:
    print 'C'
elif value<90:
    print 'B'
else:
    print 'A'

练习一

for i in range(100):
    print "I love python !"
i=0
while i<100:
    print "I love python !"
    i+=1

练习二

def max(m,n):
    if m>n:
        return m
    return n
print max(3,9)
print max(5.0,2.0)

练习三

追问

中间的用while怎么做

追答

第二个代码包含了用for和用while打印"I love pyton !" 100次的两种方法

追问

哦哦哦。。好吧。。刚看见。。十分感谢。。。

温馨提示:答案为网友推荐,仅供参考