Exercise
Pair Of Negative Values
Objective
Develop a Python program that prompts the user for two numbers and checks if both numbers are negative.
Example Python Exercise
Show Python Code
# Prompt the user to enter the first number
num1 = float(input("Please enter the first number: "))
# Prompt the user to enter the second number
num2 = float(input("Please enter the second number: "))
# Check if both numbers are negative and display the result
if num1 < 0 and num2 < 0:
print(f"Both {num1} and {num2} are negative.")
else:
print(f"Both numbers are not negative.")
Output
Please enter the first number: -5
Please enter the second number: -3
Both -5.0 and -3.0 are negative.
Share this Python Exercise
Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.
In this exercise, you will develop a Python program that prompts the user for two numbers and checks whether both are negative, only one is negative...
In this exercise, you will develop a Python program that displays the numbers from 1 to 500 that are multiples of both 3 and 5 on the screen. You...
In this exercise, you will develop a Python program that prompts the user for a number and a quantity, then displays that number repeated as many...
In this exercise, you will develop a Python program that prompts the user to enter their login and password (both must be integer numbers). The p...
In this exercise, you will develop a Python program that prompts the user for their login and password, both of which must be integers. The progr...
In this exercise, you will develop a Python program that prompts the user for two numbers and displays their division and remainder. If 0 is entered as ...