Posts

Showing posts from February, 2025

python unit-3 programs

  Program-1: Aim: Write a program to create tuples (name, age, address, college) for at least two members and concatenate the tuples and print the concatenated tuples. Program: t1=('revanth',19,'vijayawada','LBRCE college') t2=('kumar',20,'mylavaram','CMR college') con_tuple=t1+t2 print(con_tuple) output:       program-2: Aim : Write a program to count the number of vowels in a string (No control flow allowed). Program: string="pythonprogramming" vowel_count=len([char for char in string if char in 'aeiouAEIOU']) print(vowel_count) output: program-3: Aim : Write a program to check if a given key exists in a dictionary or not. Program: dict={'a':1,'b':2,'c':3} check='b' exists=check in dict print(exists) output: program-4: Aim: Write a program to add a new key-value pair to an existing dictionary Program: dict={'a':1,'b...

pyhton unit-2 programs

  Program-1: Aim: Write a python program to define a function with multiple return values. Program: def operations(x,y):     sum=x+y     sub=x-y     mul=x*y     return sum,sub,mul sum,sub,mul=operations(25,15) print("sum:",sum) print("sub:",sub) print("mul:",mul) Output: (Or) def operations(x,y):     sum=x+y     sub=x-y     mul=x*y     return sum,sub,mul sum,sub,mul=operations(25,15) print("sum:",sum) print("sub:",sub) print("mul:",mul) program-2: Aim: Write a python program to define a function using default arguments. Program: def defaultArgs(a=10,b=15,c=30):     print(a,b,c)     return defaultArgs() Output: (or) def area_rect(height=1,length=1):     area=height*length     print(area) area_rect(10,10) output: Program-3: Aim:...

python unit-1 programs

Program 1: Aim: Write a python program to find the largest element among three Numbers Program: a=int(input("Enter a value :")) b=int(input("Enter b value :")) c=int(input("Enter c value :")) if((a>b)&(a>c)):     print("a is big",a) elif(b>c):     print("b is big",b) else:     print("c is big",c)   Output:                       Program 2: Aim: Write a python program for all prime numbers with in range. Program: min=int(input("Enter min number")) max=int(input("Enter max number")) for i in range(min,max):     count=0     for j in range(1,i+1):         if(i%j==0):             count+=1     if(count==2):         print(i) Output: ...