You are on page 1of 11

lOMoARcPSD|31793068

Python mc removed

Computer Engineering (शासकीय तंत्रनिकेतन अंबड)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by uday thete (uthete16@gmail.com)
lOMoARcPSD|31793068

GOVERNMENT POLYTECHNIC, AMBAD 1162


COMPUTER ENGINEERING DEPARTMENT

A MICRO-PROJECT REPORT ON

“MATH GAME”
For The Award Of
DIPLOMA IN COMPUTER ENGINEERING & TECHNOLOGY
(COMPUTER ENGINEERING)

2022-23
UNDER THE GUIDANCE OF

Prof.A.V.WANKAR

SUBMITTED BY

SR NAME ENROLLMENT NO

01 HARSHA MOHAN DASPUTE 2011620398


02 ADIL ATTURAHEMAN SHAIKH 2011620121
03 KISHOR INDARRAO SOJE 2011620403

Downloaded by uday thete (uthete16@gmail.com)


lOMoARcPSD|31793068

CERTIFICATE
GOVERNMENT POLYTECHNIC, AMBAD.1162

DEPARTMENT OF COMPUTER ENGINEERING


MICRO PROJECT ON
MATH GAME

This is to certify that the Micro-project entitled “Math Game being submitted
herewith for the award of
DIPLOMA IN ENGINEERING & TECHNOLOGY in COMPUTER
ENGINEERING of MAHARASHTRA STATE BOARD &TECHNICAL
EDUCATION (MSBTE), Mumbai is the result of Micro-project work completed
under my supervision and guidance by Prof.A.V.Wankar

Mr.

To the best of my knowledge and belief, the work embodied in this Microproject
has not formed earlier the basis for the award of any diploma of this or any other Board
or examining body.

Place: Ambad Prof.A.V.WANKAR

Date : (Micro-Project Guide)

Downloaded by uday thete (uthete16@gmail.com)


lOMoARcPSD|31793068

DECLARATION
We, the undesired, hereby declare that the project entitled “Math
Game” Is written and submitted by us to GovernmentPolytechnic
Ambad during Year 2022-23, Six Semester for partial
fulfillment of the ‘Micro Project’ requirement of "Programming With
Python" subject under Maharashtra State Board of Technical
Education, Mumbai curriculum, under the guidance of Prof.A.V.WANKAR. is
our original work.
The empirical findings in this project are based on the data collected in this
project is collected from various sources.

Roll NO Name of student Signature

349 HARSHA MOHAN DASPUTE

337 ADIL ATTURAHEMAN SHAIKH

353 KISHOR INDARRAO SOJE

Downloaded by uday thete (uthete16@gmail.com)


lOMoARcPSD|31793068

ACKNOWLEDGEMENT

I have great pleasure to express my immense gratitude towards a dynamic person and
my project guide Prof.A.V.WANKAR

Department of “COMPUTER ENGINEERING “Government Polytechnic, Ambad


for giving me an opportunity to work on an interesting topic over six semester. The
work presented here could not have been accomplished without his most competent
and inspiring guidance, incessant encouragement, constructive criticism and constant
motivation during all phases of our group Micro-project work. I am greatly indebted to
him.

I am very much thankful to, Prof. A.V.WANKAR Head, Department of


COMPUTER ENGINEERING all HODs of various departments and Prof. Dr. A.M.
AAGARKAR, Principal, Government Polytechnic, Ambad, for his encouragement
and providing me a motivating environment and project facilities in the Institute to
carryout experiments and complete this Micro-project work.
I would like to extend our thanks to all our professors, staff members and all our
friends who extended their co-operation to complete the project.

I am indeed indebted to my parents and other family members for their immense
help at all levels with moral, social & financial support, care and support throughout
my studies without which my work would not have seen light of the day.

With warm regards,

Place: Ambad Yours Sincerely,

Date:---/---/--- Mr./Miss.----------

Downloaded by uday thete (uthete16@gmail.com)


lOMoARcPSD|31793068

Index

Sr.no Contents Page no

01 Introduction

02 Module Needed

03 Function Need

04 Code

05 Output

Downloaded by uday thete (uthete16@gmail.com)


lOMoARcPSD|31793068

❖ CREATE A RANDOM MATH GAME USING PYTHON

• This code is a simple math game that generates random math problems and asks
the user to solve them. The game keeps track of the user's score and ends when
the user decides to stop playing.

❖ MODULE NEEDED

• There are two modules used in this python code random and operator.

• Random Module : random module is used to generate random numbers and


operators for random module.

• Operator Module : operator module is used to perform actual math operations.

Downloaded by uday thete (uthete16@gmail.com)


lOMoARcPSD|31793068

❖ FUNCTION NEEDED

The random_problem() : function generates two random numbers between 1 and 10,
selects a random math operator from a dictionary of operators, performs the math
operation using the operator module, and returns the answer.

The ask_question() : function calls random_problem() to generate a math problem,


asks the user to solve it, and returns a boolean indicating whether the user's guess was
correct or not.

The game() : function initializes the user's score to 0 and enters a loop that continues
until the user decides to stop playing.

In each iteration of the loop, it calls ask_question() to ask the user a math problem and
updates the user's score if the user's guess was correct. If the user's guess was incorrect,
the loop breaks and the game ends. Finally, the user's score is displayed.

❖ PROGRAM

import random
import operator

def random_problem():

operators = {
'+': operator.add,
'-': operator.sub,
'*': operator.mul,
'/': operator.truediv,
}

num_1 = random.randint(1, 10)


num_2 = random.randint(1, 10)
operation = random.choice(list(operators.keys()))
answer = operators.get(operation)(num_1, num_2)
print(f'What is {num_1} {operation} {num_2}')
return answer

Downloaded by uday thete (uthete16@gmail.com)


lOMoARcPSD|31793068

def ask_question():

answer = random_problem()
guess = float(input('Enter you answer: '))
return guess == answer

def game():

score = 0
while True:
if ask_question() == True:
score += 1
print('Correct !')
else:
print('Incorrect')
break
print(f'======== Game Over ========\nYou score is {score}\nKepp going!')

game()

Downloaded by uday thete (uthete16@gmail.com)


lOMoARcPSD|31793068

❖ OUTPUT

Downloaded by uday thete (uthete16@gmail.com)


lOMoARcPSD|31793068

❖ CONCLUSION :

The random_problem() function can generate division by zero errors if the randomly
generated operator is / and the second number is 0.

The ask_question() function assumes that the user will enter a float as their guess, but
it does not handle cases where the user enters a non-numeric value.

The game() function does not handle cases where the user enters a non-numeric value
as their guess.

Downloaded by uday thete (uthete16@gmail.com)

You might also like