-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython task 1.txt
More file actions
48 lines (39 loc) · 2.14 KB
/
Copy pathpython task 1.txt
File metadata and controls
48 lines (39 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Exercise 1: Basic Print Statements
Exercise: Write a program that prints the following information:
• Your name
• Your age
• Your favorite hobby
Exercise 2: Simple Variables and Types
Exercise: Create variables for the following:
• A string that stores the name of your favorite movie.
• An integer that stores your age.
• A float that stores your height in meters.
Exercise 3: Arithmetic Operations
Exercise: Given two numbers x = 15 and y = 4, perform the following operations and print the result:
• Addition
• Subtraction
• Multiplication
• Division
• Modulus (remainder)
Exercise 4: Working with Lists
Exercise: Create a list of your top 3 favorite foods. Then:
• Print the second fruit in the list.
• Add another fruit to the end of the list.
Exercise 5: Combining Strings
Exercise: Create two string variables, one for your first name and one for your last name. Then:
• Combine them into a full name using concatenation.
• Print a message like "Hello, my name is Full Name!" where Full Name is the combined string.
• Exercise 7: Input and Output
• Exercise: Write a program that asks the user to input their favorite color and favorite food. Then print a message like:
Your favorite color is red and your favorite food is pizza.
Exercise 6: Working with Numbers and Lists
Exercise: Now that you have worked with the numbers a = 12, b = 8, and c = 5, your task is to:
a. Manually calculate the average of the three numbers (you cannot use any built-in functions).
b. Multiply a, b, and c together and then subtract 10 from the result.
c. Calculate the difference between the largest and the smallest number.
d. Create a list that contains the numbers a, b, and c and then add to the list the average
Independent Exercise: Discount Calculator
Exercise: Write a program that calculates the discount based on the total purchase amount. Your task is to:
Ask the user to enter the total purchase amount.
If the total purchase is greater than or equal to 100, apply a 10% discount and print the final price.
If the total purchase is less than 100, apply a 5% discount and print the final price.