Model2 PYTHON Key
Model2 PYTHON Key
3. Write an algorithm to find the sum of first ‘N ‘ natural numbers (AU.,DEC2022) C105.1 BTL1
1. Start
2. Assign sum=0 and i=0
3. Read the number , n
4. Repeat steps 5 to 6 until i=n reached
5. Compute sum=sum+i
6. Compute i=i+1
7. Print sum
8. Stop
Dictionaries in python is an ordered collection of data values, used to store data values like a map. Unlike other
9. How do you use command line arguments to give input to the program?
Python provides a getopt module that helps to parse command line option and arguments.
10. What is range function and how it is used in the list ? (AU,A/D2024) C105.2 BTL1
The range() function generates a list of numbers. This is very useful when creating new lists
Eg:
x = list(range(1,101))
print(x)
11. i) Draw a flow chart to accept three distinct numbers , find (AU,N/D2022) C105.2 BTL2
the greatest and print the result (8)
ii) Draw a flowchart to find the sum of the series. 1+2+3+…..
+100(8)
12. i) What is meant by recursion? Write a recursive algorithm to (AU,N/D2022) C105.3 BTL2
solve towers of Hanoi problem (8)
ii) Explain in detail about precedence of python operators
and the associativity of python operators.(8)
13. i) Discuss about scope and lifetime of variables considering (AU,N/D2022) C105.2 BTL3
functions.(8)
ii) Write and explain the python program to swap two
numbers with and without temporary variables.(8)
14. i) Explain bubble sort algorithm using python (AU,N/D2023) C105.2 BTL4
programming(8)
ii) What is string function in python? Explain any 3 python
string methods with an example.(6)
15. i) Explain in deatil about lists, list operations and list slices(8)
(AU,A/M2023) C105.2 BTL3
ii)Demonstrate with python code the various operations that can be performed on tuples(8)
16. i) Why does python require file handling?Explain opening & closing file in python with all modes.
(AU,N/D2023) C105.3 BTL4
ii) Give a brief note on python exception handling using try, except, raise and finally statements.(8)