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

Python作业

# -*- 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: ...

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

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

记得给采纳哦,不然我都回答得没劲了。 #!/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...

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)

eval参数是一个字符串, 可以把这个字符串当成表达式来求值, 比如'x+1'就是一个表达式字符串 >>> x = 1 >>> print eval('x+1') 2

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

# 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...

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...

# encoding=UTF-8 ==>定义Python代码的编码为UTF-8# 石头剪子布 程序# 李忠import random ==>导入随机生成器 # 定义石头剪子布字典dict = {1:'剪子',2:'石头',3:'布'} ==>定义一个字典来保存数字和石头剪子布的对应关系 for row in dict: ==>遍...

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