Вы находитесь на странице: 1из 37

MATHAKONDAPALLI MODEL SCHOOL

COMPUTER SCIENCE PROJECT

PYTHON TUTORIAL

SUBMITTED BY:

NAVEEN NARENDRA KUMARAN

4621926

1
MATHAKONDAPALLI MODEL SCHOOL

COMPUTER SCIENCE PROJECT


2018-2019

BONAFIED CERTIFICATE

Certified to be the Bonafied Project work done by

NAVEEN NARENDRA KUMARAN

Of class XII in Mathakondapalli Model School, Hosur During the year 2018-2019

Date: - Teacher in Charge:-

Submitted for AISSCE Practical Examination held on -----------------------------------

Project Title : PYTHON TUTORIAL

Name Of The Candidate: NAVEEN NARENDRA KUMARAN

Roll No : 4621926

Centre Code : 07085

External Examiner School seal Internal Examiner

2
ACKNOWLEDGEMENT

I register my sense of gratitude to Mathakondapalli Model School and our Principals for the

opportunity and facilities provided which helped me to complete this project successfully.

I am also thankful to our principal, our Co-coordinator for the help provided in referring the

required amount of resources.

It is my humble pleasure to acknowledge my deep sense of gratitude to my Computer Science

teacher Mr.Nagaraj C for his valuable support, constant help and guidance at each and every

stage of this project. His constructive advice & constant motivation have been responsible for the

successful completion of this project

Last but not least, I would like to thank my classmates for their timely help and support for

completion of this project

Name : NAVEEN NARENDRA KUMARAN

Roll No: 4621926

3
INDEX

S.NO CONTENT PAGE NO:

01. INTRODUCTION 05

02. PROJECT DESCRIPTION 06

03. PROJECT REQUIREMENT 08

04. PYTHON CONCEPTS 09

05. USER MANUAL 14

06. PROGRAM 18

07. CONCLUSION 35

08. BIBLIOGRAPHY 36

09. WEBSITES REFERED 37

4
INTRODUCTION

A quiz is a form of game or mind sport, in which the players (as individuals or in teams) attempt
to answer questions correctly. In some countries, a quiz is also a brief assessment used in
education and similar fields to measure growth in knowledge, abilities, and/or skills. Quizzes are
usually scored in points and many quizzes are designed to determine a winner from a group of
participants – usually the participant with the highest score.

The oxford English dictionary attests the use of the verb quiz to mean "to question or
interrogate", with a reference from 1843 "She com back a quiesed us", which could be a clue to
its origin.

Quiz as a test could be a corruption of the Latin quies, meaning "Who are you?" The American
English dictionary says it may be from the English dialect verb quiset, meaning "to question". In
any case it is probably from the same root as question and in quisitive.

There is a well-known myth about the word quiz that says that in 1791 a Dublin theater owner
named James Daly made a bet that he could introduce a word into the language within twenty-
four hours.

He then went out and hired a group of street urchins to write the word "quiz", which was a
nonsense word, on walls around the city of Dublin. Within a day, the word was common
currency and had acquired a meaning (since no one knew what it meant, everyone thought it was
some sort of test) and Daly had some extra cash in his pocket. However, there is no evidence to
support the story, and the term was already in use before the alleged bet in 1791.

General knowledge has been defined in differential psychology as "culturally valued knowledge
communicated by a range of non-specialist media" and encompassing a wide subject range. This
definition excludes highly specialized learning that can only be obtained with extensive training
and information confined to a single medium.

General knowledge is an important component of crystallized intelligence and is strongly


associated with general intelligence, and with openness to experience.

5
PROJECT DESCRIPTION

The project is based a software for conducting quiz for the age group of 16 and above based on
the high school learning.

SOFTWARE FOR CONDUCTING QUIZ

Quiz is a software program that allows you to easily generate interactive on-screen quizzes
using a Microsoft Windows PC.

Software testing is an investigation conducted to provide stakeholders with information about


the quality of the product or service under test. Software testing can also provide an objective,
independent view of the software to allow the business to appreciate and understand the risks of
software implementation.

Test techniques include the process of executing a program or application with the intent of
finding software bugs (errors or other defects), and to verify that the software product is fit for
use.

Software testing involves the execution of a software component or system component to


evaluate one or more properties of interest. In general, these properties indicate the extent to
which the component or system under test:

 meets the requirements that guided its design and development,


 responds correctly to all kinds of inputs,
 performs its functions within an acceptable time,
 is sufficiently usable,
 can be installed and run in its intended environments, and

 Achieves the general result its stakeholder’s desire.

6
PROJECT REQUIREMENTS

SOFTWARE’S

Python 2.7
Os name
Version

HARDWARE

System Model HP 202 G1 MT


System Typex64-based PC
Processor Intel(R) Pentium(R) CPU G2030 @ 3.00GHz, 3000 MHz, 2 Core(s), 2
Logical Processor(s)
SMBIOS Version 2.7
Installed Physical Memory (RAM) 2.00 GB
Total Physical Memory 1.89 GB
Available Physical Memory 1.21 GB
Total Virtual Memory 3.78 GB
Available Virtual Memory 2.83 GB

7
PYHTON CONCEPS USED IN PROJECT

1. NUMBER: Number data type stores Numerical Values. This data type is immutable
value of its object cannot be changed. Numbers are of three different types

1.1 Integer & Long (to store whole numbers i.e. decimal digits without fraction part)

1.2 Float/floating point (to store numbers with fraction part)

1.3 Complex (to store real and imaginary part)

2. SEQUENCE: A sequence is an ordered collection of items, indexed by positive integers. It


is a combination of mutable (a mutable variable is one, whose value may change) and immutable
(an immutable variable is one, whose value may not change) data types. There are three types of
sequence data type available in Python; they are Strings, Lists & Tuples.

3. STRING: Is an ordered sequence of letters/characters. They are enclosed in single quotes ('
') or double quotes ('' "). The quotes are not part of string. They only tell the computer about
where the string constant begins and end, they can have any character or sign, including space in
these are immutable. A string with length 1 represents a character in
python.

4. LISTS: List is also a sequence of values of any type. Values in the list are
called elements / items.

These are mutable and indexed/ordered. List is enclosed in square


brackets ([ ]).

3. DICTIONARIES: It can store any number of python objects. What they store is a key -
value pairs, which are accessed using key. Dictionaries enclosed in curly brackets ({}).

8
DEFINING CLASSES:

We have already studied in the previous chapter that a class is a unit that encapsulates data and
its associated functions. In this section we will learn how to define classes.

To define a class in Python, we need to just define the class and start coding. A Python class
starts with the reserved word 'class', followed by the class name and a colon(:). The simplest
form of class definition looks like this:

Class <Class Name>:

<statement-
1>…

<Statement-2>

Class used in project ():


1. Main()
2. Divide()

CONSTRUCTORS IN PYTHON (USING __init__)

A constructor is a special method that is used to initialize the data members of a class. In python,
the built in method __init__ is a sort of constructor. Notice the double underscores both in the
beginning and end of init. In fact it is the first method defined for the class and is the first piece
of code executed in a newly created instance of the class.

But still it should also be remembered that the object has already been constructed by the time
__init__ is called, and you already have a valid reference to the new instance of the class through
the first argument, self of the __init__ method.

9
E.g.
Class Initialize:
'"An example of __init__"'
int var
def __init__(self, var=10): #double underscore before and after init
Initialize.var=var
def display():
Print var

__init__ method can take any number of arguments, and just like functions, the arguments can be
defined with default values, making them optional to the caller. Initial values for attributes can
be passed as arguments and associated to attributes.

A good practice is to assign them default values, even none. In this case, var has a default value
of 10. After the class definition, object. __init__ (self [...]) is called when the instance is created.
The arguments are those passed to the class constructor expression. This means the statements
given below will give the output ;

P = Initialize (20)
P. display ()

Also note that if no argument was passed while creating the object, then the __init__ would have
taken the default value of var and the output would have been 10.

In Python, the first argument of every class method, including __init__, is always a reference to
the current instance of the class and by convention; this argument is always named 'self'. In case
of __init__, self refers to the newly created object or the instance whose method was called. Note
that the __init__ method never returns a value.

10
IMPORTANCE OF SELF:

Class methods have only one specific difference from ordinary functions - they must have an
extra argument in the beginning of the parameter list. This particular argument is self which is
used for referring to the instance.
But you need not give any value for this parameter when you call the method. Python provides it
automatically. self is not a reserved word in Python but just a strong naming convention and it is
always convenient to use conventional names as it makes the program more readable. So while
defining your class methods, you must explicitly list self as the first argument for each method,
including __init__.

CLASS INSTANCES (OBJECTS):

Having a class defined, you can create as many objects as required. These objects are called
instances of this class. In fact after the class definition is made, a class instance is created
automatically once the definition is left normally i.e. the indentation of statements is removed
and the class object is called. All the instances created with a given class will have the same
structure and behavior. They will only differ regarding their state, i.e. regarding the value of their
attributes.

Classes and instances have their own namespaces, that is accessible with the dot ('.') operator.
These namespaces are implemented by dictionaries, one for each instance, and one for the class.
A class object is bound to the class name given in the class definition header. A class object can
be used in two ways - by Instantiation and attribute references.

1. INSTANTIATION: CREATING INSTANCE OBJECTS

To create instances of a class, you call the class using class name and pass in whatever
arguments its __init__ method accepts.
Test = T (1,100)

11
OPERATORS AND OPERANDS:
Operators are special symbols that represent computation like addition and multiplication. The
values
that the operator is applied to are called operands. Operators when applied on operands form an
expression. Operators are categorized as Arithmetic, Relational, Logical and Assignment.
Following is the partial list of operators:

Mathematical/Arithmetic operators: +
Relational operators: <, <=, >, >= and ==.
Assignment Operator: =, +=

2. FUNCTION IN PYTHON:

A function is named sequence of statement(s) that performs a computation. It contains line of


code(s) that are executed sequentially from top to bottom by Python interpreter.
They are the most important building block for any software in Python. For working in script
mode, we need to write the Python code in functions and save it in the file having extension.
Functions can be categorized as belonging to

1. BUILT IN FUNCTION:

1.len (): It is used for length of list.

2.Count (): It is used to increase the values.

3.def (): It is used for defining the function

4.input (): It is used to get values.

5.raw_input (): It is used to get string.

6.redline (): It is used to read the text from the file.

7. sum(): It is used to sum up the values.

12
2. USER DEFINED FUNCTION:

Quiz ( ): It is used to define a class

1. getinput( ): It is used to get input from the user


2. eligibility( ): It is used to check the eligibility of the user
3. firstround( ): It is used to start the first round
4. secondround( ): I t is used to start the second round
5. thirdround ( ): I t is used to start the third round
6. lastround ( ): It is used to start the last round
7. calculate ( ): It is used to sum all the rounds
8. display ( ): It is used to display the answers of all the questions
9. result ( ) : I t is used to display the result of answered questions

2. LOOP:

The loop which I am using in my project is.

4.1 ) For loop: It is used to get values or character from the user number of times

13
USER MANUAL

1. When the user runs the program it displays

2. Checking for the eligibility with a question and options given

14
3. The user needs to answer the questions

15
4. If the answer is correct then the score is increased

16
5. At the end of each round the score is displayed then the next round starts

17
PROGRAM

print"WELCOME TO THE QUIZ COMPETATION"

print"HERE THEIR ARE THREE ROUNDS"

print"EACH QUESTION CONSIST OF FIVE MARKS AND LAST QUESTION CONSIST OF


TEN MARKS"

print"OPTIONS ARE GIVEN"

print"PLEASE TYPE THE CORRECT SPELLINGS AS GIVEN"

print"LETS ROCK"

class quiz(object):

def __init__(self,name,age,adress):

self.name=name

self.age=age

self.adress=adress

self.a=" "

self.b=" "

self.c=" "

self.d=" "

self.e=" "

self.f=" "

self.g=" "

18
self.h=" "

self.i=" "

self.j=" "

self.k=" "

self.l=" "

self.m=" "

self.n=" "

self.o=" "

self.p=" "

self.q=" "

self.r=" "

self.s=" "

self.t=" "

self.u=" "

self.v=" "

self.w=" "

self.x=" "

self.y=" "

self.z=" "

self.aa=" "

self.bb=" "

19
self.cc=00

self.ss=" "

self.ae=" "

self.io=" "

self.ya=" "

self.ni=" "

self.gh=" "

self.lo=" "

self.ij=" "

self.kl=" "

self.mn=" "

self.op=" "

self.qr=" "

self.st=" "

self.c1=02

self.c2=03

self.c3=04

self.total=05

def getinput(self):

self.name=raw_input("enter your name :")

self.age=int(raw_input("enter your age :"))

20
self.adress=raw_input("enter your adress :")

if self.age>15:

print "you age is eligible to play the game"

file=open('user.txt',"w+")

self.aa=raw_input("enter your name :")

self.bb=input("enter your age :")

self.cc=raw_input("enter your adress :")

self.ss=file.readline()

print file

file.close()

print "your details are verified"

def eligibility(self):

print "eligible question to play the game"

print"what is the normal heart beat per minute?"

self.a=['50-100','60-100','70-100','80-100']

print self.a

print"hint= one minute "

self.b=raw_input("enter your answer")

if self.a[1]==self.b:

print "you are right",'selected'

else:

21
print"you are wrong",'not selected'

def firstround(self):

self.c=0

print "what is gb in computer science?"

self.d=['terabyte','octabyte','gigabyte','byte']

print self.d

self.e=raw_input("enter your answer")

self.c=0

if self.d[2]==self.e:

self.c+=5

print "you are right","your score is",self.c

else:

print "wrong answer"

print "qustion number two"

print "which is the largest flower in the world?"

self.f=['rafflesia','hibiscus','lotus','lilly']

print self.f

self.g=raw_input("enter your answer")

if self.f[0]==self.g:

self.c+=5

22
print "you are right","your score is",self.c

else:

print "wrong answer"

print "question number three"

print "who invented telephone?"

self.h=['alexander graham bell','edison','einsten','newton']

print self.h

self.i=raw_input("enter your answer")

if self.h[0]==self.i:

self.c+=5

print "you are right","your score is",self.c

else:

print "wrong answer"

print "question number four"

print " what is the square root of nine?"

self.j=['3','78','91','81']

print self.j

self.k=raw_input("enter your answer")

if self.j[0]==self.k:

23
self.c+=5

print "you are right","your score is",self.c

else:

print "wrong answer"

def secondround(self):

self.c1=0

print "second round starts"

print "question number five"

print "ordinary table salt is sodium chloride,what is baking soda?"

self.l=['potassium chloride','potassium hydroxide','potassium carbonate','sodium


bicarbonate']

print self.l

self.m=raw_input("enter your answer")

if self.l[3]==self.m:

self.c1+=5

print "you are right","your score is",self.c1

else:

print "wrong answer"

24
print "question number six"

print "ozone hole refers too?"

self.n=['hole ozone layer','decrease ozone layer','decrease thickness','depletion ozone


molecules']

print self.n

self.o=raw_input("enter your answer")

if self.n[3]==self.o:

self.c1+=5

print "you are right","your score is",self.c1

else:

print "wrong answer"

print "question number seven"

print " what is the ratio of width of our national flag is?"

self.p=['1:2','2:3','3:1','1:4']

print self.p

self.q=raw_input("enter your answer")

if self.p[1]==self.q:

self.c1+=5

print "you are right","your score is",self.c1

else:

25
print "wrong answer"

print "question number eight"

print "dandia is a popular dance of which state?"

self.r=['tamilnadu','punjab','gujarat','maharastra']

print self.r

self.s=raw_input("enter the answer")

if self.r[2]==self.s:

self.c1+=5

print "you are right","your score is",self.c1

else:

print "wrong answer"

def thirdround(self):

self.c2=0

print "third round starts"

print "question number nine"

print "which is the higest grossing indian movie 2009"

self.t=['bahubali-the beginning','3-idiots','happy new year','kick']

print self.t

self.u=raw_input("enter your answer")

if self.t[1]==self.u:

26
self.c2+=5

print "you are right","your score is",self.c2

else:

print"wrong answer"

print "question number ten"

print "how many states does india have?"

self.v=['27','28','29','30']

print self.v

self.w=raw_input("enter your answer")

if self.v[2]==self.w:

self.c2+=5

print "you are right","your score is ",self.c2

else:

print "wrong answer"

print "question number eleven"

print "the number of moles of solute present in 1kg of solvent is called its?"

self.w=['molarity','molality','normality','none of these']

print self.w

self.x=raw_input("enter your answer")

if self.w[1]==self.x:

self.c2+=5

27
print "you are right","your score is",self.c2

else:

print "wrong answer","better luck next time"

print "the question number twelve"

print "the most electronegative element is?"

self.y=['chlorine','bromine','flourine','iodine']

print self.y

self.z=raw_input("enter your answer")

if self.y[2]==self.z:

self.c2+=5

print "you are right","your score is",self.c2

else:

print "wrong answer","sorry"

print "your total score is",c2

def finalround(self):

self.c3=0

print "final round starts"

print "question number thirteen"

print "the absorption of ink by blotting paper involes?"

28
self.ae=['viscocity of ink','capillary action pheneomenon','diffusion of ink through
plotting','siphon action']

print self.ae

self.io=raw_input("enter your answer")

if self.ae[1]==self.io:

self.c3+=5

print"correct answer","your score is",self.c3

else:

print "wrong answer"

print "question number fourteen"

print "expand dbms?"

self.ni=['data base managing system','data base manager system','data base managment


system','data base management system']

print self.ni

self.ya=raw_input("enter your answer")

if self.ni[2]==self.ya:

self.c3+=5

print "correct answer","your score is ",self.c3

else:

print "wrong answer"

29
print "question number fifteen"

print "what is internet?"

self.gh=['network','network connected to network','many networks','network of networks']

print self.gh

self.lo=raw_input("enter your answer")

if self.gh[3]==self.lo:

self.c3+=5

print "correct answer","your score is",self.c3

else:

print "wrong answer"

print "question number sixteen"

print "what is full form of mp?"

self.ij=['member of legislature','member of parliment','member of participation','member of


meating']

print self.ij

self.kl=raw_input("enter your answer")

if self.ij[1]==self.kl:

print"correct answer","your score is",self.c3

self.c3=+5

else:

print "wrong answer"

30
print "question number seventeen"

print "what is full form of ROM?"

self.mn=['random OS memory','read or memory','read only memory','read and operate


memory']

print self.mn

self.op=raw_input("enter your answer")

if self.mn[2]==self.op:

self.c3+=5

print "correct answer","your score is",self.c3

else:

print "wrong answer"

print "question number eighteen"

print "what is the full form of PCR?"

self.qr=['polymerase chain reaction','polymer chain reaction','polymers cell


reaction','polymerase cell reaction']

print self.qr

self.st=raw_input("enter your answer")

if self.qr[0]==self.st:

self.c3+=5

print "correct answer","your score is",self.c3

else:

print "wrong answer"

31
def calculate(self):

self.total=self.c+self.c1+self.c2+self.c3

def display(self):

print self.aa,self.bb,self.cc,self.ss,self.a,self.b,self.d,self.e,self.f,self.g,self.h,self.i,self.j,self.k

print self.l,self.m,self.n,self.o,self.p,self.q,self.r,self.s

print self.t,self.u,self.v,self.w,self.x,self.y,self.z,self.c

print self.ae,self.io,self.ni,self.ya,self.gh,self.lo,self.ij,self.kl,self.mn,self.op,self.qr,self.st

print self.c,self.c1,self.c2,self.c3

print self.total

def result(self):

if self.total<=20:

print "better luck next time"

elif self.total<=30:

print "good"

elif self.total<=40:

print "very good"

elif self.total<=55:

32
print "excellent"

elif self.total<=70:

print "out standing"

ab=quiz('anupama',16,'achubalam village')

ab.getinput()

ab.eligibility()

ab.firstround()

ab.secondround()

ab.thirdround()

ab.finalround()

ab.calculate()

ab.display()

ab.result()

33
OUTPUT

34
CONCLUSION

This project “quiz” was done for using it in our school for helping to know more about
programming language. In the process of completing this project I was able to learn many new
concepts in python programming language and I also gained knowledge and experience on how a
program works practically and what type of errors arises and how to clear the errors.
Learning python and doing program first time was not a simple thing for me. But I sincerely
thank MR.JERALD who helped me through the project and clarified the doubt asked.

THANK YOU.

35
BIBILIOGRAPHY

1. Book: Computer Science for Class XII Comprehensive CBSE Computer Science with
python
PUBLISHE: The Secretary, Central Board of Secondary Education
Shiksha Kendra, 2, Community Centre,
Preet Vihar, Delhi-110092

2. Book: Computer science python book class XII.


AUTHOR: Sumita Arora
Publisher: DHANPAT RAI & CO.(pvt.) Ltd.

3. Book: Class XI computer science textbook.


Author: Shri Vineet Joshi
Publisher: The Secretary, Central Board of Secondary Education
Shiksha Kendra, 2, Community Centre,
Preet Vihar, Delhi-110092.

4. Book : Python Programming for ClassXI and XII


Author: Ravish Bapna.

5. Book: Practical workbook for CBSE computer science class XII


Author: Pavithra Karthik.
Publisher: LAXMI PUBLICATION (p) LTD.

36
WEBSITES REFERED

 http://forum.codecall.net

 http://www.tutorialspoint.com/python/python_gui_programming.htm

 https://inventwithpython.com/chapter10.html

 https://docs.python.org/3/howto/sorting.html

 https://www.leaseweb.com/labs/2013/12/python-tictactoe-tk-minimax-ai/

 http://effbot.org/tkinterbook/tkinter-index.htm

 http://www.python-course.eu/tkinter_mastermind.php

37

Вам также может понравиться