Python语言程序设计!!!基础题
import math
pi=3.14159
r=float(input("banjing:"))
h=float(input("gao:"))
p=r h math.sqrt(r*r h*h)
a=r*h/2
s=pi*r*(r math.sqrt(r*r /usr/bin/env python
#coding=utf-8
Created on 2011-1-29
@author: qihigh
class baiduAns:
__fruitLeft = 20
__buyDay = 5
__x = None
__y = None
def __init__(self, x, y):
self.__x = x
self.__y = y
def daydayAfter(self,days):
for i in range(1, days 1):
print("self.daySell(" str(i) ")")
# exec("self.daySell(" str(i) ")")
self.daySell(i)
return self.__fruitLeft
def daySell(self,day):
if(self.isSelling(day)):
left = self.__fruitLeft - self.__x
if(left < 0):
self.__fruitLeft = 0
self.__fruitLeft = left
def YArray(self):
self.__fruitLeft = 20
def isSelling(self,day):
卖货周期 5 y
if(day%(5 self.__y) == 0):
货刚到了 不卖
self.YArray();
return False
elif(day%(5 self.__y) <= 5 and self.__fruitLeft != 0):
卖
return True
else:
有货也不卖
return False
if __name__ == __main__:
‘’‘ 传入参数顺序 x 、y ’‘’
ans = baiduAns(5,1)
print(ans.daydayAfter(32))
python程序设计 大神帮帮忙吧 13 14题=_=
from math import sqrt
print(sqrt((x2-x1)**2 (y2-y1)**2)
def convert(x): #x is a list, x=[value, inch or foot]
if x[1] == "inch":
return 0.305*x[0]/12
else:
return 0.305*x[0]
关于python语言的小程序题 求指点,谢谢了!
import random
a=[]
i=random.randint(1,10)
for j in range(1,i 1):
x=random.randint(0,9)
a.append(x)
print a
k=random.randint(1,10)
b=[]
for m in range(1,k 1):
y=random.randint(0,9)
b.append(y)
print b
c=list(set(a)&set(b))
print c
d=list(set(a)|set(b))
print d
编程题~~~~
#include
void main()
{
char a;
int z=0,k=0,s=0,q=0;
printf("请输入一行字符: ");
while((a=getchar())!=
)
{
if(a>=a&&a<=z||a>=A&&a<=Z)
z ;
else if(a>=0&&a<=9)
s ;
else if(a== )
k ;
else
q ;
}
printf("字母:%d
数字:%d
空格:%d
其它字符:%d
",z,s,k,q);
}