Introduction To Programming Practical File
Introduction To Programming Practical File
20231113090
Name :- Jaya Nagar
Aim :-
Section - 1
Section – 2
Ans :-
decimal = 10
remainder = decimal % 2
decimal = decimal // 2
Ans :-
print("marks of Ip is 60 ")
maths = 80
science = 75
communicationskill = 85
Ip =60
fluid = 45
tot = maths+science+communicationskill+Ip+fluid
avg = tot/5
else:
print("Invalid Input!")
PNR NO. 20231113090
Name :- Jaya Nagar
Ans :-
nums = [ 7, 8, 9, 10]
print(nums)
print(square_nums)
print(cube_nums)
PNR NO. 20231113090
Name :- Jaya Nagar
Q. 04 Write a program to add , delete and update the element from Tuple.
Ans :-
#programme to add
y = list(thistuple)
y.append("orange")
thistuple = tuple(y)
print(thistuple)
#programme to delete
y = list(thistuple)
y.remove("apple")
thistuple = tuple(y)
print(thistuple)
#programme to update
y = list(x)
y[1] = "kiwi"
x = tuple(y)
print(x)
Q . 05 Take a list of 10 elements. Find the average of elements minimum No. & Maximum No.
Ans :-
print("the 10 elements of list is" + " " "15, 9, 55, 41, 35, 20, 62, 49 , 50 , 10")
def Average(lst):
PNR NO. 20231113090
Name :- Jaya Nagar
average = Average(lst)
x=min(lst )
x=max(lst)
Ans :-
# initialising dictionary
print("initial_dictionary", str(ini_dict))
rev_dict = {}
rev_dict.setdefault(value, set()).add(key)
# printing result
Q. 07 S = "Dyp1 international 45 university578" calculate the sum and Average of digit present in
string
Ans :-
def sum_digits_string(str1):
sum_digit = 0
if char.isdigit():
digit = int(char)
sum_digit += digit
return sum_digit
print(result1)
average = print(result1/6)
PNR NO. 20231113090
Name :- Jaya Nagar
test_str = "abcdabcdabcdabcd"
print("string is abcdabcdabcdabcd")
count = 0
for i in test_str:
if i == 'a':
count = count + 1
+ str(count))
count = 0
for i in test_str:
if i == 'b':
count = count + 1
+ str(count))
count = 0
for i in test_str:
if i == 'c':
count = count + 1
+ str(count))
count = 0
for i in test_str:
if i == 'd':
count = count + 1
Ans :-
Create two 3-by-3 arrays, A and B, and multiply them element by element.
>> A = [1 0 3; 5 3 8; 2 4 6];
B = [2 3 7; 9 1 5; 8 8 3];
C = A.*B
PNR NO. 20231113090
Name :- Jaya Nagar
Q . 02 Plot graph for A graph a = [0:0.5:5], b = [2a^2+3a-5], define the plot by line pattern color and
thickness .
Ans :-
a = [0:0.5:5]
a=
0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000 4.5000 5.0000
b=
-5 -3 0 4 9 15 22 30 39 49 60
>> plot(a,b)
Q.03 Write program to determine weather given year is leap year or not ?
Ans :-
>> prompt = 'enter the year which you want to check whether it is leap year or not\n';
year = 2024
cond1 = 100;
cond2 = 4;
cond3 = 400;
else
end
year =
2024
>>
PNR NO. 20231113090
Name :- Jaya Nagar
Q.04 take an array of 10 elements and calculate average and sum of numbers ?
Ans :-
x = [1 2 3 4 5 6 7 8 9 10]
theSum = 0;
for k = 1 : length(x);
fprintf('After element #%d, the sum = %.1f, and the mean = %.3f\n\n',...
k, theSum, theSum/k);
end
PNR NO. 20231113090
Name :- Jaya Nagar
Plot A&C
Ans :-
>> a = [0;0.5;5]
a=
0.5000
5.0000
>>
b = [2*a.^2+3*a-5]
b=
-5
-3
60
>>
b = [2*a.^2+4*a-3]
b=
-3.0000
-0.5000
67.0000
>> plot(a,b,'--ro')
>> plot(a,c,'-g')
title('second graph')
PNR NO. 20231113090
Name :- Jaya Nagar
PNR NO. 20231113090
Name :- Jaya Nagar