Help with Python program

Discussion in 'Python' started by beginner_python, Oct 2, 2022.

  1. beginner_python

    beginner_python New Member

    Joined:
    Sep 27, 2022
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    Gender:
    Male
    I am having trouble with an assignment in computer science. The teacher wants us to Write a program with a loop that asks the user to enter a series of positive numbers (using input validation). The user should enter a negative number to signal the end of the series. After all the positive numbers have been entered, the program should display the largest and smallest of the numbers entered. I don't think we are allowed to use any lists as we have not got to that part yet.

    The code I have so far is :

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

    while positive_number >= 0:
    positive_number = int(input("Please enter a positive number:"))
    if positive_number < 0:
    break
     
  2. beginner_python

    beginner_python New Member

    Joined:
    Sep 27, 2022
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    Gender:
    Male
    Please ignore this post, I manage to figure out the answer
     
    shabbir likes this.
  3. unni krishnan.r

    unni krishnan.r Member

    Joined:
    Apr 20, 2010
    Messages:
    209
    Likes Received:
    4
    Trophy Points:
    18
    Occupation:
    education
    Location:
    Kerala
    Home Page:
    http://blogofunni.blogspot.com
    are the intentations correctly given?
     
  4. amadjan

    amadjan New Member

    Joined:
    Nov 24, 2022
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    how you fixed it
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice