0% found this document useful (0 votes)
18 views4 pages

Set 1

Uploaded by

lokbushank
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)
18 views4 pages

Set 1

Uploaded by

lokbushank
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/ 4

#1 different number data types in python

'''
i=10
flt=10.1
str1="Exam"
cmp=10+5j
lst=[1,2,3]
tup=(1,2,3)
dict={1:"aa",2:"bb"}
set1={1,2,3}
print(type(i))
print(type(flt))
print(type(str1))
print(type(cmp))
print(type(lst))
print(type(tup))
print(type(dict))
print(type(set1))
'''

#2 different number data types in python


'''
a=10
b=3
print(a+b)
print(a-b)
print(a*b)
print(a/b)
print(a//b)
print(a%b)
print(a**b)
'''

#3 To create, concatenate and print a string and accessing substring


'''
str1="Annamalai"
str2="University Exam"
print(str1+str2)
print(str1[0:4]+str2[0:10])
'''

#4 To print the current date in the format “Sun May 29 02:26:23 IST
2017”
'''
import time
ltime=time.localtime()
print(time.strftime("%a %b %d %H:%M:%S %Z %Y",ltime))
'''

#5 To create, append and remove lists


'''
lst=[10,20,30,40]
print("Original lst : ",lst)
lst.append(50)
print("After append : ",lst)
lst.remove(20)
print("After remove : ",lst)
'''

#6 To demonstrate working with tuples


'''
tuple1=(1,2,-3,2,2,2)
tuple2=2,5,6

print("Access using +ve index :",tuple1[2])


print("Access using -ve index :",tuple2[-2])
tuple3=tuple1+tuple2
print("Concatenation :",tuple3)
print("Repetation :",tuple1*3) #tuple1+tuple1
print("in operation :",10 in tuple1)
print("Slicing :",tuple1[1:2])
print("Reverse :",tuple1[::-1])

print("Traversing the list using for :")


for i in tuple1:
print(i)
#Tuple Functions
print("max :",max(tuple1))
print("min :",min(tuple1))
print("Length of the tuple ",len(tuple1))
print("Sum of the tuple :",sum(tuple1))
print("Sorted tuple elements ",(sorted(tuple1)))
'''

#7 To demonstrate working with dictionaries


'''
d1={1:"one",3:"three",2:"two"}
print(d1)
print(" Print the value using key value :",d1[1])
print(" Print the value using get method :",d1.get(1))
print(" Items : ",d1.items())
print(" Keys : ",d1.keys())
print(" Values : ",d1.values())
'''

'''

#8 To find largest of three numbers


n1=int(input("Enter the number1 :"))
n2=int(input("Enter the number2 :"))
n3=int(input("Enter the number3 :"))
if(n1>n2):
if(n1>n3):
print("N1 is greater ")
else:
print("N3 is greater")
else:
if(n2>n3):
print("N2 is greatest")
else:
print("N3 is greatest")
'''

'''
#9
# Centigrade to farenheit
celsius=int(input("Enter the celsius :"))
farenheit=1.8*celsius+32
print("Farenheit = ",farenheit)
'''

'''
#10 To construct the Star pattern
n=5
for i in range(n):
for j in range(i):
print ('* ', end="")
print('')

for i in range(n,0,-1):
for j in range(i):
print('* ', end="")
print('')
'''

'''
#11 To print prim numbers less than 20
n=int(input("Enter the value of n : "))
for i in range(2,n+1):
flag=0
for j in range(2,i):
if(i%j == 0):
flag=1
break
if(flag==0):
print(i)
else:
continue
print("end")
'''

'''
#12 To find factorial of a number using recursion
def fact(m):
f1=1
for i in range(1,m+1):
f1=f1*i
return(f1)

n=int(input("Enter the value of n:"))


f=fact(n)
print("Factorial :",f)
'''

'''
#13 To accepts length of three sides of a triangle
opp_side=int(input("Enter the oppsite side :"))
adj_side=int(input("Enter the adjacent side :"))
hyp=int(input("Enter the Hypotenuse side :"))
hyp1=opp_side*opp_side + adj_side*adj_side
if(hyp==hyp1):
print("Given Sides form right angled triangle")
else:
print("Given Sides does not form right angled triangle")
'''

'''
#14 To define a module to find Fibonacci Numbers
def fib(n):
a, b = 0, 1
while b < n:
print(b, end =" ")
a, b = b, a+b

import fibbonacci.fib
n=int(input("Enter the value of n:"))
fibbonacci.fib(n)
'''

'''
#16 Write a script named copyfile.py.
f1=open("E:\\f1.txt","r")
f2=open("E:\\f2.txt","w")
s=f1.read()
f2.write(s)
f1.close()
f2.close()

f3=open("E:\\f2.txt","r")
s=f3.read()
print(s)
f3.close()
'''

'''
#17 Unique words in the file in alphabetical order
f1=open("E:\\f1.txt","r")
s=f1.read().split()
set1=set(s)
print(sorted(set1))
f1.close()
'''

'''
#18 Reverse and Palindrome
s=input("Enter the string:")
s1=s[::-1]
print("Reversed string :",s1)
if(s!=s1):
print("Not a palindrome")
else:
print("Palindrome")
'''

You might also like