Skip to content

Latest commit

 

History

History
78 lines (49 loc) · 1.67 KB

File metadata and controls

78 lines (49 loc) · 1.67 KB

Unit 3 Practice

Exercise 4 - Number Proximity

4.1

  • Assign a number to a variable.

  • Determine whether the number is within 10 of 100.

Output

number: 92
output: 92 is within 10 of 100.

number: 108
output: 108 is within 10 of 100.

number: 51
output: 51 is not within 10 of 100.

4.2

  • Have the user enter values for number_1 and number_2.

  • Determine whether number_1 is within 10 of number_2.

Output

Enter the first number: 36
Enter the second number: 28
output: 36 is within 10 of 28.
---

Enter the first number: 251
Enter the second number: 260
output: 251 is within 10 of 260.
---

Enter the first number: 95
Enter the second number: 15
output: 95 is not within 10 of 15.

4.3

  • Have the user enter values for number_1 and number_2.

  • Have the user choose the limit of how many numbers may be in between the two.

  • Determine whether number_1 and number_2 are within the limit set by the user.

    Enter the first number: 235
    Enter the second number: 555
    Enter how far apart the numbers are allowed to be: 1000
    
    235 is within 1000 of 555.
    ---
    
    Enter the first number: 66
    Enter the second number: 62
    Enter how far apart the numbers are allowed to be: 5
    
    66 is within 5 of 62.
    ---
    
    Enter the first number: 34
    Enter the second number: 101
    Enter how far apart the numbers are allowed to be: 20
    
    34 is not within 20 of 101.
    

Exercise 4 solution