Lab: Practice Problems III

If and else

Copy this into a Python file and add the specified code under each comment. For testing purposes, you can comment out working parts as you go (surround the lines with """).

"""
This is how you comment
out a whole block of stuff.
"""
# given the variable x with a number gotten from the user...
x = float(input("Number please: "))

# write python code to...

# print "big" or "small" depending on whether the number is greater than 10 or not


# print "even" or "odd" depending on whether the number is even or odd


# print *only one* of the following options, based on these rules:
#  "Too big" if the number is greater than 100
#  "Too small" if less than 20
#  "Too negative" if less than 0
#  "Just right" if in the range 20 to 100 (inclusive)


# given another variable y, with a second number gotten from the user...
y = float(input("Another number please: "))

# print the bigger number, x or y (not using the max function)


# given another variable z, with a third number gotten from the user...
z = float(input("Please sir, may I have some more?: "))

# print the biggest number, x, y or z (not using the max function)


# given this list
numbers = [-2, 4, -6, 9, 0, 2, 0, 4, -1, 0, 3]

# write a loop that updates the list (using an if-else tree), replacing:
#  every positive number with 100
#  every negative number with -100
#  every 0 stays the same