Semester : S1 and S2
Year : 2016
Term : SEPTEMBER
Branch : MECHANICAL ENGINEERING
Scheme : 2015 Full Time
Course Code : BE 101-05
Page:2
10. Write a program to calculate nCr with a function for finding out factorial.
[11016: - nCr=n!/r!*(n-r)!] (2)
11. What are the different ways in which we can delete an item from a list? Explain with examples.
(2)
12. Consider the following code snippet:
one = “This a test!”
one[2] = “प्र!
print one
What error will the above code produce? Why is the error caused? Write the Python code
which will work around this issue and print the string “Thus a test!” as output. (3)
13. Assume that the variable data refers to the dictionary {‘‘b”:34,”a”:67}. Write the expressions
that perform the following tasks
a) Replace the value at key ”ا“ with negation of the value.
b) Add key:value pair “൦:56 to data.
c) Remove the value at key “a” in data. (3)
14. The following code sequence fails with a traceback when user enters a file that does not exist.
How would you avoid the traceback and make it so you could print out your own error message
when a bad file name was entered?
name = raw_input('Enter the file name: ')
Shand = open(fname)
Justify your answer. (2)
15. Compare class and object. Generate a class to represent a rectangle. (3)
16. What is pickling? How does it aid in putting values into a file? Also, what happens when the
“load” method is invoked? (3)
PART 8
Answer any 4 complete questions each having 8 marks
17. a) Describe the memory hierarchy of a computer with the help of a diagram (3)
b) Write notes on internal memory. (5)
18. Design an algorithm and flowchart to generate 0,1,1,2,3,5,8,13,21,34.....
19. Write a program to generate all prime numbers in a given range.
20. a) Write a python program to find the roots of a quadratic equation. (4)
b) Define recursion with an example function. (4)
21. a) List the advantages of using functions. (3)
2