Highlights
Task:
Q1. Write up a python program that implements the following algorithm. [10 marks]
Input: Two numbers X and Y representing number to multiply together
Output: an integer holding the result of X * Y
1. Sum ? 0
2. while Y > 0 do
3. Sum ? Sum + X
4. Y ? Y – 1
5. return Sum
Q2. Write a program that when given as input from the user a number x and value n will find the nth root of x. To make this task easier you will be required to import python’s math library, see https://docs.python.org/3/library/math.html
[10 marks]
Example:
Please enter a number: 390625
Please enter a value for n: 8
The 8th root of 390625 is 4.999999999999999
Q3. Write a program that takes as input a string representing a user's name. Your program should output the length of the name and the number of times each vowel occurs in it. [10 marks]
Q4
a) Write a program that simulates an unbiased coin flip. Your program should print true if the coin flip results in a head and false if the coin flip results in a tail. The library we will be importing is the random library allowing the programmer to access tools to generate pseudo-random number and perform operations that use these tools. See https://docs.python.org/3.5/library/random.html [5 marks]
b) Now consider a biased coin. Write a program that takes a value p, with range between 0 and 1, as input from the user and tests a number of coin flips where p is the probability of the flip resulting in a result of heads.
[5 marks]
Example:
What kind of bias do your coins have? 0.5
Coin flip 1 has a value of heads: True
Coin flip 2 has a value of heads: False
Coin flip 3 has a value of heads: True
c) Write a program that takes a number n as input from the user and simulates n coin flips printing the results each time. [10 marks]
Example:
How times would you like to flip the coin? 5
The coin came up heads.
The coin came up tails.
The coin came up tails.
The coin came up heads.
The coin came up heads.
d) Modify the program from task (c) to store the number of heads and tails in variables. Once you have generated the variables, print the total number of heads and the total number of tails. Calculate the ratio of heads to the total coin flips. Is this ratio what you would expect, what happens to this ratio as you change the probability of the coin coming up heads? What happens as the number of coins being flipped becomes large? [15 marks]
e) Using the documentation from the random library, use random.randrange(a) to extend your progra so that it uses 3 sided coins. [15 marks]
Example:
Please input the number of coin flips: 10
Side3
tails
tails
heads
heads
tails
tails
Side3
heads
Side3
Side1 total 3, Side2 total 4, and Side3 total 3 The ratio heads / total tries is: 0.3
Q5
a) Write a function, named adjust, that takes a number of cents between 0 and 9, inclusive, rounds it off to the nearest 5 cents by the following rules, and returns the result: [10 marks]
o 1 and 2 cents are rounded off to 0
o 3, 4, 6 and 7 cents are rounded off to 5 8 and 9 cents are rounded off to 10 cents
b) Write a function, named roundOff, which takes an amount of money in dollars, and rounds it off to the nearest 5 cents and returns the result. The amount is entered as a decimal number with 0, 1 or 2 decimal places. The rounding off is based on the rules given above.
This CSE1PE: IT Assignment has been solved by our IT Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.