Worksheet 1
Worksheet 1
1 Write a program that allows a user to input their first name, their last name and
age. Store the results into variables.
Outputs the message "Well done! You have passed both tests" if both test scores
are 60 or greater.
Outputs the message You need to try again with the Physics test." if the Physics
test score is less than 75, but the Biology test score is 75 or greater
Outputs the message "You need to try again with the Biology test." if the Biology
test score is less than 75, but the Physics test score is 75 or greater
Outputs the message "You need to try again with both tests" if both test scores
are less than 75
You must use a nested IF statement and Boolean operator in your program.
11 Create an iterative statement that prints the following:
1a
1b
1c
1d
2a
2b
2c
2d
3a
3b
3c
3d
Hint: You will need to use a nested loop. You will also need to use an array.
12 Write a function that tells user whether a function has two solutions, one
solution or no solution – discriminant problem in Maths:
- Takes a parameter a
- Takes a parameter b
- Takes a parameter c
Note: If the discriminant is > 0, then the function has two solutions, If
discriminant = 0, then the function has one solution. If discriminant < 0, then the
function has one solution.
13 Modify your program in Q12 to make the determinant function returns the
determinant. Your function should return the determinant value and it should be
stored into another variable d.
14 Initialise a list that has value from 1 to 10. Initialise another array with 10 “0”.
Using the first list you created, populate the second list like this:
Represent the following data in Python using a list of lists. Write a program that
finds out the top score for each subject and the student with highest average
marks.