Skip to content

ReDi-school-Berlin/week-3-homework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Homework for Week 3

(Scroll down for some reminder on cloning this repository and making commits)

Exercises:

Exercise 1.) Errors encountered Before doing exercises 2 to 4, be aware of the errors that you encounterUsing Conditional statements (if, else, elif)

  • Before doing exercises 2 to 4, be aware of the errors that you encounter
  • For each exercise below, list down some of the errors (Developers usually call it bug") you saw
  • What did you do to solve the error?
  • NOTE: The more errors you get familiar with, the better. That means you are adding to what you are learning from the lessons. "Practice makes perfect".

Exercise 2.) Using Conditional statements (if, else, elif)

  • Situation: Citizens apply for financial benefits from the government whose policy is to grant government employee benefits for only 2 of his children, 1.000Euro for each child if he/she is less than or equal to 20 years old.
  • Write a set of codes using the conditional statements (if, else, elif) that checks the following conditions:
  • If citizen's occupation is a government employee, check if he has kids eligible for benefits, calculate the total benefit amount
  • If citizen's occupation is an entrepreneur, output the message "You make sure you pay your tax!"
  • If citizen has other occupation, output the message "This facility is only for government employees!"
  • At the end output the message "Total benefit availed: " and total benefit amount

(hint: Assign different values to the occupation of the citizen)

Exercise 3.) Applying the "for" loop

  • Have you watched Mary Poppins? I haven't but there is a loooooong word that became popular from that movie.
  • Let's do a bit of coding using the "for" loop
  • Assign this loooooong word "supercalifragilisticexpialidocious" to a string variable
  • For each letter in this looooooong word, print it
  • Count the number of letters
  • Print the number of letters at the end.

Exercise 4.) Applying the "while" loop

  • Do you have a bicycle that has flat tyre. Imagine pumping up its tyre. Its inflation percentage is currently 20.
  • Write a few codes that will do the following until the inflation percentage <100:
  • Output "PUMP TYRE"
  • Each time you pump the tyre, you add 10 to the inflation percentage
  • Output "Tyre inflation percentage " and the new inflation percentage after you pumped some air

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages