2. Against All "Odds"
by CodeChum Admin
Looping numbers is fun, but it's even more exciting when we combine complex tasks to it, just like looping through a series of numbers and performing a series of code only to special numbers, like odd ones! And today, we're going to do just that.
Are you ready?
Instructions:
Input a random positive integer. This will serve as the starting point of the loop.
Using a while() loop, print out all the odd numbers starting from the inputted integer, until 0. The outputted numbers must all be separated by line.
Input
A line containing an integer.
10
Output
Multiple lines containing an integer.
9
7
5
3
Businesses are categorized as small, medium, & large based on their turnover profit. If up to $5,000 profit is realized in a month, business should be classified as small, $5,000 but up to $10,000 is realized in a month, business should be classified as medium, when more than $10,000, the business should be considered as large. Your application should:
a) Request for a company's profit to be entered. Categorize the company into small, medium, and large scale based on the profit made.
b) Create a method to compute the following taxes:
1. Small scale, first $2500 tax of 3.5% and 6.7% for any other profit made
2. Medium scale, first $7800 tax of 6.6% and 9.2% for any other profit
3. Large scale, first $16000, tax of 9.3% and 13% for any other profit. NB. Percentage profit is per month
c) Program should calculate 2% extra tax on the calculated tax for refuse collection and display the following result:
1. Category, tax and refuse tax
2. Total tax which is the sum of the tax and refuse tax.
Write a program that reverses the number entered by the user. Formulate
an equation to come up with the answer. (Hint: You are going to use the modulus
operator.)
Sample Output:
Enter a number: 1234
Number in reverse: 4321
For each function, describe what it actually does when called with a string argument. If it does not correctly check for lowercase letters, give an example argument that produces incorrect results, and describe why the result is incorrect.
# 3
def any_lowercase3(s):
for c in s:
flag = c.islower()
return flag
For each function, describe what it actually does when called with a string argument. If it does not correctly check for lowercase letters, give an example argument that produces incorrect results, and describe why the result is incorrect.
# 2
def any_lowercase2(s):
for c in s:
if 'c'.islower():
return 'True'
else:
return 'False'
Create a program that will display the corresponding college level of s given input year level. The year and the college are given below:
Note: Use if else if statement.
Year Level College Level
1 Freshmen
2 Sophomore
3 Junior
4 Senior
Other years Unlisted Level
For each function, describe what it actually does when called with a string argument. If it does not correctly check for lowercase letters, give an example argument that produces incorrect results, and describe why the result is incorrect.
# 1
def any_lowercase1(s):
for c in s:
if c.islower():
return True
else:
return False
Create a program using the while statement that displays the numbers 0
through 117, in increments of 9.
Create a program that will display the corresponding college level of s given input year level. The year and the college are given below:
Note: Use if else if statement.
Year Level College Level
1 Freshmen
2 Sophomore
3 Junior
4 Senior
Other years Unlisted Level
Create a program that will display the corresponding remark of a given input grade. The range of grades and its corresponding remark are given below:
Note: Use switch case statement
Range of Grades Remarks
90-100 Excellent
80-89 Good
75-79 Fair
50-74 Poor
Other grades Out-of-range