>>返回主目录







源代码

# 内置函数:输入/输出
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)的更多相关文章

  1. Python3基础 内置函数 eval str转为list tuple dict

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  2. Python3基础 内置函数 hash

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  3. Python3基础 内置函数 dir 查询对象的方法列表

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  4. Python3基础 内置函数 id

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  5. python基础——内置函数

    python基础--内置函数  一.内置函数(python3.x) 内置参数详解官方文档: https://docs.python.org/3/library/functions.html?highl ...

  6. python3.7 内置函数整理

    #!/usr/bin/env python __author__ = "lrtao2010" #python3.7 内置函数整理 #abs(x) #返回数字的绝对值. 参数可以是整 ...

  7. python3.7内置函数整理笔记

    #python3.7 内置函数整理 #abs(x) #返回数字的绝对值. 参数可以是整数或浮点数. 如果参数是复数,则返回其大小 # print(abs(1)) # print(abs(-1)) # ...

  8. python基础7之python3的内置函数

    官方介绍: python3:https://docs.python.org/3/library/functions.html?highlight=built#ascii python2:https:/ ...

  9. python基础-内置函数详解

    一.内置函数(python3.x) 内置参数详解官方文档: https://docs.python.org/3/library/functions.html?highlight=built#ascii ...

随机推荐

  1. poj2778 DNA Sequence(AC自动机+矩阵快速幂)

    Description It's well known that DNA Sequence is a sequence only contains A, C, T and G, and it's ve ...

  2. hdu2430Beans(单调队列)

     Mr. Pote's shop sells beans now. He has N bags of beans in his warehouse, and he has numbered them ...

  3. NCD 2019 H. Mr. Hamra and his quantum particles

    题意:给你n个数,有m次操作,每次使得两个数相连接,询问q次,问某两个数是否连接在一起. 题解:这其实是一道并查集的裸题,这里就不再多说了,写个路径压缩的find函数即可. 代码: #include ...

  4. JavaScript——变量及作用域

  5. 11.PowerShell DSC之安装PowerShell Module

    打开https://powershellgallery.com,检索你需要的目标模块,我们以安装名为"xmysql"的module为例: 自动安装 1.执行命令install-mo ...

  6. 一句话木马的简单例子 网站webshell & 远程连接

    一  概述 本地 kail  linux 目标 windows nt 服务器 二 过程 首先编写一句话木马  index.php 一句话木马的原理就是把C=xxx 字符串当成php语句执行 注意这里用 ...

  7. 一道思维题 &&递归改循环

    思路: 比如5 2 12345--> 1245 从3开始,这时候5变成了1.剩下4512,对应1234.只需要找到现在n-1,k中的数对应原来的编号的映射. 比如1-->3 是1+2 mo ...

  8. Leetcode(23)-合并K个排序链表

    合并 k 个排序链表,返回合并后的排序链表.请分析和描述算法的复杂度. 示例: 输入: [   1->4->5,   1->3->4,   2->6 ] 输出: 1-&g ...

  9. mybatis(三)配置mapper.xml 的基本操作

    参考:https://www.cnblogs.com/wuzhenzhao/p/11101555.html XML 映射文件 本文参考mybatis中文官网进行学习总结:http://www.myba ...

  10. 力扣485. 最大连续1的个数-C语言实现-简单题

    题目 [题目传送门] 给定一个二进制数组, 计算其中最大连续1的个数. 示例 1: 输入: [1,1,0,1,1,1] 输出: 3 解释: 开头的两位和最后的三位都是连续1,所以最大连续1的个数是 3 ...