Lab Data
Lab Data
_________________________________________________________________________________
You may submit files as many times as you like. The most recent submission overwrites all previous
submissions.
____________________________________________________________________________________
Note: For each part you need to create a different cell and use the proper comments (such as Question 1, part
a). Your comments must be clear and indicate the question number, part and the functions or methods you
may use if it’s needed.
1|Page
EECS 1015 Introduction to Computer Science And Programming
Lab questions:
This question is to compute the membership price for a person based on the type of purchase (one time entry or
multiple entry) and their age group (Kid, Youth, and Senior).
1. Your program should first ask the person which type of purchase they want: (1) one time entry or (2)
multiple entry.
2. Your program should then ask the person to select the correct again group: (1) Kid; (2) Youth; or (3)
Senior.
3. You then should compute the fare as follows:
4. After the input, print out the computed fare in the following format:
2|Page
EECS 1015 Introduction to Computer Science And Programming
(2) Youth
(3) Senior
Enter 1, 2, or 3: 2
Total amount due: $25.50 [one time entry (full fee)]
The goal is to find the maximum odd number from a sequence of positive numbers entered by the user.
Stop prompting the user for numbers after they enter a negative number.
Hint: How do you know if a number is odd? Any number modulus two that results in a 1 is an odd
number.
3. When the user enters a negative number, stop and print out the largest odd number entered.
4. If the user does not enter an odd number, output 0 as the output and print “No odd number was
provided”.
3|Page
EECS 1015 Introduction to Computer Science And Programming
Enter a number : 11
Enter a number : 103
Enter a number : 99
Enter a number : 88
Enter a number : -1
Largest odd number: 103
4|Page
EECS 1015 Introduction to Computer Science And Programming
Draw a triangle based on a number between 5-20 that the user provides.
1. Ask the user to input a number between 5 and 20
If the number they input is not between 5 and 20, ask again until it is.
5|Page
EECS 1015 Introduction to Computer Science And Programming
QUESTION 4 (30marks)
This task is to help you with while-loops, for-loops, and summing values.
Rolling dice is a random process – the values for each dice can be 1 to 6. However, the expected value of the
sum of two dice is 7. This can be observed by rolling two dice many times and computing the average of the
results. As the number of dice rolls approaches "infinity," the average will converge to the "expected value."
1. Ask the user to enter the number of times they would like to roll the two dice (let's call this N).
2. Loop N times – at each loop, select two random numbers between 1-6 to simulate dice rolls.
3. Print out the two dice values, their sum, and the current roll iteration (starting from 1).
4. When the loop completes, print the average value (with precision 2) of all the dice (i.e., add up all the
5. Ask the user if they'd like to do this again. If they input 'Y' or 'y', go back to step 1.
6|Page
EECS 1015 Introduction to Computer Science And Programming
7|Page