日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:檢查一個數(shù)字是不是霓虹數(shù)字

創(chuàng)新互聯(lián)python教程:

創(chuàng)新互聯(lián)公司是一家專注網(wǎng)站建設、網(wǎng)絡營銷策劃、成都微信小程序、電子商務建設、網(wǎng)絡推廣、移動互聯(lián)開發(fā)、研究、服務為一體的技術型公司。公司成立10多年以來,已經(jīng)為1000+成都陽光房各業(yè)的企業(yè)公司提供互聯(lián)網(wǎng)服務?,F(xiàn)在,服務的1000+客戶與我們一路同行,見證我們的成長;未來,我們一起分享成功的喜悅。

編寫一個 Python 程序來檢查一個數(shù)字是不是霓虹數(shù)字,或者是否使用 while 循環(huán)。如果一個數(shù)等于平方數(shù)位數(shù)之和,它就是霓虹數(shù)。例如,9 是一個霓虹數(shù)字,因為 92 = 81,8 +1 = 9

在這個 python 例子中,首先,我們找到一個數(shù)的平方。接下來,把那個正方形分成幾個獨立的數(shù)字,求出總和。如果總和等于實際數(shù)字,它就是一個霓虹數(shù)字。

import math

Number = int(input("Enter the Number to Check Neon Number = "))
Sum = 0

squr = math.pow(Number, 2)
print("Square of a Given Digit = %d" %squr)

while squr > 0:
    rem = squr % 10
    Sum = Sum + rem
    squr = squr // 10

print("The Sum of the Digits   = %d" %Sum)

if Sum == Number:
    print("\n%d is a Neon Number." %Number)
else:
    print("%d is Not a Neon Number." %Number)

Python 程序檢查一個數(shù)字是不是 neon 數(shù)或者不使用遞歸或者遞歸函數(shù)。

# Python Program to Check Neon Number
import math
Sum = 0

def neonNumber(squr):
    global Sum
    if squr > 0:
        rem = squr % 10
        Sum = Sum + rem
        neonNumber(squr // 10)
    return Sum

Number = int(input("Enter the Number to Check Neon Number = "))

squr = math.pow(Number, 2)
print("Square of a Given Digit = %d" %squr)

Sum = neonNumber(squr)
print("The Sum of the Digits   = %d" %Sum)

if Sum == Number:
    print("\n%d is a Neon Number." %Number)
else:
    print("%d is Not a Neon Number." %Number)
Enter the Number to Check Neon Number = 44
Square of a Given Digit = 1936
The Sum of the Digits   = 19
44 is Not a Neon Number.

Enter the Number to Check Neon Number = 9
Square of a Given Digit = 81
The Sum of the Digits   = 9

9 is a Neon Number.

使用 for 循環(huán)和 while 循環(huán)打印從 1 到 n 的霓虹數(shù)字的 Python 程序。

import math

MinNeon = int(input("Please Enter the Minimum Neon Value = "))
MaxNeon = int(input("Please Enter the Maximum Neon Value = "))

for i in range(MinNeon, MaxNeon + 1):
    Sum = 0
    squr = math.pow(i, 2)

    while squr > 0:
        rem = squr % 10
        Sum = Sum + rem
        squr = squr // 10

    if Sum == i:
        print(i, end = '  ')
Please Enter the Minimum Neon Value = 1
Please Enter the Maximum Neon Value = 10000
1  9 

分享文章:Python程序:檢查一個數(shù)字是不是霓虹數(shù)字
本文地址:http://www.5511xx.com/article/cdsddoc.html