Python输入输出练习
1.hello world
print('hello world')
2.交互式
name=input('name=:') print('我的名字是:{}'.format(name))
3.两者之和
print('两者之和为:%.0f'%float(float(input('输入第一个数字:'))+float(input('输入第二个数字:'))))
4.三角形面积
a=float(input('a=')) b=float(input('b=')) c=float(input('c=')) p=float((float(a+b+c))/2) print('三角形abc的面积为:%.0f'%float((p*(p-a)*(p-b)*(p-c))**0.5))
5圆的面积
r=float(input('半径为:')) print('半径为{}的面积为:%.2f'.format(r) %float(3.1314 * r * r))
6同切圆
import turtle turtle.circle(5) turtle.circle(10) turtle.circle(15) turtle.circle(20)
7.五角星
import turtle turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100)
8填充颜色的五角星
import turtle turtle.bgcolor('red') turtle.color('yellow') turtle.fillcolor('yellow')turtle.begin_fill()turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100)turtle.end_fill()
9国旗
import turtle turtle.color('yellow') turtle.bgcolor('red') turtle.fillcolor('yellow')turtle.begin_fill()turtle.up() turtle.goto(-200,100) turtle.down()turtle.forward(150) turtle.right(144) turtle.forward(150) turtle.right(144) turtle.forward(150) turtle.right(144) turtle.forward(150) turtle.right(144) turtle.forward(150) turtle.end_fill()turtle.begin_fill()turtle.up() turtle.goto(-80,160) turtle.down()turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.end_fill()turtle.begin_fill()turtle.up() turtle.goto(-22,68) turtle.down()turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.end_fill()turtle.begin_fill()turtle.up() turtle.goto(-30,110) turtle.down()turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.end_fill()turtle.begin_fill()turtle.up() turtle.goto(-45,-10) turtle.down()turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.right(144) turtle.forward(50) turtle.end_fill()
转载于:https://www.cnblogs.com/husiqi/p/7491880.html
Python输入输出练习相关推荐
- Python 输入输出
1 格式化输出 Python 输出值的方式有两种:表达式语句和 print 函数(文件对象的输出使用 write 方法,标准文件输出可以参考 sys.stdout ,详细文档). 如果我们想要将输出的 ...
- python输入输出-python 输入输出 - 刘江的python教程
输入输出 阅读: 18476 评论:6 无论是从我们一开始的"hello world",还是前面章节的里各种例子,基本都是些"自说自话",展示类的代码片段.只有 ...
- python输入输出-6、Python 输入输出
一 .输入 1.说明 输入输出,简单来说就是从标准输入中获取数据和将数据打印到标准输出,常被用于交互式的环境当中,Python中 input()来输入标准数据 2.语法格式 格式:input() 功能 ...
- python输入输出-Python3
Python 输入和输出 在前面几个章节中,我们其实已经接触了 Python 的输入输出的功能.本章节我们将具体介绍 Python 的输入输出. 输出格式美化 Python两种输出值的方式: 表达式语 ...
- python输入输出重定向_Python标准输出重定向
Python标准输出重定向 标签: Python stdout 重定向 声明 本文基于Python2.7版本,介绍常见的几种标准输出(stdout)重定向方式.显然,这些方式也适用于标准错误重定向. ...
- python输入输出-Python3输入输出
Python两种输出值的方式,表达式语句和print()函数. 第三种方式是使用文件对象的write()方法,标准输出文件可以用sys.stdout的引用. 如果你希望输出的形式更加多样,可以使用st ...
- python输入输出-python输入输出及变量
知识内容: 1.python输出及注释 2.变量及常量 3.python用户输入 4.Hello,World程序 一.python输出及注释 1.python输出 在python2和python3中的 ...
- python输入输出-2. Python中的基本输入、输出、格式化输出
本文利用的是Python 3.x版本,建议学习3.x版本 Python中的基本输入.输出.格式化输出 1. 输入 使用input([prompt])读取一行,将其转换为string类型并返回,inpu ...
- python输入输出-Python input()和print()终端输入输出
Python 中的输入和输出主要分为终端和文件两种.终端输出常用 print( ) 函数实现,之前已经多次使用,print( ) 函数输出字符串通常有两种方式,一是使用 str( ) 函数将数字型数据 ...
- python输入输出-python输入与输出
python输出 python3中的输出 python3中的输出使用函数print(),示例如下: >>> print('hello kitty') print()也可接受多个参数, ...
最新文章
- usaco Fence Loops
- [svc][op]vim自动添加注释
- SD2C大会,JavaScript + Delphi + ErLang 讲演相关资料完全公开!
- 解决JDBC连接MySQL时发出的警告WARN: Establishing SSL connection without server‘s identity verification ...
- Android新手入门2016(10)--GridView
- 老师说过链表是分水岭,至少得会这些题目
- linux进程号函数,linux进程
- C#操作config文件
- Postman:ResponseHeader存在多个Set-Cookie时,教你获取Cookie值
- 关于查看文件size
- mysql awk_Awk实用手册(全)
- FastReport.Net使用:[1]屏蔽打印对话框
- 订单接收不同业务消息设计
- 【java】输出素数
- [矩阵的QR分解系列二] 吉文斯(Givens)变换
- Ubuntu18.04安装mysql8.0.XX
- nRF52832 BLE UART
- 计算机网络第三章——数据链路层
- Arduino 用4位共阴数码管造一个计数器
- 百万亚瑟王无法连接服务器请在信号良好的地方重试,乖离性百万亚瑟王无法匹配怎么解决 匹配失败原因和解决方法...
热门文章
- 2015年传智播客JavaEE 第168期就业班视频教程day38-SSH综合案例-1
- iOS键盘监听以及获取键盘高度
- BZOJ 1734: [Usaco2005 feb]Aggressive cows 愤怒的牛( 二分答案 )
- 通过onkeydown事件来控制只允许数字
- gemfire资料网址
- 我要养成写博客的好习惯!
- [技巧]CSS的超级技巧大放送
- 关于html的一切(updating...)
- java manager 如何使用_java – Android:如何使用AlarmManager
- spring boot文件的上传与下载