-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25afd6c
commit 96490eb
Showing
10 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
for i in range(1,10): | ||
print() | ||
for j in range(1,i+1): | ||
print("{}x{}={}\t".format(j,i,i*j),end='') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
age=int(input("请输入你的年龄:")) | ||
print(f"你确定你已经{age}岁了吗") | ||
if age>=18: | ||
print("你尽然已经成年了,那我就给你我的珍品吧") | ||
elif age<18: | ||
print("未成年禁止访问,滚") | ||
else: | ||
print("你要干什么") | ||
|
||
|
||
print("欢迎来到黑马儿童游乐场,儿童免费,成人收费") | ||
age1=int(input("请输入你的年龄:")) | ||
if age>=18: | ||
print("您已成年,游玩需要补票10元") | ||
else: | ||
print("您未成年,可以免费游玩") | ||
print("祝您游玩愉快") | ||
|
||
|
||
|
||
|
||
num=5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# ##print输出语句 Input输入的内容 | ||
# name=input("请告诉我你是谁:") | ||
# print("尊敬的:%s"%name) | ||
# num=input("尊敬的%s先生,请输入你的银行卡号码:"%name) | ||
# num=int(num) | ||
# print("你的银行卡类型是",type(num)) | ||
|
||
|
||
user_name=input("请输入你的名字:") | ||
if user_name=="王海涛": | ||
user_type="ssssvip" | ||
else: | ||
print("不是SSSSSVIP,无法进入") | ||
exit(0) | ||
print("您好:",user_name,"您是尊贵的:",user_type,"用户,欢迎您的光临") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
money=50 | ||
print("1",money) | ||
money=money-10 | ||
print(money) | ||
print("现在是1点我有",money+1,"圆子") | ||
print("现在是2点我有",money+3,"圆子") | ||
print("现在是3点我有",money+5,"圆子") | ||
print("现在是4点我有",money+7,"圆子") | ||
print("现在是5点我有",money+9,"圆子") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
##== 判断书否相等 !=判断是否不相等 | ||
a=6 | ||
b=7 | ||
txt=a<b | ||
print(txt,type(txt)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
##字符串的三种定义方式 | ||
name="张楚岚" | ||
print(type(name),name) | ||
name2='张楚岚2' | ||
print(type(name2),name2) | ||
name3="""张楚岚3""" | ||
print(type(name3),name3) | ||
#在字符串内,包含双引号 | ||
hacker="张楚岚" | ||
#在字符串内,包含引号 | ||
web="'Marco'" | ||
|
||
##字符串的拼接 | ||
print("张楚岚"+"Marco") | ||
print("学it来黑马"+"月入过万") | ||
namr4="张楚岚" | ||
address="19" | ||
tel=10000000000000 | ||
print("我是",name,"我今年",address,"岁",tel) | ||
|
||
|
||
##字符串格式化 占位符 | ||
#字符串为%s 整数为%d 浮点数为%f | ||
#占位拼接 | ||
name5="张楚岚" | ||
age=19 | ||
message="我叫%s,我今年%s岁"%(name5,age) | ||
print(message) | ||
#通过展位完成数字和字符串的拼接 | ||
class_num=57 | ||
ave_num=16781 | ||
nesss="周口职业技术学院%s班级,我的学号为%s"%(class_num,ave_num) | ||
print(nesss) | ||
|
||
name5="北京大学" | ||
setup_year=2022 | ||
stock_price=19.99 | ||
message_num="我来自%s,我的年级为%d,我的钱包为%f"%(name5,setup_year,stock_price) | ||
print(message_num) | ||
|
||
|
||
num1=11 | ||
num2=11.321 | ||
print("数字11宽度限度5,结果为:%5d"%num1) | ||
print("数字11宽度为1魏国为:%1d"%num1) | ||
print("数字11.76宽度先付为7,小数为2结果为:%.2f"%num2) | ||
##简便方式 | ||
print(f"我是{num1},我今天的股票为{num2}") | ||
|
||
#字符串格式化 | ||
print(f"18*11的结果为:{18*11}") | ||
print(f"字串的类型是:%s"%type("字符串")) | ||
|
||
|
||
#练习 | ||
name="周口职业技术有限公司" | ||
stock_price=19.99 | ||
stock_code="003032" | ||
stock_prie_daily_growth_factor=1.2 | ||
gorwth_days=15 | ||
print(f"公司:{name},股票代码{stock_code},当前股价{stock_price}") | ||
num1222="每日增长系数为:%f,经过%d天的增长后,股票达到了:%f"%(stock_prie_daily_growth_factor,gorwth_days,(stock_price+stock_price*stock_prie_daily_growth_factor*gorwth_days)) | ||
print(num1222) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name="张楚岚" | ||
nme_type=type(name) | ||
print(nme_type) | ||
string_ytpe=type("张楚岚") | ||
string_ytpe2=type(1.5678) | ||
print(string_ytpe2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#python允许的标识符 | ||
#英文 | ||
#中文 | ||
#数字 | ||
#_ | ||
##数字不可以在开头 | ||
andy="安迪1" | ||
Andy="安迪2" | ||
print(Andy) | ||
print(andy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
##装数字类型转换为字符串 | ||
num_str=str(11) | ||
print(type(num_str),num_str) | ||
flaot_str=str(11.345) | ||
print(type(flaot_str),flaot_str) | ||
#字符串转换为数字 | ||
num=int("11") | ||
print(type(num),num) | ||
|
||
num2=float("11.345") | ||
print(type(num2),num2) | ||
#错误!想要将字符串转换为数字,要求为字符串内容都是数字 | ||
#num3=int("张楚岚") | ||
#print(type(num3),num3) | ||
#整数3转浮点数 | ||
float_num=float(11) | ||
print(type(float_num),float_num) | ||
#浮点数转整数 | ||
int_num=int(11.345) | ||
print(type(int_num),int_num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
print("1+1=",1+1) | ||
print("4/2",4/2) | ||
##/ 为除法 //为整除 | ||
print("15//3",15//2) | ||
print("9%2",9%2) | ||
## **为次方 | ||
print(2**2) | ||
#复合赋值运算符 | ||
num=1+2*3 ##赋值 | ||
num2=1 | ||
num+=1 | ||
num=3 | ||
num%=2 | ||
num**=2 | ||
print(num) |