首页 > 编程语言 >【笨方法学python】ex5 - 更多的变量和打印

【笨方法学python】ex5 - 更多的变量和打印

时间:2022-10-05 03:56:27浏览次数:64  
标签:weight python age height hair ex5 print my 方法学

代码如下:

点击查看代码
# -*-coding:utf-8- -*-
# 更多的变量和打印

my_name = 'P.S'
my_age = 28
my_height = 183 # cm
my_weight = 100 # kg
my_eyes = 'Black'
my_teeth = 'White'
my_hair = 'Black'

# print "Let's talk about %s." % my_name
# print "He's %d cm tall." % my_height
# print "He's %d kg heavy." % my_weight
# print "Actually that's not too heavy."
# print "He's got %s eyes and %s hair." % (my_eyes, my_hair)
# print "His teeth are usually %s depending on the coffee." % my_teeth

# # this line is tricky, try to get it exactly right
# print "If I add %d, %d, and %d I get %d." % (my_age, my_height, my_weight,my_age + my_height + my_weight)

# 中文
print "让我们说一下 %s。" % my_name
print "他的身高是 %d cm。" % my_height
print "他有 %d 公斤重" % my_weight
print "实际上并不是很重。"
print "他有 %s 色的眼睛和 %s 色的头发。" % (my_eyes, my_hair)
print "由于经常喝咖啡,他的牙齿是 %s 色的。" % my_teeth

# this line is tricky, try to get it exactly right
print "如果我把年龄 %d, 身高 %d,体重 %d 相加,我将得到 %d 。" % (my_age, my_height, my_weight,my_age + my_height + my_weight)

执行结果:
image

标签:weight,python,age,height,hair,ex5,print,my,方法学
From: https://www.cnblogs.com/TiramisuPS/p/16754962.html

相关文章

  • 【笨方法学python】ex6 - 字符串(string)和文本
    代码如下:点击查看代码#-*-coding:utf-8--*-#字符串(string)和文本x="Thereare%dtypesofpeople."%10binary="bianry"do_not="don't"y="Thosewh......
  • 【笨方法学python】ex7 - 更多打印
    代码如下:点击查看代码#-*-coding:utf-8--*-#更多打印print"Maryhadalittlelamb."print"Itsfleefewaswhiteas%s."%'snow'print"Andeverywhereth......
  • 【笨方法学python】ex8 - 打印,打印
    代码如下:点击查看代码#-*-coding:utf-8--*-#打印,打印formatter="%r%r%r%r"printformatter%(1,2,3,4)printformatter%('one','two','three','......
  • 【笨方法学python】ex9 - 打印,打印,打印
    代码如下:点击查看代码#-*-coding:utf-8--*-#打印,打印,打印#Here'ssomenewstrangestuff,remembertypeitexactly.days="MonTueWedThuFriSatSun"......
  • 【笨方法学python】ex2 - 注释符
    代码如下:点击查看代码#-*-coding:utf-8-*-#Acomment,thisissoyoucanreadyourprogramlater.#Anythingafterthe#isignoredbypython.#一个注释......
  • 【笨方法学python】print
    代码如下#-*-coding:utf-8--*-print"HelloWorld"print"HelloAgain"print"Iliketypingthis."print"Thisisfun."print"Yay!Printing."print"I'dmuch......
  • Python 注册菜单
    我们看到下面的示例图是在右键文件夹上查看菜单,带有两级的菜单选项。需要使用管理员权限运行因为右键菜单需要注册表信息,打开注册表需要管理员权限UAC,所以在执行命令过......
  • python安装及环境变量配置
    python环境变量配置1、双击安装包,出现如下的安装界面,选择自定义安装2、选项设置,默认全部勾选即可3、高级配置选线,如图勾选即可4、如下图所示,安装过程中5、......
  • python 输出
    1.print()函数1.1print()输出格式①print()可以输出多个内容print(内容1,内容2,...,内容3)②print(f"内容1{},内容2{}...")③print(""%())1.2print输出换行与不......
  • XX学Python·前端
    HTML:网页结构布局HTML(HyperTextMark-upLanguage)超文本标记语言。HTML控制页面整体布局书写形式用标签形式, <标签名称> </标签名称>,比如: <html></html......