0% found this document useful (0 votes)
4 views1 page

Python

The document outlines important Python programming questions covering topics such as conditional statements, functions, built-in functions, variable scopes, exception handling, data structures, and methods. It includes specific programming tasks like generating a Fibonacci sequence and manipulating lists with examples. Additionally, it provides explanations of various Python concepts and syntax with illustrative examples.

Uploaded by

jeevanambkj555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Python

The document outlines important Python programming questions covering topics such as conditional statements, functions, built-in functions, variable scopes, exception handling, data structures, and methods. It includes specific programming tasks like generating a Fibonacci sequence and manipulating lists with examples. Additionally, it provides explanations of various Python concepts and syntax with illustrative examples.

Uploaded by

jeevanambkj555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python important questions

1. With python programming examples to each, explain the syntax and control flow
diagrams of Conditional Statements (any three).
2. Define functions? Explain functions in python in python with parameters and return
statement.
3. Explain the following built in functions (i) print( ) (ii) input( ) (iii) Len( )
(iv) String Concatenation (v) String replication.
4. Explain the local and global scopes with suitable example. Explain FOUR scope rules
of variables in Python.
5. Define Exception handling. How exceptions are handled in python? Write a program
to solve divide by zero exception.
6. Develop a program to generate Fibonacci sequence of length(N). Read N from
console.
7. Discuss list and dictionary data structures with example for each.
8. Explain different types of methods like (i) append( ), (ii) remove( ), (iii) sort( ),
(iv) reverse( ), (v) insert( )
9. Explain Augmented short hand assignment operators with example
10. For a=[‘hello’, ‘how’, [1,2,3], [[10,20,30]]] what is the output of following statement
(i) print( a[ : : ] )
(ii) print(a[-3][0])
(iii) print(a[2][ : -1])
(iv) print(a[0][ : : -1])
(v) print(a[-1][1:-1]
Solutions(i) a[::] is a full slice with default start, stop, and step.
This simply returns the whole list
['hello', 'how', [1, 2, 3], [[10, 20, 30]]]
(ii) print(a[-3][0])
a[-3] accesses the 2nd element ('how') because:
a[-1] is [[10, 20, 30]]
a[-2] is [1, 2, 3]
a[-3] is 'how'
'how'[0] gives 'h'
'h'

(iii) print(a[2][:-1])

a[2] is [1, 2, 3]
[:-1] slices off the last element
[1, 2]
(iv) print(a[0][::-1]) (v) print(a[-1][1:-1]
a[0] is 'hello' a[-1] is [[10,20,30]]
[::-1] reverses the string [1:-1] is 20
'olleh' 20

You might also like