|
1 | 1 | ## Section 10 Exercises
|
2 | 2 |
|
3 | 3 | # Section A
|
4 |
| -1. Create a Person class, initialise it with a name. Create a method for the Person class that will say hello to the name. |
5 |
| -2. Create a Circle class, initialise it with a radius. Create two methods for the Circle class: get_area() and get_circumference() which give both respective areas and circumference, to 2 decimal placese. |
| 4 | +1. Create a class called Upper which has two methods called get_word and print_word. |
| 5 | + - the get_word method should accept a string from the user |
| 6 | + - the print_word method prints the string in upper case. |
| 7 | +2. Create a Person class, initialise it with a name. Create a method for the Person class that will say hello to the name. |
| 8 | +3. Create a Circle class, initialise it with a radius. Create two methods for the Circle class: get_area() and get_circumference() which give both respective areas and circumference, to 2 decimal placese. |
6 | 9 | - Note: Area of a circle = πr ** 2
|
7 | 10 | - Circumference = 2πr
|
8 | 11 | - Use the round() function to get the answer to 2 decimal places
|
9 |
| -3. Create a Employee class and initialise it with name and staff number. |
| 12 | +4. Create a Employee class and initialise it with name and staff number. |
10 | 13 | - i. Make methods to:
|
11 | 14 | - display_info - It should display all the information of the employee.
|
12 | 15 | - set_department - It should assign the department to employee.
|
|
17 | 20 | - Given a person's first and last names:
|
18 | 21 | - Form the full_name method by simply joining the first and last name together, separated by a space.
|
19 | 22 | - Form the email_address by joining the first and last name together with a . in between, and follow it with @company.com at the end. Make sure everything is in lowercase.
|
20 |
| -4. Create a Vehicle parent class, initialise it with, wheels, colour and a method to display all this information. |
| 23 | + |
| 24 | +5. Create a Vehicle parent class, initialise it with, wheels, colour and a method to display all this information. |
21 | 25 | - i. Create a Tesla (or any car) child classs and add a method to get the miles and a method to display all this information.
|
22 | 26 | - ii. Change the colour of the vehicle.
|
23 | 27 | - iii. Delete the wheels.
|
24 |
| -5. Create a class called Upper which has two methods called get_word and print_word. |
25 |
| - - the get_word method should accept a string from the user |
26 |
| - - the print_word method prints the string in upper case. |
| 28 | + |
27 | 29 | 6. Create a Sandwich class with the attributes order_number and ingredients.
|
28 | 30 | - i. The ingredients attributes is given as a list - (Note: use list(<atrribute>) to enable this).
|
29 | 31 | - Only the ingredients attributes will be given as input.
|
|
0 commit comments