PRACTICAL 11-20uhbfdfhjdgjm
PRACTICAL 11-20uhbfdfhjdgjm
PRACTICAL-11
============
Input a list of numbers and swap elements at the even location with the
n=len(l)
for i in range(0,n,2):
l[i],l[i+1]=l[i+1],l[i]
OUTPUT
[11, 22, 33, 44, 55, 66, 77, 88, 99, 121]
[22, 11, 44, 33, 66, 55, 88, 77, 121, 99]
'''
'''
PRACTICAL-12
============
char_list=[]
c=1
char_list.append(chr(i)*c)
c=c+1
OUTPUT
'''
'''
PRACTICAL-13
===========
Write a progarm that reads a number n to display the Fibonacci Series upto the nth term
n=int(input("Enter upto which term do you want to print the Fibonacci Series?"))
t1=0
t2=1
if n==1:
print(t1)
elif n==2:
print(t1,",",t2)
elif n<=0:
print("Invalid entry")
else:
print(t1,",",t2,end=",")
for i in range(3,n+1):
tn=t1+t2
t1,t2=t2,tn
print(tn,end=",")
OUTPUT
Enter upto which term do you want to print the Fibonacci Series?26
0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,
75025,
'''
'''
PRACTICAL-14
============
n=len(l)
l.sort()
if n%2==0:
else:
OUTPUT-1
Enter the elements of a list[22, 11, 44, 33, 66, 55, 88, 77, 99]
OUTPUT-2
Enter the elements of a list[22, 11, 44, 33, 66, 55, 88, 77, 121, 99]
Elements of Original list=
[22, 11, 44, 33, 66, 55, 88, 77, 121, 99]
[11, 22, 33, 44, 55, 66, 77, 88, 99, 121]
'''
'''
PRACTICAL-15
============
n=len(t)
p=""
c=0
for j in range(n):
if t[j]==s:
p=p+str(j)+","
c=1
if c==0:
else:
OUTPUT
'''
'''
PRACTICAL-16
============
Write aprogram that inputs two tuples seq_a and seq_b and prints True if
for i in seq_a:
if i not in seq_b:
print("False")
break
else:
print("True")
OUTPUT
False
'''
'''
PRACTICAL-17
============
import json
planets_dictionary={'M':'MERCURY','V':'VENUS','E':'EARTH','A':'MARS','S':'SATURN','J':'JUPITER','U':'U
RANUS','N':'NEPTUNE','P':'PLUTO'}
print("Original dictionary:")
print(json.dumps(planets_dictionary,indent=2))
keys=planets_dictionary.keys()
values=planets_dictionary.values()
planets_dict_reversed=dict(zip(values,keys))
print(json.dumps(planets_dict_reversed,indent=2))
keys1=sorted(keys)
print(keys1)
OUTPUT
Original dictionary:
"M": "MERCURY",
"V": "VENUS",
"E": "EARTH",
"A": "MARS",
"S": "SATURN",
"J": "JUPITER",
"U": "URANUS",
"N": "NEPTUNE",
"P": "PLUTO"
"MERCURY": "M",
"VENUS": "V",
"EARTH": "E",
"MARS": "A",
"SATURN": "S",
"JUPITER": "J",
"URANUS": "U",
"NEPTUNE": "N",
"PLUTO": "P"
'''
'''
PRACTICAL-18
===========
Create a dictionary with the roll number, name and marks of n students in a class and display the
import json
stu_dict={}
for i in range(n):
stu_dict[rn]=[nm,mk]
print(json.dumps(stu_dict,indent=2))
stu_distiction={}
for j in range(1,n+1):
if stu_dict[j][1]>=75:
stu_distiction[j]=stu_dict[j]
print(json.dumps(stu_distiction,indent=2))
OUTPUT
"1": [
"Anil",
79
],
"2": [
"Bishakha",
65
],
"3": [
"Chetan",
71
],
"4": [
"Darsana",
89
],
"5": [
"Fahim",
78
],
"6": [
"Naina",
58
"1": [
"Anil",
79
],
"4": [
"Darsana",
89
],
"5": [
"Fahim",
78
'''
'''
PRACTICAL-19
==============
import random
a=pow(10,n-1)
b=pow(10,n)-1
OUTPUT1
OUTPUT2
'''
'''
PRACTICAL-20
============
import math
print("Answer =",ans)
OUTPUT
Answer = 4096.0
'''