2017-01-29 18 views
-2

私は数日間この作業をしています。私はいくつかのチュートリアルを見て、私の本を読んで、私は非常にコーディングに新しいです。pythonの倍数19

Iはこのプログラムは次に、200よりも大きい19の倍数を入力するようにユーザに促すべき

、プログラムは、入力を分析し、各に対する応答を表示する必要があり、このプログラムを作成するために必要としてい分析の4つの可能な結果。以下のサンプルランを参照してください。

Enter an exact multiple of 19 that is greater than 200 76 
No, 76 is a multiple of 19 but it is not greater than 200 
>>> 
Enter an exact multiple of 19 that is greater than 200 55 
55 is not over 200 and also is not a multiple of 19 
>>> 
Enter an exact multiple of 19 that is greater than 200 222 
222 is over 200 but is not a multiple of 19 
>>> 
Enter an exact multiple of 19 that is greater than 200 380 
Good input. 19 divides into 380 exactly 20 times 

この

は私が持っているもので、これまで

#promt user to enter an exact multiple of 19 that is larger than 200 
#assign variable a to user input 
def main() : 
    random = int(input('Enter an exact multiple of 19 that is greater than 200:')) 

    number = random/19 


    if random > 200 : 
     print('Good input 19 divides into', random , 'exactly' , number ,'times') 


    if random % 19 == 0 or random <200: 
     print('is a multiple of 19') 

    else: 
     print('is not a multiple of') 


main() 

私は380を入力するユーザーのためのラインを吐き出すためにプログラムを得ることができますが、私は限りアップ書き方などの損失で午前他の出力。ヘルプは素晴らしいだろう!

私はイムは、彼の宿題をやってと思うけれども、私は、働いた何相続人
+0

ああ、OLE」fizzbuzzテスト。 (これは、銀の皿に手渡さずにそれを理解するのに十分であるはずです) – Enfyve

答えて

-1

...:

def main(): 
    try: 
     random = int(input('Enter an exact multiple of 19 that is greater than 200:')) 
    except ValueError: 
     print("Not a number") 
     return 

    number = random % 19 #if number==0 it's divisible by 19 

    if random <= 200: #checks to see if the number is less than 200 

     if number == 0: #if the num is divisible by 19 but less than 200 

      print("Enter an exact multiple of 19 that is greater than 200. No, {0} is a multiple of 19 but it is not greater than 200".format(random)) 

     else: #if the num is not divisible by 19 ant it's less than 200 

      print("Enter an exact multiple of 19 that is greater than 200. No, {0} is not over 200 and also is not a multiple of 19".format(random)) 

     return 

    if number != 0: #if the number is over 200 buy not divisible by 19 

     print("Enter an exact multiple of 19 that is greater than 200. No, {0} is over 200 but is not a multiple of 19".format(random)) 
     return 
    #every other possibility: divisible by 19 and over 200 
    print('Good input 19 divides into {0} exactly {1} times'.format(random, random/19)) 

main() 
+3

彼らのために宿題をする代わりに、コードを説明してください。 – Carcigenicate

+0

@ brittmoe09次回はあなたの宿題をしてください!私はあなたの問題を解決した場合、私にあなたを助けるためのチェックマークを与えるために自由に落ちてください:) – kda