Reference no: EM133122702
CSE4IP Introduction to Programming - La Trobe University
Programming Assignment
Programming Tasks
Take your time to read and re-read the instructions before attempting to write your solution---you can save a lot of trouble by simply having a clear understanding of the problem before touching any code.
Task 1
For this task, you are to write code for the following numerical expression.
Instructions
Write a simple Python program which asks the user to input a value for x and z , and then prints the result of the following mathematical expression:
Requirements
You must keep the calculation as a single expression on a single line in your final solution.
You must not rearrange or simplify the expression in any way.
You should parentheses in code so that it is evaluated in the same way as the mathematical expression described above.
You must not use any conpcets not covred yet
Task 2
For this task, you are to write code that computes the value of acceleration of object, given the values of displacement, time, and initial velocity.
Instructions
Your program should ask for user inputs to get the values of displacement (how much distance the object has travelled), time, and the initial velocity of the object. It should then calculate the acceleration of the object and print this value out.
Requirements
To achieve full marks for this task, you must follow the instructions above when writing your solution. Additionally, your solution must adhere to the following requirements:
Appropriate data types must be used for all user inputs.
The output must be printed with the value between the description and the unit of measurement, as shown in the example runs.
Task 3
For this task, you are to write code that determines whether a person is eligible to participate in a clinical trial.
Instructions
Your program should ask the user for a few details:
The weight of the person (in kilograms)
The height of the person (in meters)
Whether the person is over 18 years of age.
Your program should then calculate the body mass index (BMI) of the person. Finally, your program should output whether the person is eligible to participate in the clinical trial. A flowchart has been provided which outlines the program flow. Use this in conjuction with the text description to code the solution.
Notice that the flowchart contains a decision element which checks whether the person is eligible. We will consider a person to be eligible for the trial if both of the following two conditions are met:
The person has a BMI value greater than or equal to 20.
The person is older than 18 years.
Your solution should make appropriate use of a single complex boolean expression encompassing both the above conditions. If done correctly you will only need one if/else structure in your solution (corresponding to the one decision element in the flowchart).
Hint: Think about how to combine multiple conditions using a logical operator.
Requirements
To achieve full marks for this task, you must follow the instructions above when writing your solution. Additionally, your solution must adhere to the following requirements:
Appropriate data types must be used for all user inputs.
The calculate_body_mass_index function must be used exactly once in your solution.
The MIN_BMI constant must be used in your solution.
The decision element in the flowchart must be implemented in a single complex boolean expression encompassing both eligibility conditions.
Task 4
For this task, you are to write a function and for-loops that outputs the shape like the one below. Allow the user to specify how high the shape should be.
Instructions
Your function should take one argument: the height of the shape and then print the shape based on the value of the height
Requirements
To achieve full marks for this task, you must follow the instructions above when writing your solution. Additionally, your solution must adhere to the following requirements:
You must implement the for-loops and print inside the function.
Appropriate data types must be used for all user inputs.
Your solution must not add any more lines of code outside the function implementation.
Task 5
For this task, you are to write code that calculates the maximum yearly income tax given by an individual within a period of multiple years.
Instructions
Your program should first ask the user to input a number of years. The program should then repeatedly ask the user to input a yearly tax amount until the specified number of years is reached. Finally, the program should output the maximum yearly income tax of the user based on the input values.
Hint: consider which form of aggregation might be appropriate for solving this problem.
If the user inputs zero for the number of years, the program should output a friendly message informing the user that maximum tax could not be calculated.
Requirements
To achieve full marks for this task, you must follow the instructions above when writing your solution. Additionally, your solution must adhere to the following requirements:
You must choose appropriate data types for user input.
Your solution must not crash if the user inputs zero for the number of years.
Your solution must be implemented using a for loop on a range.
You must indicate which year the input is for as part of your income tax prompt (see example runs).
Task 6
For this task, you are to write a function that takes two strings as inputs and then print how many matches there are between them. A match is where the two strings have the same character at the same index. For example, ‘Melbourne' and ‘Mildura' match in the first and third characters so the function should print 2. 'Python' and 'Path', match in the first, third, and fourth characters, the function should print 3.
Instructions
You program should first ask the user to input two different strings. If you entered the same strings, the program should ask the user to re-enter two different strings.
Requirements
To achieve full marks for this task, you must follow the instructions above when writing your solution.
Attachment:- Programming Assignment.rar