Q1. Write a
Python program to print the sum of series 13 + 23 + 33
+ 43 + …….+ n3
till n-th
term. N is the value given by the user.
Q.2. Write a Python Program to find the successor
and predecessor of the largest
element in
an array.
Q.3. Write a
Python program that takes list of numbers as input from the user and
produces a
cumulative list where each element in the list at any position n is
sum of all
elements at positions upto n-1
Q. 1
Write a Python function to find the sum of all numbers between 100 and
500 which
are divisible by 2.
Q . 2
Write a Python function to get two matrices and multiply them. Make sure
that number
of columns of first matrix = number
of rows of second.
Q . 3Write a Python function which
takes list of integers as input and finds:
(a) The largest positive number in
the list
(b) The smallest negative number in
the list
(c) Sum of all positive numbers in
the list
Mutable and immutable data types?
If elif else satatement used for
How do you define a python function
Loops name and type in python
What is variable in python
1. Program
to multiply two matrices using nested loops
3x3 matrix
X = [[12,7,3],
[4 ,5,6],
[7 ,8,9]]
# 3x4 matrix
Y = [[5,8,1,2],
[6,7,3,0],
[4,5,9,1]]
2. Python
Program to Convert Decimal to Binary Using Recursion
3 .Python
program to find the sum of natural using recursive function
Viva
Different
in set and dictionary
Python
sequent data types
Python 2
library name
Python
developer and year
M3
r5 python
Python program to
print the pattern
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
Q 2
Python Program to Find Factorial of Number Using Recursion
Q 3
Write python
program to print number between range and
sum ,average of even number , where range is input by user
Viva
How to
import numbpy
Import numpy
as np
How many
file modes available in python
R+
W+
A+
Python
developed by using which language
Who
developed python and when
How many
keywords in python
What is
flowchart?
Algorithm ?pseudo?
M3 r5 python
Write a
program to generate 6 digit random secure OTP between 100000 to 999999.
Write a
function that removes all duplicates from a list while maintaining the original
order
Write a
Python function that takes a string and returns the number of vowels in it.
Viva
python
What are
sequence data types
What is
anonymous function
What is
recursion
Name any
three module in python
M3
r5
Q 1
Write Python program to calculate
Electricity Bill
unit > 500 then 9.25 per unit and
surcharge 80
unit > 300 then 7.25 per unit and
surcharge 70
unit > 200 then 5.25 per unit and
surcharge 50 and so on
Q 2 Python
program to input 4 number and print in ascending order
Q 3 Python
program to compute the result when two numbers and one operator is given by
user
Viva
Different in
list and tuple
Different in set
and dict
What is numpy
What is file
handling
M3 R5
1 Write a
program that take in a sentence as input and display the number of words number
of capital letter number of small letter and number of special symbols
2 Accept
the name of the labour and number of hours worked calculate and display the
wages the program should run for n numbers of labourers as specified by the
user
3 Write a program to compute the wages of a
daily laborer as per the following rules:
Hours
Worked Rate Applicable:
Upto
first 8 hrs Rs 100/-
a) For
next 4 hrs Rs 30/- per hr extra
b) For
next 4 hrs Rs 40/- per hr extra
c) For
next 4 hrs Rs 50/- per hr extra
d) For
rest Rs 60/- per hr extra
viva
full form
of idle
what is
file handling in python
types of
numeric data type in python
name the
sequence data types
def
abcd():
Q . 1
.Write a function that takes two filenames f1 and f2 as input. The function
should read the contents of f1 line by line and write them onto f2.
Q .2 .
Write a NumPy program to find the most frequent value in an array.
Q .3
.Take two NumPy arrays having two dimensions. Concatenate the arrays on axis 1.
Viva
What is
numpy
Name any
three module in python
Name any
three built in function in python
Name any
three function used for file handling
Explain
mutable and immutable data types
What are
local and global scope
Define the
rules of declaring a variable
1. Program to Print Armstrong Numbers in a Given Range
An Armstrong number is a number whose sum of cubes of digits is equal to the number itself. Example: 370 = 3³ + 7³ + 0³
start = int(input("Enter start range: "))
end = int(input("Enter end range: "))
for num in range(start, end+1):
temp = num
s = 0
while temp > 0:
d = temp % 10
s += d ** 3
temp //= 10
if s == num:
print(num)
2. Function to Find Sum of Series: X + X³/3! + X⁵/5! + …
import math
def series1(x, n):
s = 0
power = 1
for i in range(n):
s += (x ** power) / math.factorial(power)
power += 2
return s
x = int(input("Enter x: "))
n = int(input("Enter n: "))
print(series1(x, n))
3. Function to Find Sum of Series: 1 + x/1! + x²/2! + …
import math
def series2(x, n):
s = 0
for i in range(n):
s += (x ** i) / math.factorial(i)
return s
x = int(input("Enter x: "))
n = int(input("Enter n: "))
print(series2(x, n))
4. Program to Multiply Two Numbers Using Repeated Addition
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
result = 0
for i in range(b):
result += a
print("Multiplication =", result)
5. Program to Compute Wages of Daily Labourer
n = int(input("Enter number of labourers: "))
for i in range(n):
name = input("Enter labourer name: ")
hours = int(input("Enter hours worked: "))
wage = 0
if hours <= 8:
wage = hours * 100
else:
wage = 8 * 100
hours -= 8
if hours > 0:
extra = min(4, hours)
wage += extra * 30
hours -= extra
if hours > 0:
extra = min(4, hours)
wage += extra * 40
hours -= extra
if hours > 0:
extra = min(4, hours)
wage += extra * 50
hours -= extra
if hours > 0:
wage += hours * 60
print("Name:", name, "Wages:", wage)
6. Function to Replace Successive Repeated Characters with ?
def replace_repeat(s):
result = s[0]
for i in range(1, len(s)):
if s[i] == s[i-1]:
result += '?'
else:
result += s[i]
return result
print(replace_repeat("school"))
7. Program to Analyze a Sentence
s = input("Enter sentence: ")
words = len(s.split())
caps = small = special = 0
for ch in s:
if ch.isupper():
caps += 1
elif ch.islower():
small += 1
elif not ch.isalnum() and ch != ' ':
special += 1
print("Words:", words)
print("Capital letters:", caps)
print("Small letters:", small)
print("Special symbols:", special)
8. Program to Create Cumulative List
lst = list(map(int, input("Enter numbers: ").split()))
cum = []
total = 0
for x in lst:
total += x
cum.append(total)
print(cum)
9. Program to Find Largest, Smallest and Product of List
lst = list(map(int, input("Enter numbers: ").split()))
largest = lst[0]
smallest = lst[0]
product = 1
for x in lst:
if x > largest:
largest = x
if x < smallest:
smallest = x
product *= x
print("Largest:", largest)
print("Smallest:", smallest)
print("Product:", product)
10. Function to Check Common Item in Two Lists
def common(lst1, lst2):
for x in lst1:
if x in lst2:
return True
return False
print(common([1,2,3], [4,5,3]))
11. Combine Two Dictionaries by Adding Values
from collections import Counter
d1 = {'a':100, 'b':200, 'c':300}
d2 = {'a':300, 'b':200, 'd':400}
result = Counter(d1) + Counter(d2)
print(result)
12. Recursive Programs
a) Product of Two Numbers Using Recursion
def multiply(a, b):
if b == 0:
return 0
return a + multiply(a, b-1)
print(multiply(6, 7))
b) Fibonacci Series Using Recursion
def fib(n):
if n <= 1:
return n
return fib(n-1) + fib(n-2)
n = int(input("Enter n: "))
for i in range(n):
print(fib(i), end=" ")
13. Program to Find GCD of Two Numbers
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
while b != 0:
a, b = b, a % b
print("GCD =", a)
14. File Handling Program: Copy File Content
def copy_file(f1, f2):
with open(f1, 'r') as src, open(f2, 'w') as dest:
for line in src:
dest.write(line)
copy_file("f1.txt", "f2.txt")
15. NumPy Program to Find Most Frequent Element
import numpy as np
arr = np.array([1,2,2,3,3,3,4])
values, counts = np.unique(arr, return_counts=True)
print(values[counts.argmax()])
16. NumPy Program to Concatenate Two 2D Arrays (Axis=1)
import numpy as np
a = np.array([[1,2],[3,4]])
b = np.array([[5,6],[7,8]])
c = np.concatenate((a, b), axis=1)
print(c)
1 Comments
THANKS SIR
ReplyDelete