パイソンDays1

テキスト入力を使用してPythonの書き込みコード

入力をコンソールと読んで:

入力は、入力文字列の中にあります

evalの

jupyterで文書を解釈のうち、シフト+タブを使用して

演算子:

+:プラス

- :少ないです

*:乗算

/:に加え、

//:割り切れます

**:指数関数的パワー

%:剰余

強化された代入演算子:

= +:増加するので

- =:デクリメント

* =:乗

/ =:自己に加え、

コード:

摂氏=フロート(入力( '摂氏度を入力してください'))
華氏=(10/5)、*摂氏+ 32
プリント(.format(摂氏、華氏) "{0}摂氏{1}華氏です")

コード:

インポート数学
半径、長さ=評価(入力(「半径とシリンダの長さを入力してください」))
面積=半径** 2 *にMath.PIの
体積=面積*長
プリント(「領域は{0}」形式。 ( "%.4f" %面積))
プリント( "体積は{0}"フォーマット( "%。1F"体積%))

コード:

足=フロート(入力( 'フィートの値を入力:'))
メートル=フィート* 0.305
プリント(.format(フィート、メートル) "{0}足{1}メートルです")

コード:

water=float(input('Enter the amount of water in kilograms:'))
initialtemperature=float(input('Enter the initial temperature:'))
finaltemperature=float(input('Enter the final temperature:'))
Q = water * (finaltemperature - initialtemperature) * 4184
print("The energy needed is ",Q)

代码:

balance,interestrate=eval(input('Enter balance and interest rate (e.g., 3 for 3%):'))
interest=balance * (interestrate / 1200)
print("The interest is {0}".format("%.5f"%interest))

代码:

 v0,v1,t=eval(input('Enter v0,v1,and t:'))
a=(v1 - v0) / t
print("The average acceleration is {0}" .format("%.4f"% a))

代码:

number=float(input("Ener the monthly saving amount :"))
number1=0
for i in range(6):
    number1=(number+number1) * (1 + 0.00417)
print("After the sixth month,the account value is {0}".format("%.2f"% number1))

代码:

 number=float(input("Enter a number between 0 and 1000:"))
bai=int(number/100)
shi=int(number/10%10)
ge=int(number%10)
he=bai+shi+ge
print("The sum of the digits is ",he)

体会:

通过初时Python以及对他的语言元素的认识,对于python有了很深的印象

おすすめ

転載: www.cnblogs.com/huangchuan/p/11272641.html