26, ఆగస్టు 2025, మంగళవారం
python intl/regnl languages..................# A lambda function to add 10 to a number add_ten = lambda x: x + 10 print(add_ten(5)) # Output: 15 # Using lambda with filter() to get even numbers my_list = [1, 2, 3, 4, 5, 6] even_numbers = list(filter(lambda x: x % 2 == 0, my_list)) print(even_numbers) # Output: [2, 4, 6]
23, ఆగస్టు 2025, శనివారం
Python Online Compiler................... programiz.proStrings in Python are sequences of characters, so we can access individual characters using indexing. Strings are indexed starting from 0 and -1 from end. This allows us to retrieve specific characters from the string. s = "ramdayinaboyina " # Accesses 3rd character: 'r' print(s[-10]) # Accesses 5th character from end: '' print(s[-5])
print("Try programiz.pro")
a=3
b=3.4
print(a,b)
print(type(a))
a=b
print(a)
a=int(b)
print(a)
c = "ramu.a.dayinaboyina"
print(c)
s = "ram.a.dayinaboyina"
print(s[1]) # access 2nd char
s1 = s + s[0] # update
print(s1) # print
output:-
Try programiz.pro
3 3.4
<class 'int'>
3.4
3
ramu.a.dayinaboyina
a
ram.a.dayinaboyinaa
s = """I am Learning
Python String on by ramu sir """
print(s)
s = '''I'm a
ramu'''
print(s)
22, ఆగస్టు 2025, శుక్రవారం
lab session 5 for python programming ....................
n = 6 # Initialize the factorial variable to 1 fact = 1 # Calculate the factorial using a for loop for i in range(1, n + 1): fact *= i print(fact)
import math
# Lambda function to calculate square root using math.sqrt()
sqrt_lambda_math = lambda x: math.sqrt(x)
# Example usage
number = 25
result = sqrt_lambda_math(number)
print(f"The square root of {number} using math.sqrt() is: {result}")program 3
# using lambda with max() function
find_max = lambda a, b, c: max(a, b, c)
result = find_max(10, 5, 8)
print("Maximum Number :", result)
prg4 for filter , lambda concepts
a = [1, 2, 3, 4, 5]
res = list(filter(lambda num: num % 2 == 0, a))
print(res)
output
[2, 4]
21, ఆగస్టు 2025, గురువారం
దీనికి సబ్స్క్రయిబ్ చేయి:
పోస్ట్లు (Atom)