Python笔记————20180716

2-1

2-2简单消息:将一条消息储存到变量中,再将其打印出来。

message='This a simply message' 

print(message)
message='simply is not easy'

print(message)     

运行结果如下:


————————————————————————

2-3个性化消息:将用户的姓名储存到一个变量中,并向该用户显示一条消息

user_name = "shui peng peng"

print("Hello, " +user_name.title() +", would you like to learn some Python today.")

运行结果如下:




————————————————————————————————————

2-4调整名字的大小写

name = 'kfc'
print(name.title())
print(name.upper())
print(name.lower())
first_name = "ada"
last_name = "lovelace"
full_name = first_name + " " + last_name
print(first_name)
print(last_name)
print(full_name)

print("Hello, " + full_name.title()+"!")

运行结果如下:


——————————————————————————

2-5and2-6名言

famous_person = 'albert einstein'
saying = "A person who never made a mistake never tried something new."

print(famous_person.title() +" once said: " + '"' + saying + '"' )    

运行结果如下:

         

——————————————————————————

2-7删除人名中的空白

name = '   \n\tshui peng peng\n\t   '

print(name)
print(name.lstrip())
print(name.rstrip())

print(name.strip())

运行结果如下:


——————————————————————————

2-8 数字8

print(6 + 2)
print(2 * 4)
print(10 - 2)

print(16 / 2)

运行结果如下:


——————————————————————————

  2-9最喜欢的数字

favorite_number = 8

print("My favorite number is "+str(favorite_number)+".")      

运行结果如下


©️2020 CSDN 皮肤主题: 大白 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值