Professional Documents
Culture Documents
END-TERM PROJECT WORK
END-TERM PROJECT WORK
PROJECT REPORT
ACTIVITY 1 (PROJECT)
Simulate the roll of a dice (between 1 and 6). Repeat the simulation for two users. The one
who gets the first 6 wins the game. Display all intermediate throw values for both users. Also,
provide the verdict of the winner.
To implement the rolling dice game in Python, We will be using the random module. The
random module provides us with different functions to generate numbers within a range or
select numbers with a range from a list. Since we want to randomize the numbers we get from
the dice, we will use the randint() function and the choice() function defined in the random
module to implement the game in Python.
To implement the rolling dice game in Python using the randint() function, we will initialize
two variables min_value and max_value to the lowest and highest number of dice i.e. 1 and 6
respectively. Then, we will use the randint() function to generate a random integer from 1 to
6. The randint() function takes the minimum value and maximum value of a range as its input
arguments and returns a random integer within the range. We will pass the
variables min_value and max_value to the randint() function to imitate dice rolling by
generating a random number from 1 to 6.
To implement the functionality to repeatedly roll the dice, we will use a while loop so that the
user can choose to roll the dice again. For this, we will ask the user if they want to roll the
dice again. We will assign the user input to a variable roll_again. If the user
inputs "yes" or "y", we will roll the dice by executing the while loop again. Otherwise, we
will come out of the while loop.
After implementing the above functionalities, you can implement the rolling dice game in
Python as shown below.
PROJECT ACTIVITY 2:
Circle Calculation: Write a program that takes the radius of a circle as input and uses the pi()
function to calculate and display the area and circumference of the circle.
1
MS BHAGYASHREE B.
Cambridge Facilitator
PROJECT ACTIVITY 3:
Rounding Grades: Create a program to input a student's test score, then use the ceil() and
floor() functions to round the score up or down to the nearest integer, and display the rounded
grade.
PROJECT ACTIVITY 4:
Tax Calculator: Build a tax calculator program that takes an individual's annual income as
input. Use the ceil() function to round the income up to the nearest thousand dollars and the
floor() function to round it down. Then, calculate the tax based on the rounded income and
display the result.
PROJECT ACTIVITY 5:
PROJECT ACTIVITY 6:
Price Adjustment: Create a program that allows a store manager to input the original price of
a product. Use the ceil() function to increase the price to the nearest dollar and the floor()
function to decrease it to the nearest dollar. Display both the rounded-up and rounded-down
prices.
2
MS BHAGYASHREE B.
Cambridge Facilitator
SOLUTIONS:
1. Rolling Dice:
import random
min_value=1
max_value=6
roll_again = "yes"
while roll_again == "yes" or roll_again == "y":
print("Rolling the dices...")
print("The values are....")
value1=random.randint(min_value, max_value)
value2=random.randint(min_value, max_value)
print(value1,value2)
roll_again = input("Press 'y' or 'yes' to roll the dices again.")
print("Have a good day.")
Expected Outcome:
The above code keeps rolling the dice until you give any other input than 'y' or 'yes'.
3
MS BHAGYASHREE B.
Cambridge Facilitator
2. Circle Calculation:
import math
Output:
Enter the radius of the circle: 5
Area of the circle: 78.54 square units
Circumference of the circle: 31.42 units
3. Rounding Grades:
import math
OUTPUT:
Enter the student's test score: 87.5
Rounded-up grade: 88
Rounded-down grade: 87
4. Tax Calculator:
import math
# Calculate tax based on rounded income (replace with your tax calculation formula)
tax = 0.2 * rounded_up_income # Example tax calculation, modify as needed
OUTPUT:
Enter the annual income: 55000
Rounded-up income: 56000
Rounded-down income: 55000
Tax to pay: 11200.00
5. Temperature Conversion:
import math
# Convert to Celsius
celsius = (fahrenheit - 32) * 5/9
OUTPUT:
Enter temperature in Fahrenheit: 68
Temperature in Celsius (Rounded Up): 20 °C
Temperature in Celsius (Rounded Down): 20 °C
6. Price Adjustment:
import math
OUTPUT:
Enter the original price: $24.99
Rounded-up price: $ 25
Rounded-down price: $ 24
6
MS BHAGYASHREE B.
Cambridge Facilitator