- 简述编译型与解释型语言的区别,且分别列出你知道的哪些语言属于编译型,哪些属于解释型
编译型:c,执行速度快,调试比较麻烦
解释型:python,执行速度慢,调试方便
- 执行 Python 脚本的两种方式是什么
1.命令行方式
2.脚本文件方式
- Pyhton 单行注释和多行注释分别用什么?
单行注释可以使使用单引号或者双引号
多行注释使用三个单引号或者三个双引号
- 布尔值分别有什么?
False和True
- 声明变量注意事项有那些?
变量名只能是 字母、数字或下划线的任意组合
变量名的第一个字符不能是数字
关键字不能声明为变量名
- 如何查看变量在内存中的地址?
使用id(变量名)
实现用户输入用户名和密码,当用户名为 seven 且 密码为 123 时,显示登陆成功,否则登陆失败!
user='seven'
password='123'
inp_user=input('please input your username: ')
inp_pass=input('please input your password: ')
if inp_user == user and inp_pass == password:
print('login succ')
else:
print('username or password wrong')
实现用户输入用户名和密码,当用户名为 seven 且 密码为 123 时,显示登陆成功,否则登陆失败,失败时允许重复输入三次
user='seven'
password='123'
tag=0
while tag<3:
tag+=1
inp_user=input('please input your username: ')
inp_pass=input('please input your password: ')
if inp_user == user and inp_pass == password:
print('login succ')
break
else:
print('username or password wrong')
实现用户输入用户名和密码,当用户名为 seven 或 alex 且 密码为 123 时,显示登陆成功,否则登陆失败,失败时允许重复输入三次
user1='seven'
user2='alex'
password='123'
tag=0
while tag<3:
tag+=1
inp_user=input('please input your username: ')
inp_pass=input('please input your password: ')
if (inp_user == user1 or inp_user == user2) and inp_pass == password:
print('login succ')
break
else:
print('username or password wrong')
a. 使用while循环实现输出2-3+4-5+6...+100 的和
tag=1
sum=0
while tag < 100:
tag+=1
if tag%2 != 0:
sum = sum - tag
else:
sum = sum + tag
print(sum)
b. 使用 while 循环实现输出 1,2,3,4,5, 7,8,9,11,12
tag=0
while tag < 12:
tag+=1
if tag != 6 and tag != 10:
print(tag)
c.使用 while 循环实现输出 1-100 内的所有奇数
tag=0
while tag < 100:
tag+=1
if tag % 2 != 0:
print(tag)
d. 使用 while 循环实现输出 1-100 内的所有偶数
tag=0
while tag < 100:
tag+=1
if tag % 2 == 0:
print(tag)
现有如下两个变量,请简述 n1 和 n2 是什么关系?
n1 = 123456
n2 = n1
n1和n2类型相同,value相同并且内存地址相同