Question: PC7.1-PC7.5 One individual practical assignment including threetasks Task 1: Write/complete a Python program to solve a problem using if and if-else block structures Create an

PC7.1-PC7.5 One individual practical assignment including threetasks

Task 1: Write/complete a Python program to solve a problem using if and if-else block structures

Create an if statement that will check if the marks variable is greater than or equal to 60. If true, create a print statement that will output Pass and print Fail if condition fails

Test conditions with different values for marks

Answer:

Task 2: Determine the output for the following code

 
if (n > 10):
 print("*****")
if (n > 7):
 print("****")
if (n > 4):
 print("***")
if (n > 1):

print("**")

How many *will be printed when the code is executed in the following cases:

a) with n = 6?

b) with n = 1?

Answer:

Task 3: Writea python program that uses a multi-way selection if-elif-else statement toprint the letter grade of a student according to his numeric mark and display it as per the table given below.

Condition

Printed output

Mark between 90 and 100

Grade A

Mark between 80 and 89

Grade B

Mark between 70 and 79

Grade C

Mark between 60 and 69

Grade D

Mark less than 60

Fail

Mark more than 100 or negative

INVALID MARK

Answer:

Task 4: Use nested if statements to implement the task below:

If i is less than 20 then perform the following:

  • If i is less than 15 then display i is smaller than 15
  • If i is less than 12 then display i is smaller than 12 too
  • Otherwise, display i is greater than 12

Answer:

print(i ,is smaller than 15)

can you please answer correctly

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!