2.1 Python3基础-内置函数(print&input)
>>返回主目录



源代码
# 内置函数:输入/输出
name = 'Portos'
age = 18
sex = 'man'
score = 99.5
print('Hello World!') # 输出常量
print(name) # 输出变量
print('My name is:', name) # 混合输出
# 格式化输出:
print('My name is:%s' % name) # 格式化字符串多变量格式化输出
print('My name is:%s,age is:%d' % (name, age))
# 不指定位置,按默认排序
print('My name is:{},age is:{}'.format(name, age))
# 指定参数位置,默认从0开始
print('My name is:{1},age is:{0}'.format(age, name))
# format(),另一种写法如下:
print(f'My name is:{name},age is:{age}')



源代码
# input()输入函数
input('Please input a number:')
# 思考如下语句的执行结果,了解程序执行顺序
print('Your input is:', input('Please input:'))
'''
练习:在控制台输出如下内容:
+++++++++++++++++++++++++++
+欢迎光临,王者荣耀装备购买系统+
+++++++++++++++++++++++++++
请输入您的角色:
请输入当前装备:
请输入想替换的装备:
请输入金币数量:
恭喜您购买成功!
当前角色XX,已经替换原来装备XX为新装备XX,总共花费
XX金币!
'''
print('''
+++++++++++++++++++++++++++
+欢迎光临,王者荣耀装备购买系统+
+++++++++++++++++++++++++++
''')
role = input('请输入您的角色:')
equipment = input('请输入当前装备:')
change_equipment = input('请输入想替换的装备:')
money = input('请输入金币数量:')
print(f'恭喜您购买成功!当前角色{role},已经替换原来装备{equipment}为新装备{change_equipment},总共花费{money}金币!')
参考文献
全部内置函数:https://www.runoob.com/python3/python3-built-in-functions.html
>>返回主目录
2.1 Python3基础-内置函数(print&input)的更多相关文章
- Python3基础 内置函数 eval str转为list tuple dict
Python : 3.7.3 OS : Ubuntu 18.04.2 LTS IDE : pycharm-community-2019.1.3 ...
- Python3基础 内置函数 hash
Python : 3.7.3 OS : Ubuntu 18.04.2 LTS IDE : pycharm-community-2019.1.3 ...
- Python3基础 内置函数 dir 查询对象的方法列表
Python : 3.7.3 OS : Ubuntu 18.04.2 LTS IDE : pycharm-community-2019.1.3 ...
- Python3基础 内置函数 id
Python : 3.7.3 OS : Ubuntu 18.04.2 LTS IDE : pycharm-community-2019.1.3 ...
- python基础——内置函数
python基础--内置函数 一.内置函数(python3.x) 内置参数详解官方文档: https://docs.python.org/3/library/functions.html?highl ...
- python3.7 内置函数整理
#!/usr/bin/env python __author__ = "lrtao2010" #python3.7 内置函数整理 #abs(x) #返回数字的绝对值. 参数可以是整 ...
- python3.7内置函数整理笔记
#python3.7 内置函数整理 #abs(x) #返回数字的绝对值. 参数可以是整数或浮点数. 如果参数是复数,则返回其大小 # print(abs(1)) # print(abs(-1)) # ...
- python基础7之python3的内置函数
官方介绍: python3:https://docs.python.org/3/library/functions.html?highlight=built#ascii python2:https:/ ...
- python基础-内置函数详解
一.内置函数(python3.x) 内置参数详解官方文档: https://docs.python.org/3/library/functions.html?highlight=built#ascii ...
随机推荐
- hdu 6835 Divisibility 思维
题意: 给你一个10进制的b和x,对于任意的一个b进制的y.如果y每一位的和可以被x整除,且y可以被x整除:或者如果y每一位的和不可以被x整除,且y不可以被x整除.那么就输出T.否则输出F 题解: 代 ...
- 2020杭电多校 10C / HDU 6879 - Mine Sweeper (构造)
HDU 6879 - Mine Sweeper 题意 定义<扫雷>游戏的地图中每个空白格子的值为其周围八个格子内地雷的数量(即游戏内临近地雷数量的提示) 则一张地图的值\(S\)为所有空白 ...
- hdu5414 CRB and String
Problem Description CRB has two strings s and t. In each step, CRB can select arbitrary character c ...
- Git关联GitHub
1.打开git命令行工具 2.设置全局用户名.邮箱 git config --global user.name "your_name" git config --global us ...
- 【应急响应】Windows应急响应入门手册
0x01 应急响应概述 首先我们来了解一下两个概念:应急响应和安全建设,这两者的区别就是应急响应是被动响应.安全建设是主动防御. 所谓有因才有果,既然是被动的,那么我们在应急响应的时候就得先了解 ...
- scu-4440 rectangle (非原创)
Rectangle frog has a piece of paper divided into nn rows and mm columns. Today, she would like to dr ...
- OpenCV+Ubuntu+缺少Python.h
在cmake时粗心了, 要确保有 -D PYTHON_INCLUDE_DIR=/usr/include/python3.5 且该目录下存在Python.h文件. 如果在错误提示中是python2, 那 ...
- vue v-on-clickaway
vue v-on-clickaway Custom directive 自定义指令 https://stackoverflow.com/questions/36170425/detect-click- ...
- GitHub Classroom
GitHub Classroom GitHub Education https://classroom.github.com/classrooms https://classroom.github.c ...
- Flutter in DartPad
Flutter in DartPad Gist Sharing https://github.com/dart-lang/dart-pad/wiki/Sharing-Guide https://gis ...