wlbk.net
当前位置:首页 >> Python作业 >>

Python作业

eval函数将字符串当成有效Python表达式来求值,并返回计算结果 例子 x=0l='x+1'print(eval(l))结果是1

需求不太明确,是操控图像编辑软件来达到目的,还是写一个功能一样的程序。补全代码代码也没有。

from math import pir=float(input("input\n"))s=pi*r*rv=4/3*pi*r**3print("{:.2f} {:.2f}".format(s,v))

# -*- coding: utf-8 -*- TEXT = r''' The King and Queen of Hearts were seated on their throne when they arrived, with a great crowd assembled about them--all sorts of little birds and beasts, as well as the whole pack of cards: ...

coinprice={"1分":1,"2分":2,"5分":5,"1角":10,"2角":20,"5角":50}coins=["5角","2角","1角","5分","2分","1分"]price=float(raw_input("请输入物品价格(元):"))if price>1 or price

def isPrime(num):for i in range(2,num-1):if(num%i==0):return 0return 1def fun1():for i in range(2,200):if(isPrime(i)):print("%d is prime number." %(i))def fun2():for i in range(2,200):isp=0for j in range(2,i-1):if(i%j==0):isp=1...

第4行的n = 0该写在for j的外面,不然你for j每跑一次它就变0,那么下面的 n == 2永远是False

def main(): sentence = raw_input('sentence') words = sentence.split() temp = "" for idx in range(len(words)): temp += words[idx][0].upper() temp += words[idx][1:] words[idx] = temp temp = "" return " ".join(words)

记得给采纳哦,不然我都回答得没劲了。 #!/usr/bin/env pythonlargest = Nonesmallest = NoneLIST = []while True: num = raw_input("Enter a number: ") if num == "done" : break print num try: LIST.append(int(num)) except: print "Invali...

# python 3.6+from random import randint, choiceMAX = 5def rd(h=3, repeat=False): a = randint(1, 9) choices = [i for i in range(0, 10) if i!=a] ns = [a] for i in range(h-1): n = choice(choices) ns.append(n) choices = [i for i in...

网站首页 | 网站地图
All rights reserved Powered by www.wlbk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com