Python Imp
Python Imp
- | P
Programs:
understood
The
entirely by meaning
of a
analysis of thecomputer
program is unambiguous and literal.
tokens and structure,
(Semai
and can h
First, remember that
languages, formal languages are much more condensed
not a good ideato longer to read them. Also, the structure is veryimportant, sothanit is natura
so it takes
read
from top to bottom, left to right. Instead, learn to parse the
your head,
identifying usualyn
Small errors in spellingtheandtokens and interpreting the structure. Finally, the details progranmatter
in apunctuation,
can make a big which you can get away with in natural
difference
1.9 THE
DIFFERENCE BETWEEN
formal language.
BRACKETS, PARENTHESES AND BRACES
languags
Brackets ]:
define mutable Generally
data typesbrackets
are used to index into an array. It also
okup/slicing.() : such as lists, list comprehensions and for indexiusedng to
loParenthesis
Parenthesesand areto used for two purposes: to control the of
Operationsit in an expression,
Python is used to define supply parameters to a order
function calls and other syntax. tuples, order of constructor or method. In
operations, generator expressions,
Braces {}:The braces
generally are used to group
contents of class or interface are enclosed in
statements in if statement, a loop, statements and declarations. The
braces. Braces are used
used to specify the scope of or other control to
used to create logical structures. It means group the
block of
statements. In python the braces are
dictionaries or sets. braces are also
. Write short note on QUESTIONS
2. Python and
Write a note on Python and its ways to use Python
k3 Explain compiler and history. interpreter.
Give features of interpreter.
5. Python,
Explain debugging and error types in
6.
Write short note on formal and Python.
Give the difference natural languages.
between Brackets, Parentheses and
Braces.
hothing but selt-describing text that helps programmer to
information about code block. With you can remind yourself what a
Condit
2.
The three double quotes( ) - If you need to comment out a longer multiline
text,y
can use three double quotes. Python will treat alltext inside the three quotes as a comment
Ex.
OUTPUT
0
1
3
22
27
QUESTIONS
1. Write a short program to demonstrate type
conversion in Python.
2. Explain any 5 math functions in Python in detail.
3. How todefine and access the
function in Python?
4. Write a
short program todemonstrate the use of
(5.) What is import? Explain ways of importing in parameterized function in Python.
6. Explain the difference between Python.
import module and form module.
( Write a short program to
8. Write
demonstrate use of function returning value.
short note on incremental development.
(9 Write ashort program to
demonstrate use of function recursion.
quotation markS.
lowercase (r) or uppercase (R) and
must be placed immediately preceding
thefirst quote mark.
Ex.:
#Pr.5.10Program to string concatenation (string addition)
s='RSADT"
t='AM"
for iin s:
print(i+t)
OUTPUT
RAM
SAM
AAM
DAM
TAM
Ex.
#Pr.5.11 Program to string
stl ="madam" palindrome
st2 =st1[:-1]
if st1==st2:
print("String is palindrome")
else:
1.
Demonstrate use of string QUESTIONS
The
strings in Python are operations with the help of s
3 Explain any five built in immutable. Justify. suitable
functions that are used with strings. program.
4.
Explain the string operations with help of different
5,, Explain the use of in and not
operator using operators.
strings with help of:
small suitable
program.
Athon Prgnamming(SYRS
OUTPUT
Sorted tist (in Desc): u, o',. 'e', 'a]
st.count(27): 1
len(st): S
min(st): 8
max(st) : 27
st.insert(2,-1): (13, 22,-1, 8, 27, 11]|
st.append(4): (13,22, -1, 8, 27, 11, 4)
st.index(8): 3
st.remove(8): (13, 22, -1, 27, 11, 4]
st.reverse(): (4, 11, 27,-1, 22, 13)
st.sort( ): F1,4 11, 13, 22, 27)
st.pop( ): -1, 4, 11, 13, 22, 27)
QUESTIONS
What are lists? How to define and access the elements of list.
Lists in Python are mutable. Justify.
3. How totraverse and delete the elemènts in the list?
Write short note on built in listoperators.
Explain built list functions and methods.
76
Python Programming (S.Y.B.Sc. - LT)|
9.
values(0:Thismethod returns list of dictionary values. (Sem-
Syntax :mydict.values()
Ex,:
>>> d2={'Name': "Tushar,'Age': 34, 'Class': 'First'}
>>> print ("Values:",
list(d2.values( ))
Values: Tushar', 'First', 34]
QUESTIONS
Write short note on tuple in Python.
What is tuple? How create and access it?
3.
Explain indexing, negative indexing and slicing with respect to tuples.
4. Write short note on tuple assignment and
5: Explain basic tuple returning the value.
6. Write
operations.
short note on built in tuple functions.
What is dictionary? How create and access it?
8.
Explain the properties of dictionary keys.
9. Write short note on operations in
dictionary.
J0. Explain built in dictionary functions.
L, Explain built in dictionary methods.
9
In Python,users can define such exceptions by creating a new class. Thie
has to be derived, either directly or indirectly, from
exceptions are also derived from this class.
Exception class.
Following program will ask the user to enter a number and guess
correctly: a
Most eRceyk
of the
stored
Ex.
# Pr.8.24 Python program to user define exception
class demo(Exception):
pass
print("value matched")
OUTPUT
Enter the number5
Exception raised value no matched
In above example we have
This is the standard way to defined a class called demno which raised by
define user-defined our progra
exceptions in Python programming.
1.) What is file? What are its QUESTIONS
2. Write short note
operating modes?
on file object attributes and file
3 Write a short methods.
program to deal with text file in Python.
4. What is
directory? Which methods are available to deal with
Write a short program todeal with directories in Python. directories in Pvthon?
What is Exception? List and explain any five built in
Write short note on exception handling mechanism inExceptions
Python.
in Python.
Write short note on Exception with arguments and
user defined
9. Write a short program to demonstrate Exception Handling in exception
Python.
S=STO
s.show( )
ST.sdemo()
OUTPUT
Hello World
Hello
of
PE
to arguments
10.13 POLYMORPHISM
functions or methods can be applied
type of the arguments differentwhichtypes,a
to
they
Polymorphic
can behave differently depending on the like int, float, char and
behaves they
stringfunction
example functionshow()
below
applied. In
Ex.
polymorphism
#Pr.10.19 Program touse
def show(s):
11.1
print("s: "s)
M
proce
show(11)
progr
show("Vedu") paral
show(1.2) Pythc
show('y')
inde
OUTPUT shar
S: 11 exec
S: Vedu the t
S: 1.2 This
S: y
11.
QUESTIONS po
1. What is Object Oriented Programming? Explain the concepts of 00P in
2. Write short note on class in Python. short.
3 List and explain built in class
attributes. Give
Write a short program todemonstrate use of example use.
of
4.
Write a short program to inheritance.
6.
demonstrate use of
Explain the concept of method overriding in multiple inheritance.
7. Explain Data Hiding, Data class with suitable example.
Encapsulation and static methods.
tm_min=56, tm_sec=49,tm_ wday=0, tm_yday=46, tm_isdst=0) mh0u
time.localtime( ): %s time.struct_time(tm_year=2017, tm_mon=5.
tm_hour=15, tm_min=36, tm sec=18, tm_wday=6, tm _yday=148, tm_isdst
May 28 2017 10:13:38
time.time(): 1495965978.937082
QUESTIONS
1.)What is multithreading? Write short note on
2.
thread module.
Explain creation of thread with suitable example.
3. Write short note on thread and Threading
modules.
How to synchronize the thread? Explain in detail.
5 Write short note on
Pythons Multithreaded priority queue. Give example.
6 What are module? How use it? What are its
7 How to create module? Explain
advantages?
with example.
Explain math module with its any five functions.
9. Demonstrate the use of math module functions with suitable example.
10. Explain time module with its any five functions.
11. Demonstrate the use of time module
functions with suitable example.
12. Explain random module with its any five functions.
13 Demonstrate the use of
randommodule functions with suitable example.
152
Python Programming (S.Y.B.Sc.-))(Sem.
QUESTIONS
What is GUI? Explain its advantages.
Explain creating GUl in Python with tkinter?
3.
Write note on standarddimension attributes of tkinter module.
+. Explain in details the standard colour attributes of tkinter module.
5.
Write note on standard font attributes of tkinter module.
6.
Write short note on anchor and relief attribute in Python GUI.
Explain creation of label widget with small example.
Writeshort note on checkbutton widget.
9. Write short note on button widget.
10. Explain creation of radiobutton widget with small example.
1 Explain frame with example.
12. Write a detail note on canvas widget.
13.)Write a detailnote on list widget.
14. Write short note on menu and menubutton.
15.)Explain Entry and text widget with small example.
16. Write short note on scale and scrollbar widget.
17. Write short note on spinbox widget. Give example.
18. Write short note on PanedWindow and LabelFrame.
(19./What is message box? What are its types?
20. Build asimple GUl application with demonstrating event handling of multiple
widgets.