Read whole and negative numbers in Phyton

Asked

Viewed 2,608 times

-2

I’m new to Phyton and I don’t know how to create all the code required in the statement. The following statement reads: Read whole numbers from the keyboard until a negative number is keyboard. Write, if any, the five largest numbers read. If less than five numbers are read, show all numbers read. Restriction It is not allowed to keep in memory more than six numbers read.

1 answer

0


To read an integer in python:

x = int(input("Enter a number: "))

To make a loop until a condition is reached:

while (<expressão_condicional>):
    <código_executado>

An example:

count = 0
while (count < 9):
   print 'The count is:', count
   count = count + 1

Now, as to the logic of the proposed question, it is quite simple. I suggest you try to resolve it with the information I have given you. After all, if I posted it here, you couldn’t copy and use it on your college paper, because it would be plagiarism.

  • I appreciate the help so far. I’m in need of this north, see what I’m hitting and what I’m missing. Thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.