#!/usr/bin/dev python 声明解释器
# -*- coding:utf-8 -*- 编码类型(python2.版本默认使用aslce码,)

'''
变量名:
字母
数字
下划线

要求:
不能以数字开头
不能使用关键字
建议不要用python内置的。。。

循环语句
if elif else

while 条件
....
print('...')

补充:
1.while else
2.continue 终止当前循环,开始下一次循环
3.break 终止所有循环

'''

'''
#if,else语句

if 1 == 1:
if 2 == 2:
print("欢迎来到北京")
print("欢迎来到上海")
else:
print("欢迎来到武汉")
else:
print("欢迎来到广州")
'''


'''
if,elif多循环语句

inp = input('请输入段位级别:')

if inp == "王者":
print('大佬')
elif inp == "星耀":
print('有手就行')
elif inp == "钻石":
print('单手能上')
else:
print('小学生')

PS:
pass指空代码,无意义,仅仅用于表示代码块
'''


'''
基本数据类型

字符串 - n1 = "alex" n2 = 'root' n3 = """eric"""
数字 - age=21 weight = 64 fight = 5

加减乘除等
字符串
加法:
n1 = "alex"
n2 = "sg"
n3 = 'ss'
n4 = n1 + n2 + n3
最终结果等于:alexsgss

乘法:
n1 = 'alex'
n2 = n1 * 10

加减乘除次方余:
a1 = 10
a2 = 20
a3 = a1 + a2 加
a3 = a1 - a2 减
a3 = a1 * a2 乘
a3 = 100 / 10 除
a3 = a1 ** a2 次方
a3 = 39 % 8 #%获取39除以8得到的余数
a3 = 39 / 8 #/获取39除以8得到的数
'''


'''
num = 12
n = num % 2
if n == 0:
print('偶数')
else:
print('奇数')
'''


'''
import time

count = 0
while count < 10:
if count != 7:
print(count)
else:
pass
count = count + 1
print(123)

'''

'''
count = 0
while count < 10:
if count != 7:
print(count)
break #continue
else:
pass
count = count + 1
print(123)
'''

'''
循环
死循环
while 1==1:
print('ok')
'''
'''
练习题
1,使用while循环1 2 3 4 5 6 8 9 10

n = 1
while n <= 10:
if n != 7:
print(n)
else:
pass
n = n + 1
print('--------')
'''

'''
#2,求1-100的所有数的和

n = 1
s = 0
while n <= 100:
s = s + n
n = n + 1

print(s)

'''

'''
3,输出1-100内的所有奇数

n = 1
while n <= 100:
sum = n % 2
if sum == 0:
pass
else:
print(n)
n = n + 1
print('------end--------')

'''

'''
#4,输出1-100内的所有偶数
n = 1
while n <= 100:
sum = n % 2
if sum == 1:
pass
else:
print(n)
n = n + 1
print('------end--------')
'''

'''
#5,求1-2+3-4+5 ... 99的所有数的和
n = 1
s = 0
while n < 100:
sum = n & 2
if sum == 0:
s = s - n
else:
s = s + n
n = n + 1
print(s)
'''


'''
#6,用户登录(三次机会重试)

count = 0
while count < 3:
user = input('请输入用户名')
pwd = input('请输入密码')
if user == 'test' and pwd == '123':
print('欢迎登录')
break
else:
print('用户名或密码错误')
count = count + 1
'''

posted on 2022-04-12 20:01  痴人_说梦  阅读(16)  评论(0编辑  收藏  举报