Assignment 18 — simple conditional analysis
Due Saturday, October 10
Program do_u_relate.py
- Produce a program that prompts for two integers and reports the relationship between them. There should be no other output.
- If the first input is less than the second input, display exactly the string
'less than'
and nothing else.
- If the first input is equal to the second input, display exactly the string
'equal to'
and nothing else.
- If the first input is greater than the second input, display exactly the string
'greater than'
and nothing else.
- Some possible program runs
Enter two numbers: 0 0equal to
Enter two numbers: 3 -7greater than
Enter two numbers: 7 12less than
Program same_diff.py
- Produce a program that prompts for two integer inputs and reports whether or not they have same sign. There should be no other output.
- Two numbers have the same sign if they are either both positive or are both negative. For assignment purposes, zero is a positive number. If they have the same sign, display exactly the string
'have same sign'
and nothing else; otherwise, display exactly the string'have different signs'
and nothing else.
- Some possible program runs
Enter two numbers: 3 -5have different signs
Enter two numbers: -2 -1have same sign
Enter two numbers: 88888888 88888888have same sign
Enter two numbers: -12 11have different signs
🦆 © 2022 Jim Cohoon | Resources from previous semesters are available. |