日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

一、认识Python

發(fā)布時間:2024/4/17 python 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 一、认识Python 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.Hello World~!

>>> print("Hello World~!") Hello World~!

2.簡單交互(交互式,文件式)

>>> name=input("輸入姓名:") 輸入姓名:kok >>> print("{}先生,你好。".format(name)) kok先生,你好。

3.用戶輸入兩個數(shù)字,計算兩數(shù)之和

>>> n1=input('n1=') n1=123 >>> n2=input('n2=') n2=456 >>> n1+n2 '123456' >>> float(n1)+float(n2) 579.0

4.輸入三角形三邊長度,求三角形面積(海倫公式)

>>> a=float(input("a="))
a=10
>>> b=float(input("b="))
b=8
>>> c=float(input("c="))
c=6
>>> p=(a+b+c)*0.5
>>> print(p)
12.0
>>> S=(p*(p-a)*(p-b)*(p-c))**0.5
>>> print("三角形面積為{}")
三角形面積為{}
>>>? print("三角形面積為{}".format(S))
?
SyntaxError: unexpected indent
>>> print(S)
24.0
>>>

不理解為什么不能整體解釋:

?

5.輸入半徑,求圓面積

>>> r=10 >>> Sc=r*r*3.14159265 >>> print('Sc') Sc >>> print(Sc) 314.159265

6.一行代碼完成計算兩數(shù)之和

>>> print("T=:%.2f"%(float(input('n1='))+float(input('n2=')))) n1=10 n2=20 T=:30.00

7.畫一組同切圓

import turtle turtle.pensize(2) turtle.circle(10) turtle.circle(40) turtle.circle(80) turtle.circle(140)

8.繪制五角星(縮進-即空4格,代表該代碼屬于循環(huán)內(nèi))

import turtleturtle.bgcolor("red") //背景色 turtle.fillcolor("yellow") //填充顏色 turtle.color('yellow')//線條顏色 turtle.begin_fill() for i in range (5):turtle.forward(200)turtle.right(144)turtle.end_fill()

9.畫一組同心圓。

import turtle #第一個圓形 turtle.penup() turtle.goto(0,-150) turtle.pendown() turtle.circle(150) #第二個圓形 turtle.penup() turtle.goto(0,-50) turtle.pendown() turtle.circle(50) #第三個圓形 turtle.penup() turtle.goto(0,-100) turtle.pendown() turtle.circle(100)

?

轉(zhuǎn)載于:https://www.cnblogs.com/maykok/p/7483889.html

總結(jié)

以上是生活随笔為你收集整理的一、认识Python的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。