Академический Документы
Профессиональный Документы
Культура Документы
PYTHON TUTORIAL
SUBMITTED BY:
4621926
1
MATHAKONDAPALLI MODEL SCHOOL
BONAFIED CERTIFICATE
Of class XII in Mathakondapalli Model School, Hosur During the year 2018-2019
Roll No : 4621926
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
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
Last but not least, I would like to thank my classmates for their timely help and support for
3
INDEX
01. INTRODUCTION 05
06. PROGRAM 18
07. CONCLUSION 35
08. BIBLIOGRAPHY 36
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.
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.
Quiz is a software program that allows you to easily generate interactive on-screen quizzes
using a Microsoft Windows PC.
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.
6
PROJECT REQUIREMENTS
SOFTWARE’S
Python 2.7
Os name
Version
HARDWARE
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)
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.
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:
<statement-
1>…
…
<Statement-2>
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__.
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.
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:
1. BUILT IN FUNCTION:
12
2. USER DEFINED FUNCTION:
2. LOOP:
4.1 ) For loop: It is used to get values or character from the user number of times
13
USER MANUAL
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"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):
20
self.adress=raw_input("enter your adress :")
if self.age>15:
file=open('user.txt',"w+")
self.ss=file.readline()
print file
file.close()
def eligibility(self):
self.a=['50-100','60-100','70-100','80-100']
print self.a
if self.a[1]==self.b:
else:
21
print"you are wrong",'not selected'
def firstround(self):
self.c=0
self.d=['terabyte','octabyte','gigabyte','byte']
print self.d
self.c=0
if self.d[2]==self.e:
self.c+=5
else:
self.f=['rafflesia','hibiscus','lotus','lilly']
print self.f
if self.f[0]==self.g:
self.c+=5
22
print "you are right","your score is",self.c
else:
print self.h
if self.h[0]==self.i:
self.c+=5
else:
self.j=['3','78','91','81']
print self.j
if self.j[0]==self.k:
23
self.c+=5
else:
def secondround(self):
self.c1=0
print self.l
if self.l[3]==self.m:
self.c1+=5
else:
24
print "question number six"
print self.n
if self.n[3]==self.o:
self.c1+=5
else:
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
if self.p[1]==self.q:
self.c1+=5
else:
25
print "wrong answer"
self.r=['tamilnadu','punjab','gujarat','maharastra']
print self.r
if self.r[2]==self.s:
self.c1+=5
else:
def thirdround(self):
self.c2=0
print self.t
if self.t[1]==self.u:
26
self.c2+=5
else:
print"wrong answer"
self.v=['27','28','29','30']
print self.v
if self.v[2]==self.w:
self.c2+=5
else:
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
if self.w[1]==self.x:
self.c2+=5
27
print "you are right","your score is",self.c2
else:
self.y=['chlorine','bromine','flourine','iodine']
print self.y
if self.y[2]==self.z:
self.c2+=5
else:
def finalround(self):
self.c3=0
28
self.ae=['viscocity of ink','capillary action pheneomenon','diffusion of ink through
plotting','siphon action']
print self.ae
if self.ae[1]==self.io:
self.c3+=5
else:
print self.ni
if self.ni[2]==self.ya:
self.c3+=5
else:
29
print "question number fifteen"
print self.gh
if self.gh[3]==self.lo:
self.c3+=5
else:
print self.ij
if self.ij[1]==self.kl:
self.c3=+5
else:
30
print "question number seventeen"
print self.mn
if self.mn[2]==self.op:
self.c3+=5
else:
print self.qr
if self.qr[0]==self.st:
self.c3+=5
else:
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:
elif self.total<=30:
print "good"
elif self.total<=40:
elif self.total<=55:
32
print "excellent"
elif self.total<=70:
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
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