Assignment 18 — simple conditional analysis
Due Tuesday, October 15
Program do_you_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 the string
'less than'
- If the first input is equal to the second input, display the string
'equal to'
- If the first input is greater than the second input, display the string
'greater than'
- Three possible program runs
Enter two numbers: 0 0equal to
Enter two numbers: 3 -7greater than
Enter two numbers: 7 12less than
Program same_difference.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 the string
'have same sign'
; otherwise, display the string'have different signs'
.
- Four sample runs
Enter two numbers: 3 -5have different signs
Enter two numbers: -2 -1have same sign
Enter two numbers: 8 8have same sign
Enter two numbers: -12 11have different signs
© 2019 Jim Cohoon | Resources from previous semesters are available. |