導航:首頁 > 編程語言 > python外源輸入數字

python外源輸入數字

發布時間:2022-07-25 05:23:13

A. python輸入幾個數字並用符號*表示輸出,比如下圖

code_number={0:[[1,1,1,1,1,1],

[1,0,0,0,0,1],

[1,0,0,0,0,1],

[1,0,0,0,0,1],

[1,0,0,0,0,1],

[1,0,0,0,0,1],

[1,1,1,1,1,1]],

1:[[1],

[1],

[1],

[1],

[1],

[1],

[1]],

2:[[1,1,1,1,1,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1],

[1,1,1,1,1,1],

[1,0,0,0,0,0],

[1,0,0,0,0,0],

[1,1,1,1,1,1]],

3:[[1,1,1,1,1,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1],

[1,1,1,1,1,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1],

[1,1,1,1,1,1]],

4:[[1,0,0,1,0,0],

[1,0,0,1,0,0],

[1,0,0,1,0,0],

[1,0,0,1,0,0],

[1,1,1,1,1,1],

[0,0,0,1,0,0],

[0,0,0,1,0,0]],

5:[[1,1,1,1,1,1],

[1,0,0,0,0,0],

[1,0,0,0,0,0],

[1,1,1,1,1,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1],

[1,1,1,1,1,1]],

6:[[1,1,1,1,1,1],

[1,0,0,0,0,0],

[1,0,0,0,0,0],

[1,1,1,1,1,1],

[1,0,0,0,0,1],

[1,0,0,0,0,1],

[1,1,1,1,1,1]],

7:[[1,1,1,1,1,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1]],

8:[[1,1,1,1,1,1],

[1,0,0,0,0,1],

[1,0,0,0,0,1],

[1,1,1,1,1,1],

[1,0,0,0,0,1],

[1,0,0,0,0,1],

[1,1,1,1,1,1]],

9:[[1,1,1,1,1,1],

[1,0,0,0,0,1],

[1,0,0,0,0,1],

[1,1,1,1,1,1],

[0,0,0,0,0,1],

[0,0,0,0,0,1],

[1,1,1,1,1,1]]}

defnum_to_code(num):

num_list=[code_number[int(i)]foriinnum]

fornum_rowinzip(*num_list):

forrow_numsinnum_row:

foriinrow_nums:

print('*'ifielse'',end='')

print('',end='')

print('')


num=input('輸入數字:')

num_to_code(num)



B. python3.4輸入數字

>>>x=int(input("x:"))
x:40
>>>y=int(input("y:"))
y:20
>>>x+y
60
輸入內容作為int()的參數,將字元串轉換成int

C. python寫一個要求用戶輸入數字,如果不是數字就一直循環要求輸入,直到輸入數字為止的代碼

主要出在eval上。
python3.0

第一個方案:
while True:
ten=input("x:")
try:
x=eval(ten)
if type(x)==int:break
except:pass
然後輸入asf,沒有提示。輸入344就退出了
x:asf
x:344

第二個方案
while True:
ten=None
try:
ten=int(input("x:"))
except:pass
if type(ten)==int:break
這個在python3.0上調試通過

第三個方案:python2.x的方案
while True:
ten=raw_input("Enter a number:")
if ten.isdigit():break
ten=int(ten) #或者是ten=eval(ten)

都調試過。可以用

D. python如何自行輸入一串數字。。。。我是零基礎。。

#-*-coding:utf-8-*-
#定義一個空list,然後用10次循環將10個數字傳遞進list
#在對list進行求和,求平均

#python2.7版本
l=[]
foriinrange(10):
l.append(int(raw_input("請輸入一個數字:")))
print"這10個數字是:",l
print"求和:",sum(l)
print"求平均",(sum(l)/10.0)

#python3.x版本
l=[]
foriinrange(10):
l.append(int(input("請輸入一個數字:")))
print("這10個數字是:",l)
print("求和:",sum(l))
print("求平均:",(sum(l)/10))

E. python寫一個要求用戶輸入數字,如果不是數字就一直循環要求輸入,直到輸入數字為止的代碼有哪些

具體解決辦法如下:

第一個方案:

1.復制代碼,如下,

while True:

ten=input("x:")

try:

x=eval(ten)

if type(x)==int:

break

except:

pass

2.然後輸入asf,沒有提示。輸入344就退出了

x:asf

x:344

第二個方案

1.復制代碼

while True:

ten=None

try:

ten=int(input("x:"))

except:

pass

if type(ten)==int:

break

這個在python3.0上調試通過

第三個方案:python2.x的方案

while True:

ten=raw_input("Enter a number:")

if ten.isdigit():

break

ten=int(ten) #或者是ten=eval(ten)

F. python怎麼從鍵盤輸入數字

raw_input()得到的是字元串
input()得到的是數值

G. 用python編寫一個程序,提示用戶輸入 一個整數,並逐個顯示其中的每個數字

代碼:

n=input('請輸入一個整數:')

for i in range(len(n)):

print(f'第{i+1}個數字是:{n[i]}')

截圖:

H. 怎麼在python裡面,用鍵盤輸入信息

I. python怎麼輸入數字

num=input('請輸入數字:')
try:
num=float(number)
except:
print('你輸入的不是數字啊')
return
print('你輸入的數字是:'+num)

閱讀全文

與python外源輸入數字相關的資料

熱點內容
qt下編譯生成mqtt庫 瀏覽:541
南京中興招收專科程序員嗎 瀏覽:297
代理商php源碼 瀏覽:983
蘋果手機怎麼解壓軟體app 瀏覽:650
游戲資源被編譯 瀏覽:152
代碼編譯後黑屏 瀏覽:8
程序員情侶寫真 瀏覽:505
python3孿生素數 瀏覽:36
計算楊輝三角Python 瀏覽:404
linux目錄重命名 瀏覽:196
演算法設計的最終形態是代碼 瀏覽:262
程序員社團招新橫幅 瀏覽:238
拖鞋解壓視頻大全 瀏覽:887
租伺服器主機鏈接軟體叫什麼 瀏覽:856
交叉編譯工具的linux版本號 瀏覽:156
python開發應用軟體 瀏覽:32
hdl綜合器與c編譯器的區別 瀏覽:899
編譯原理最左推導代碼 瀏覽:702
加密三 瀏覽:131
通過編譯鏈接後形成的可執行程序 瀏覽:680