ENE 201 – HW3
Due: September 25, 2024 at 23:59
Please answer the following questions and make sure to provide clear, well-explained answers. Please
include the necessary Python code where applicable. Once you have completed the assignment in the
MS Word template, save your work and convert the final document to a PDF file. Submit the PDF
version of your homework via Blackboard. Make sure to name your PDF file in the following format:
YourName_UniversityID_HW3.pdf
If you do not have Python installed in your device, you can use the following online tool when it is needed.
https://www.programiz.com/python-programming/online-compiler/
Answer the following
1. Define an integer variable. Write a Python program that checks if the number is
positive. If the number is positive, print the following message: "The number is
positive." Otherwise, nothing should be printed. Check the output with values of the
integer to be 1 and -1
2. Modify the Python program in question 1 to print the message "The number is not
positive." If the condition is false.
3. Modify the Python program in question 2 to print the message "The number is
negative." If the entered integer is negative. Otherwise, it should print the message
"The entered number is zero."
4. Write a Python program that checks if the entered number is even or odd. If the
entered number is even, the program should print the message "The entered number is
even". Otherwise, the message "The entered number is odd" should appear. Hint: to
check if a number is even, the number should be evenly divisible by 2 with no remainder.
Use the modulus (%) operator for checking the reminder of a division by 2
5. Assume you have the following definition:
idNumber Season
1 Fall
2 Winter
3 Spring
4 Summer
Define a variable named " idNumber" to take integer value. Write a Python program that
reads the defined variable and print the corresponding season. The program should print
"Fall" if "idNumber" is equal to 1 and so on using an else if ladder. If the entered number is
not in the list, print "The entered number is invalid"
6. Define three integer variables. Write a Python program that reads those three integers
and check if the first integer is the sum of the second and third integers. If it is true,
print the message "The first number is the sum of the second and third." Otherwise
print "The first number is not the sum of the second and third."
7. Rework question 5 using match-case statement. Note: it is new feature in Python 10.3
(https://docs.python.org/3/whatsnew/3.10.html#pep-634-structural-pattern-matching )