Journal N Docs
Journal N Docs
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
Output:
def rectangle(type_need):
le=float(input("Enter lenth"))
b=float(input("Enter bredth"))
if type_need == 1:
print("the area is =",le*b)
elif type_need == 2:
print("the perimeter is =",2*(le+b))
def circle(type_need):
r=float(input("Enter radius"))
if type_need == 1:
print("the area is =",(22/7)*r*r)
elif type_need == 2:
print("the perimeter is =",2*(22/7)*r)
if f==1:
if c == 1:
circle(1)
elif c == 2:
circle(2)
elif f ==2:
if c ==1:
square(1)
elif c == 2:
square(2)
elif f==3:
if c == 1:
rectangle(1)
elif c == 2:
rectangle(2)
else:
print("Pls enter valid numbers")
Output:
Output:
4.List Manipulation(In interactive mode)
print("Name :Viraj Bhardwaj")
print("class and sec : 10F")
print("")
>>> list1=[1,2,4,5]
>>> list1.insert(3,2)
>>> print(list1)
[1, 2, 4, 2, 5]
>>> list[6,7,8]
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
list[6,7,8]
TypeError: 'type' object is not subscriptable
>>> list2= [6,7,8]
>>> list1.extend(list2)
>>> print(list1)
[1, 2, 4, 2, 5, 6, 7, 8]
>>> list1.pop(1)
2
>>> print(list1)
[1, 4, 2, 5, 6, 7, 8]
>>> l1=[1,2,3]
>>> l2=[4,5,6]
>>> l1==l2
False
>>> l1+l2
[1, 2, 3, 4, 5, 6]
>>> l1*l2
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
l1*l2
TypeError: can't multiply sequence by non-int of type 'list'
>>> is 5 in l1
SyntaxError: invalid syntax
>>> 5 in l1
False
>>> 5 in l2
True
>>> l1 is l2
False
>>> a=10
>>> type(a)
<class 'int'>
>>> b=2.5
>>> type(b)
<class 'float'>
>>> c="hello"
>>> type(c)
<class 'str'>
5.Fibboancci Series:
Code:
print("Name :Viraj Bhardwaj")
print("class and sec : 10F")
print("")
num = int(input("Enter a limit"))
a=0
b=1
for i in range(1,num+1):
if a<=num:
c=a+b
print(a)
a=b
b=c
Output:
6. Factorial:
Code:
print("Name :Viraj Bhardwaj")
print("class and sec : 10F")
print("")
a=int(input("Enter a number:"))
b=1
for i in range(1,a+1):
b*=i
print(b)
Output:
7. Reverse a String:
Code:
print("Viraj Bhardwaj")
print("10.F, 36")
print("Reverse a string")