4, ఆగస్టు 2025, సోమవారం

python lab-3 implementation ........................

 # Initializing three numbers

num1, num2, num3 = 10, 20, 30


# Calculating sum and average

sum_numbers = num1 + num2 + num3

average = sum_numbers / 3


# Displaying the result

print(f'Sum: {sum_numbers}, Average: {average}')



print ('argument list', sys.argv)

first = int(sys.argv[1])

second = int(sys.argv[2])

print ("sum = {}".format(first+second))


C:\ramu>python hello.py 10 20

argument list ['hello.py', '10', '20']

sum = 30




def get_employee_data(): """Reads employee data from the keyboard.""" employee_id = input("Enter Employee ID: ") employee_name = input("Enter Employee Name: ") employee_salary = input("Enter Employee Salary: ") employee_department = input("Enter Employee Department: ") employee_info = { "ID": employee_id, "Name": employee_name, "Salary": employee_salary, "Department": employee_department } return employee_infodef print_employee_data(employee_data): """Prints the provided employee data.""" print("\n--- Employee Details ---") for key, value in employee_data.items(): print(f"{key}: {value}")if __name__ == "__main__": employee_details = get_employee_data() print_employee_data(employee_details)




import math# Get the radius from the usertry: radius = float(input("Enter the radius of the circle: "))except ValueError: print("Invalid input. Please enter a numerical value for the radius.") exit()# Check if the radius is non-negativeif radius < 0: print("Radius cannot be negative. Please enter a positive value.")else: # Calculate the area area = math.pi * (radius ** 2) # Display the result print(f"The area of the circle with radius {radius} is: {area}")






కామెంట్‌లు లేవు:

కామెంట్‌ను పోస్ట్ చేయండి