1.据说智商140以上者称为天才,KiKi想知道他自己是不是天才,请帮他编程判断。输入一个整数表示一个人的智商,如果大于等于140,则表明他是一个天才,输出“Genius”。
- while True:
- try:
- a = int(input())
- if a >=140:
- print('Genius')
- except:
- break
2.KiKi想知道他的考试分数是否通过,请帮他判断。从键盘任意输入一个整数表示的分数,编程判断该分数是否在范围内,如果及格,即:分数大于等于60分,是输出“Pass”,否则,输出“Fail”。
- while True:
- try:
- a = int(input())
- if a>=60:
- print("Pass")
- else:
- print("Fail")
- except:
- break
3.KiKi想知道一个整数的奇偶性,请帮他判断。从键盘任意输入一个整数(范围-231~231-1),编程判断它的奇偶性。
- while True:
- try:
- num = int(input())
- if num%2 ==0:
- print("Even")
- else:
- print("Odd")
- except:
- break
4.KiKi开始学习英文字母,BoBo老师告诉他,有五个字母A(a), E(e), I(i), O(o),U(u)称为元音,其他所有字母称为辅音,请帮他编写程序判断输入的字母是元音(Vowel)还是辅音(Consonant)。
- v = ['A','a','E','e','I','i','O','o','U','u']
- while True:
- try:
- s = input()
- if s in v:
- print('Vowel')
- else:
- print('Consonant')
- except:
- break
5.牛牛从键盘输入整数 x 和左右边界 l 和 r 共三个整数。请你判断 x 是否在 l 和 r 之间。
- c=(input())
- x=int(c.split(' ')[0])
- l=int(c.split(' ')[1])
- r=int(c.split(' ')[2])
- if l<=x<=r:
- print('true')
- else:
- print('false')
6.判断一个整数n是否是闰年。
- n = int(input())
- if n%400==0 or (n%4==0 and n%100!=0):
- print("yes")
- else:
- print("no")
7.从键盘任意输入一个字符,编程判断是否是字母(包括大小写)。
- try:
- while True:
- a = input()
- if a.isalpha():
- print("YES")
- else:
- print("NO")
- except:
- print()
8.气象意义上,通常以3~5月为春季(spring),6~8月为夏季(summer),9~11月为秋季(autumn),12月~来年2月为冬季(winter)。请根据输入的年份以及月份,输出对应的季节。
- n=input()
- if(3<=int(n[-2:])<=5):
- print("spring")
- elif(6<=int(n[-2:])<=8):
- print('summer')
- elif(9<=int(n[-2:])<=11):
- print('autumn')
- else:
- print('winter')
9.BMI指数(即身体质量指数)是用体重公斤数除以身高米数平方得出的数字,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。例如:一个人的身高为1.75米,体重为68千克,他的BMI=68/(1.75^2)=22.2(千克/米^2)。当BMI指数为18.5~23.9时属正常,否则表示身体存在健康风险。编程判断人体健康情况。
- weight,height = map(float,input().split(' '))
- BMI = weight / (height ** 2)
- if (BMI >= 18.5) and (BMI <= 23.9):
- print('Normal')
- else:
- print('Abnormal')
10.小乐乐获得4个最大数,请帮他编程找到最大的数。
print(max(list(map(int, input().split(' ')))))
11.KiKi想判断输入的字符是不是字母,请帮他编程实现。
- while True:
- try:
- s = input()
- if s.isalpha():
- print("{} is an alphabet.".format(s))
- else:
- print('{} is not an alphabet.'.format(s))
- except:
- break
12.牛牛从键盘输入一个整数,请你判断这个整数能被 2 3 7 中哪几个数整除,并按升序输出。如果不能被 2 3 7 任意一个数整除则输出 n。
- n = int(input())
- if n % 2 == 0:
- print("2", end=" ")
- if n % 3 == 0:
- print("3", end=" ")
- if n % 7 == 0:
- print("7")
- if n % 2 != 0 and n % 3 != 0 and n % 7 != 0:
- print("n")
13.输入10个整数,分别统计输出正数、负数的个数。
- num_list = list(map(int, input().split()))
- pos = 0
- neg = 0
- for i in num_list:
- if i > 0:
- pos += 1
- else:
- neg += 1
- print('positive:%d' % pos)
- print('negative:%d' % neg)
14.KiKi非常喜欢网购,在一家店铺他看中了一件衣服,他了解到,如果今天是“双11”(11月11日)则这件衣服打7折,“双12” (12月12日)则这件衣服打8折,如果有优惠券可以额外减50元(优惠券只能在双11或双12使用),求KiKi最终所花的钱数。
- a,b,c,d = input().split()
- a = float(a)
- b,c,d = map(int,(b,c,d))
- if b==11 and c==11:
- if d==1:
- m = a*0.7-50
- else:
- m = a*0.7
- elif b==12 and c==12:
- if d==1:
- m = a*0.8-50
- else:
- m = a*0.8
- else:
- m = a
-
- if m <= 0.00:
- print('0.00')
- else:
- print('%.2f'%m)
15.牛牛正在寄快递,他了解到快递在 1kg 以内的按起步价 20 元计算,超出部分按每 kg 1元计算,不足 1kg 部分按 1kg计算。如果加急的话要额外付五元,请问牛牛总共要支付多少快递费。
- n = input().split()
- a, b = float(n[0]), n[1]
- if a <= 1:
- price = 20
- elif a > 1 and a % 1 == 0:
- price = (a - 1) * 1 + 20
- else:
- price = (a - 1 + 1) * 1 + 20
-
- if b == 'y':
- price = price + 5
-
- print(int(price))
16.牛牛商场促销活动:
满100打9折;满500打8折;满2000打7折;满5000打6折;
牛阿姨算不清楚自己应该付多少钱,请你帮忙算一下。
- money = float(input())
- if money >= 5000:
- print('{:.1f}'.format(money*0.6))
- elif money >= 2000:
- print('{:.1f}'.format(money*0.7))
- elif money >= 500:
- print('{:.1f}'.format(money*0.8))
- elif money >=100:
- print('{:.1f}'.format(money*0.9))
17.牛牛的通勤路上有两种选择,要么走路,要么打车,牛牛走路的速度是 1m/s 。打车的速度的 10m/s ,但是打车需要等出租车 10 s,请你计算牛牛想尽快到公司应该选择打车还是走路。
- a = int(input())
- if a < a / 10 + 10:
- print('w')
- else:
- print('v')
18.牛牛的一周有七天,从周一到周日对应的英文是
星期一:Monday、星期二:Tuesday、星期三:Wednesday
星期四:Thursday、星期五:Friday、星期六:Saturday、星期日:Sunday
牛牛知道今天是星期几,请输出这天的英文。
- day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
- a = int(input()) - 1
- print(day[a])
19.KiKi访问网站,得到HTTP状态码,但他不知道什么含义,BoBo老师告诉他常见HTTP状态码:200(OK,请求已成功),202(Accepted,服务器已接受请求,但尚未处理。)400(Bad Request,请求参数有误),403(Forbidden,被禁止),404(Not Found,请求失败),500(Internal Server Error,服务器内部错误),502(Bad Gateway,错误网关)。
- http_dict = {"200":"OK","202":"Accepted",
- "400":"Bad Request","403":"Forbidden",
- "404":"Not Found","500":"Internal Server Error",
- "502":"Bad Gateway"}
- while True:
- try:
- http_info = input()
- print(http_dict[http_info])
- except:
- break
20.KiKi想知道已经给出的三条边a,b,c能否构成三角形,如果能构成三角形,判断三角形的类型(等边三角形、等腰三角形或普通三角形)。
- while True:
- try:
- a,b,c = map (int,input().split())
- if a+b>c and a+c>b and b+c >a:
- if a==b==c:
- print('Equilateral triangle!')
- elif a ==b or b==c or c==a:
- print('Isosceles triangle!')
- else:
- print('Ordinary triangle!')
- else:
- print('Not a triangle!')
- except:
- break
21.牛牛有一个学习计划,他计划在 y 年 m 月 d 日开始学习,但在之前他是绝不会开始学习的,但是他一旦开始学习就不会停下来,请你判断 y1 年 m1 月 d1 日牛牛应该学习吗。
- import datetime
- y,m,d = map(int,input().split())
- y1,m1,d1 = map(int,input().split())
- a = datetime.date(y, m, d)
- b = datetime.date(y1,m1,d1)
- if a<=b:
- print('yes')
- else:
- print('no')
22.从键盘输入a, b, c的值,编程计算并输出一元二次方程ax2 + bx + c = 0的根,当a = 0时,输出“Not quadratic equation”,当a ≠ 0时,根据△ = b2 - 4*a*c的三种情况计算并输出方程的根。
- import math
- while True:
- try:
- a,b,c=map(float,input().split())
- x=b*b-4*a*c
- if a==0:
- print("Not quadratic equation")
- else:
- if x==0:
- x1=(0-b)/(2*a)+0.00001
- print("x1=x2={:.2f}".format(x1))
- elif x>0:
- x1=((0-b)-math.sqrt(x))/(2*a)
- x2=((0-b)+math.sqrt(x))/(2*a)
- print("x1={:.2f};x2={:.2f}".format(x1,x2))
- else:
- if a<0:
- x1=(0-b)/(2*a)
- x2=0-math.sqrt(0-x)/(2*a)
- print("x1={:.2f}-{:.2f}i;x2={:.2f}+{:.2f}i".format(x1,x2,x1,x2))
- else:
- x1=(0-b)/(2*a)
- x2=math.sqrt(0-x)/(2*a)
- print("x1={:.2f}-{:.2f}i;x2={:.2f}+{:.2f}i".format(x1,x2,x1,x2))
- except:
- break
23.KiKi想获得某年某月有多少天,请你编程实现,输入年份和月份,计算这一年这个月有多少天。
- while True:
- try:
- a,b=map(int,input().split())
- list31=[1,3,5,7,8,10,12]
- list30 = [4,6,9,10]
- if(list31.count(b)==1):
- print(31)
- elif(b==2):
- if(a%4==0):
- print(29)
- else:
- print(28)
- else:
- print(30)
-
- except:
- break
24.小乐乐的班级进行了一次期中考试,考试一共有3门科目:数学,语文,英语,小乐乐的班主任决定给没有通过考核的同学家长开一次家长会,考核的标准是三科平均分不低于60分,所以现在想请你帮忙算一算小乐乐会不会被叫家长。
- scores = list(map(int, input().split()))
- mean = sum(scores)/len(scores)
- if mean < 60:
- print("YES")
- else:
- print("NO")
25.每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字、1位识别码和3位分隔符,其规定格式如“x-xxx-xxxxx-x”,其中符号“-”是分隔符(键盘上的减号),最后一位是识别码,例如0-670-82162-4就是一个标准的ISBN码。ISBN码的首位数字表示书籍的出版语言,例如0代表英语;第一个分隔符“-”之后的三位数字代表出版社,例如670代表维京出版社;第二个分隔之后的五位数字代表该书在出版社的编号;最后一位为识别码。
识别码的计算方法如下:
首位数字乘以1加上次位数字乘以2……以此类推,用所得的结果mod 11,所得的余数即为识别码,如果余数为10,则识别码为大写字母X。例如ISBN号码0-670-82162-4中的识别码4是这样得到的:对067082162这9个数字,从左至右,分别乘以1,2,…,9,再求和,即0×1+6×2+……+2×9=158,然后取158 mod 11的结果4作为识别码。
你的任务是编写程序判断输入的ISBN号码中识别码是否正确,如果正确,则仅输出“Right”;如果错误,则输出你认为是正确的ISBN号码。
- st=input().replace('-','')
- s=sum([(ord(st[i])-48)*(i+1) for i in range(9) if st[i]!='-'])%11
- s='X' if s==10 else str(s)
- print('Right' if s==st[9] else st[0]+'-'+st[1:4]+'-'+st[4:9]+'-'+s)
26.KiKi实现一个简单计算器,实现两个数的“加减乘除”运算,用户从键盘输入算式“操作数1运算符操作数2”,计算并输出表达式的值,如果输入的运算符号不包括在(+、-、*、/)范围内,输出“Invalid operation!”。当运算符为除法运算,即“/”时。如果操作数2等于0.0,则输出“Wrong!Division by zero!”
- while True:
- try:
- lines = input()
- for ch in lines:
- if ch in ['+', '-', '*', '/']:
- a, b = map(float, lines.split(ch))
- if ch == '+':
- print('{:.4f}+{:.4f}={:.4f}'.format(a, b, a+b))
- elif ch == '-':
- print('{:.4f}-{:.4f}={:.4f}'.format(a, b, a-b))
- elif ch == '*':
- print('{:.4f}*{:.4f}={:.4f}'.format(a, b, a*b))
- else:
- if b == 0.0:
- print('Wrong!Division by zero!')
- else:
- print('{:.4f}/{:.4f}={:.4f}'.format(a, b, a/b))
- break
- else:
- print('Invalid operation!')
- except:
- break
