首页 技术 正文
技术 2022年11月11日
0 收藏 904 点赞 2,942 浏览 1552 个字

>>> if 3>2:print(‘ok’)

ok
>>> if True:print(3);print(5)

>>> chTesst=[‘1′,’2′,’3′,’4′,’5’]
>>> if chTesst:
print(chTesst)
else:
print(‘Empty’)

[‘1’, ‘2’, ‘3’, ‘4’, ‘5’]
>>> a=5

>>>
>>>

>>> import math
>>> x=math.sqrt(9) if 5>3 else random.randint(1,100)
>>> x
3.0
>>> x=3

>>> (1 if x>2 else 0) if x>5 else (‘a’ if x<5 else ‘b’)
‘a’
>>> def func(score):
if score > 100:
return ‘wrong score.must<=100.’
elif score >=90:
return ‘A’
elif score >=80:
return ‘B’
elif score >=70:
return ‘C’
elif score >=60:
return ‘D’
elif score >=0:
return ‘E’
else:
return ‘wrong score.must >0’

>>> func(120)
‘wrong score.must<=100.’
>>> func(-10)
‘wrong score.must >0’
>>> def func1(score):
degree=’DCBAAE’
if score>100 or score<0:
return ‘wrong score.must between 0 and 100.’
else:
index=(score-60)//10
if index>=0:
return degree[index]
else:
return degree[-1]

>>> func(10)
‘E’
>>> func(70)
‘C’
>>> func(100)
‘A’

>>> func(90)
‘A’
>>> age=24
>>> subject=’computer’
>>> college=’non-key’
>>> if (age>24 and subject==’computer’) or (college==’key point’ and subject==’computer’) or (age<=28 and subject==’computer’):
print(“Congratulations, you have my company’s interview”)
else:
print(“I’m sorry, you do not meet the requirements of the interview”)

Congratulations, you have my company’s interview
>>> numbers=[]

>>> if year%400==0 or (year%4==0 and year%100!=0):
day_month[1]=29
if month==1:
print(day)
else:
print(sum(day_month[:month-1])+day)

>>> if year%400==0 or (year%4==0 and year%100!=0):
day_month[1]=29
if month==1:
print(day)
else:
print(sum(day_month[:month-1])+day)

>>>
>>> date
time.struct_time(tm_year=2017, tm_mon=5, tm_mday=23, tm_hour=20, tm_min=14, tm_sec=48, tm_wday=1, tm_yday=143, tm_isdst=0)
>>> import datetime
>>> Today=datetime.date.today()
>>> Today
datetime.date(2017, 5, 23)

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,955
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,479
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,291
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,108
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,740
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,774