Following are the questions of the midterm held on Week 4. You can access the solutions using the week4 link above.
- Get a number from the user and print 'odd' if number is odd or print 'even; if number is even.
Example - 1:
Enter a number 42
evenEnter a number 13
odd- Get birth year from the user, calculate user's age and output following based on the age range of the user.
- If age is less than 15 (including 15) “kid”
- 15-40 (including 15 - excluding 40) “young”
- 40-60 (including 40 – excluding 60) “middle age”
- 60 or older than 60 “old”
Example:
Enter your birth year: 2010
kid- Calculate the sum of odd numbers between two numbers that is got from user (excluding entered numbers).
Example: (3 + 5 = 8)
Enter first number: 2
Enter last number: 7
8- Get a number n between 1 and 9 from user and print the value of expression n+nn+nnn.
Example - 1: (1+11+111=123):
Enter a number: 1
123Example - 2: (3+33+333=369):
Enter a number: 3
369- Get a number from the user and print the patern shown in the example with number of rows equal to given number.
Example:
Enter a number: 5
1
22
333
4444
55555- User will enter numbers a and b. Given that a and b will be integers; print the numbers between a and b (including a and b) that have even squareroot value.
Example:
Enter number a: 1
Enter number b: 40
4
16
36