python while 和 if的用法

# money =int(input('你有多少钱?'))
# if money > 50:
#     print ('打车回家')
#     b = input('到家了吗?')
#     if b == '到家了':
#         print ('我到家了阿')
#     else :
#         pass


# please = input('你是男的还是女的?')
# if please == '男的' or please == '男':
#     print('你走吧')
# elif please == '美女':
#     age = int(input("今年多大拉?"))
#     if int(age) > 30:
#         print('走好吧您内')
#     else:
#         print('我家的瓜,特别甜')

# score = int(input ('分数:'))
# if score == 0:
#     print('1')
# elif score == 60:
#     print(2)
# elif score >= 90:
#     print(3)

# a = int(input("abc:"))
# if a > 10:
#     print(666)
# print('li')


# 1、使用用while循环输出 1 2 3 4 5 6 8 9 10
#
# a= 0
# while a < 10:
#     a = a +1
#     print(a)
# # 2、求1-100的所有数的和
# a = 0
# b = 1
# while b < 101:
#     a = a + b
#     b = b + 1
# print(a)
# 2、求1-100的所有数的和 a
# a = 0
# b = 1
# while b < 101:
#     a = a + b
#     b = b + 1
# print(a)
# 3、输出 1-100 内的所有奇数
# a = 0
# while a <= 100:
#     if a % 2==0:
#         a = a+1
#
#     else :
#         print(a)
#         a = a + 1

# n = 1
# while n<101:
#     if n % 2 == 0:
#         n = n + 1
#     else:
#         print(n)
#         n = n + 1

# 4、输出 1-100 内的所有偶数

# a = 0
# while a <=100:
#     if a % 2 == 0:
#         print(a)
#         a = a + 1
#     else :
#         a = a +1

# 5、求1-2+3-4+5 ... 99的所有数的和
# i=1
#定义一个变量sum为0,用来存放和
# sum=0
# while i<=100:
# 	#每次sum和i相加
# 	if i%2==0:
# 		sum+=i
# 	i+=1
# #执行完之后,打印sum的值
# print("1-100之间偶数和是%d"%sum)


# 6、用用户登陆(三次机会重试)
# z = "123"
# x = "000000"
# c = 0
# while c < 3:
#     a = input("w")
#     b = input("m")
#     if a ==z and b == x:
#         print('欢迎')
# 
#     else :
#         print('bb')
#         c = c +1

python%格式化输出

a = input ('年龄')
b = input('姓名')
c = input('性别')
print('''----------info----------
年龄%s
姓名%s
性别%s
---------ooo--------
 ''' %(a,b,c))

or and 输出

>>> 0 or 4
4
>>> 3 or 6
3
#and与or相反,运算顺序:() > not > and > or
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值