python IA 2
python IA 2
not. (8)
PULAVARNATHAM, THANJAVUR
Department of Science and Humanities
PART C (1*16=16 marks)
Internal Assessment II 12. (a) i) Elaborate on membership, identity and bitwise operators of
GE3151 Problem Solving and Python Programming python with suitable examples. (12)
YEAR/SEM: I/I Time: 1.30 Hrs ii) Write a program to print the digit at one’s place of a number. (4)
Max. Marks: 60 OR
PART A (9 X 2 =18Marks)
(b) Write a program to perform search operation which sequentially
1. What is the difference between interactive mode and script mode? checks each element of the list until a match is found or the whole list has
2. Mention the features of lists in python. been searched? (16)
3. List the various single valued data types in python.
4. What is an indentation in python? Give an example.
5. What is ‘len’ function? Give example for how it is used on strings.
6. Write a loop that prints numbers 0 to 57 using the range function in
python.
7. Compare return value and composition.
8. Define String immutability.
9. Write a simple function to multiply two numbers in python.
# Displaying result
print('Distance = %f' %(d)) The Sum Of Array Elements = 917
11.ii) Write a program to find the sum and average of array numbers.
import numpy as np
The Average Of Array Elements = 83.36363636363636
total = 0
b) Write a program to perform search operation which sequentially checks each
for i in range(len(arr)): element of the list until a match is found or the whole list has been searched?
total = total + arr[i] Linear Search Algorithm
LinearSearch(array, key)
avg = total / len(arr)
for each item in the array
print('\nThe Sum Of Array Elements = ', total) if item == value
print('\nThe Average Of Array Elements = ', avg) return its index
Total Array Elements to enter = 7 Linear Search in Python
Please enter the 1 Array Value = 22 def linearSearch(array, n, x):