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

歡迎訪問 生活随笔!

生活随笔

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

python

英寸和厘米的交互python_Python的新手-尝试将厘米编码为英寸,反之亦然

發布時間:2025/3/15 python 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 英寸和厘米的交互python_Python的新手-尝试将厘米编码为英寸,反之亦然 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這個問題已經在這里有了答案:????????????>????????????How to test multiple variables against a value?????????????????????????????????????21個

我是python的新手,我的任務是編寫厘米到英寸,反之亦然.這個想法是用戶輸入一個數字,程序詢問他們是否要將其從英寸轉換為厘米或將厘米轉換為英寸,然后顯示結果.

我在Mac上使用python 3.3.5很有幫助.

這是我的代碼:(注釋掉的部分顯示了任務和我的第一次嘗試)

##

##Write a program that converts between centimetres, and inches and vice versa, by:

##asking the user to input a number

##asking the user to choose between converting from centimetres to inches or from inches to centimetres

##calculating and outputting the result using functions

##### Old attempt

##print(" Program to convert beteween centimetres and inches " )

##

##centimetre = 1

##inch = centimetre * 2.45

##

##number = input (" Please enter a number: ")

##choice = input (" Do you want to convert into centimetres or inches: ")

##if choice == "centimetres" or "Centimetres":

## print("Your number is", centimetre*number, "cm")

##else:

## print("Your number is",number*inch, "inches")

number = int(input(" Please enter a number: "))

choice = input(str(" If you want to convert from centimetres to inches type 'A' \n If you want to convert from inches to centimetres type 'B': "))

if choice in "A" or "a":

print(" Your number is" , number*2.54,"inches")

else:

print(" Your number is", number/2.54, "centimetres")

找到答案,謝謝您的快速答復!

解決方法:

例如,如果將“ A”或“ a”中的條件“選擇”更改為“如果選擇”中的“ Aa”:條件,則可以測試選擇是“ A”還是“ a”.原始版本始終評估為True.

標簽:python

總結

以上是生活随笔為你收集整理的英寸和厘米的交互python_Python的新手-尝试将厘米编码为英寸,反之亦然的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。