0% found this document useful (0 votes)
2 views2 pages

Sec Lab

The document contains a Python script that performs various operations on lists, including concatenation, character counting, and element swapping. It also includes functions to calculate the area of geometric shapes, determine the nature of roots of a quadratic equation, and manipulate strings. Additionally, it demonstrates tuple conversion to a list and modification of its elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Sec Lab

The document contains a Python script that performs various operations on lists, including concatenation, character counting, and element swapping. It also includes functions to calculate the area of geometric shapes, determine the nature of roots of a quadratic equation, and manipulate strings. Additionally, it demonstrates tuple conversion to a list and modification of its elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# -*- coding: utf-8 -*-

"""
Created on Thu Sep 26 13:27:56 2024

@author: USER
"""
#%%
l1=["mohit","himanshu","abhigyan"]
l2=[1,2,3,4]
l=l1+l2
print("The union of two lists is",l)
a=0
for i in l1:
a+=len(str(i))
pass
print("The total number of characters in list 1 is",a)
print("The total number of elements in list 2 is",len(l2))

a=l[0]
b=l[-1]
l[0]=b
l[-1]=a
print(l)

a=len(l)
if a%2==0:
b=a+1
print(l[b//2])
else:

print(l[a//2])

l.reverse()
print(l)
l.pop(-1)
#%%
a=int(input("enter a number"))
if a%2==0:
print(a,"is even")
else:
print(a,"is odd")
#%%
choice=int(input("enter your choice"))
if choice==1:
r=int(input("enter radius of circle whose area is to find"))
print("Area of circle of radius",r,"is",3.14*r**2)
elif choice==2:
R=int(input("enter radius of sphere whose volume is to find"))
print("Volume of sphere of radius",R,"is",4/3*3.14*R**3)
elif choice==3:
a=int(input("enter radius of cone"))
b=int(input("enter slant height of cone"))
print("Area of cone is",3.14*a**2+3.14*a*b)
else:
print("Entered choice is wrong and not in our system")
#%%
a=int(input("enter coefficients of x^2 of quadratic equation"))
b=int(input("enter coefficients of x of quadratic equation"))
c=int(input("enter coefficients of constant of quadratic equation"))
d=(b**2-4*a*c)
if d>0:
print("Roots are real")

elif d==0:
print("Roots are real and equal")
elif d<0:
print("Roots are imaginary")
#%%
a=input("enter a string")
print("Total number of characters in string is",len(a))
print("The first element of the string is",a[0],"and","the last element if the
string is",a[-1])
b=list(a)
print(b)
m=b[0]
n=b[-1]
b[0]=list(n)
b[-1]=list(m)
print(b)
#%%
x=("mango","apple","bananna",25,30,35)
y=list(x)
y[2]="orange"
print(y)

You might also like