Prac1 num1 = int(input('Enter First number: ')) num2 = int(input('Enter Second number ')) add = num1 + num2 dif = num1 - num2 mul = num1 * num2 div = num1 / num2 floor_div = num1 // num2 power = num1 ** num2 modulus = num1 % num2 print('Sum of ',num1 ,'and' ,num2 ,'is :',add) print('Difference of ',num1 ,'and' ,num2 ,'is :',dif) print('Product of' ,num1 ,'and' ,num2 ,'is :',mul) print('Division of ',num1 ,'and' ,num2 ,'is :',div) print('Floor Division of ',num1 ,'and' ,num2 ,'is :',floor_div) print('Exponent of ',num1 ,'and' ,num2 ,'is :',power) print('Modulus of ',num1 ,'and' ,num2 ,'is :',modulus) Prac2 print("Logical Operators") print(True and True) print(True and False) print(True or False) print(not True) print("Relational Operators") a = 5 b = 6 print('a == b =', a == b) print('a != b =', a != b) print('a > b =', a > b) print('a < b =', a < b) print('a >= b =', a >= b) print('a <= b =', a <= b) Prac 3 number = int(input("Enter the integer number: ")) revs_number = 0 while (number > 0): remainder = number % 10 revs_number = (revs_number * 10) + remainder number = number // 10 print("The reverse number is :",revs_number) num = input("Enter the first number:") reverse = '' for i in range(len(num), 0, -1): reverse += num[i-1] print('The reverse number is =', reverse) Prac 4 #list subjects =[] subjects.append('Python') subjects.append('ETDS') print(subjects) A = [2, 33, 1, 0] B = [22, 3, 0, -2] A.append(8) print(A) A.sort() print(A) A.insert(3,15) print(A) A.sort(reverse=True) print(A) #set my_set = {1, 2, 3, 4, 5} print("Original Set:", my_set) my_set.add(6) my_set.update([7, 8, 9]) print("Modified Set:", my_set) my_set.remove(3) my_set.discard(8) print("Final Set:", my_set) set1 = {1, 2, 3, 4, 5} set2 = {3, 4, 5, 6, 7} union_set = set1.union(set2) print("Union Set:", union_set) intersection_set = set1.intersection(set2) print("Intersection Set:", intersection_set) difference_set = set1.difference(set2) print("Difference Set (set1 - set2):", difference_set) symmetric_difference_set = set1.symmetric_difference(set2) print("Symmetric Difference Set:", symmetric_difference_set) #dictionary student = { 'name': 'Prayag', 'age': 30, 'grades': {'math': 90, 'history': 85, 'english': 95}, 'courses': ['math', 'history', 'english'] } print("Student Name:", student['name']) print("Student Age:", student['age']) print("Math Grade:", student['grades']['math']) student['age'] = 21 student['grades']['english'] = 92 student['gender'] = 'Male' print("\nUpdated Student Information:") print(student) print("\nIterating over Keys:") for key in student.keys(): print(key) print("\nIterating over Values:") for value in student.values(): print(value) print("\nIterating over Key-Value Pairs:") for key, value in student.items(): print(f"{key}: {value}") Prac 7 import matplotlib.pyplot as mp import pandas as pd import seaborn as sb data = pd.read_excel("/content/dataset.csv.xlsx") print(data.corr()) dataplot = sb.heatmap(data.corr(), cmap="YlGnBu", annot=True) mp.show() Data set CustomerID Gender Age Annual Income (k$) Spending Score (1-100) 1 Male 19 15 39 2 Male 21 15 81 3 Female 20 16 6 4 Female 23 16 77 5 Female 31 17 40 6 Female 22 17 76 7 Female 35 18 6 8 Male 23 18 94 9 Male 64 19 3 10 Female 30 19 72 11 Male 67 20 14 12 Female 35 20 99 13 Female 58 21 15 14 Male 24 21 77 15 Male 37 22 13 Prac 8 import pandas as pd dataset_path = '/content/Data_Wrangling.csv' df = pd.read_csv(dataset_path) print("Shape of the dataset:", df.shape) print("Dimensions of the dataset:", df.ndim) print("Column names:", df.columns) print("\nHead of the dataset:") print(df.head()) column_number = 3 column_name = 'Age' selected_data_column_number = df.iloc[:, column_number] selected_data_column_name = df[column_name] selected_data_condition = df[df['Age'] > 30] selected_data_compound_condition = df[(df['Age'] > 25) & (df['Spending Score (1-100)'] > 50)] df.fillna(df.mean(numeric_only=True), inplace=True) df.to_csv('modified_dataset.xlsx', index=False) Prac 9 import pandas as pd df = pd.read_csv('/content/Data_Wrangling.csv') group_gender = df.groupby('Gender').mean(numeric_only=True) print("Mean values grouped by Gender:") print(group_gender) group_age = df.groupby('Age')['Spending Score (1-100)'].mean() print("\nAverage Spending Score by Age:") print(group_age) group_income = df.groupby('Annual Income (k$)').agg({ 'Age': 'mean', 'Spending Score (1-100)': ['mean', 'max', 'min'] }) print("\nSummary statistics grouped by Annual Income:") print(group_income) summary = df.groupby('Gender').agg( Avg_Age=('Age', 'mean'), Max_Income=('Annual Income (k$)', 'max'), Min_Income=('Annual Income (k$)', 'min'), Avg_Spending=('Spending Score (1-100)', 'mean') ) print("\nCombined summary grouped by Gender:") print(summary) summary.describe() Prac 10 import pandas as pd import matplotlib.pyplot as plt import seaborn as sns df = pd.read_csv('/content/Data_Wrangling.csv') print("Shape of dataset:", df.shape) print("Dimensions of dataset:", df.ndim) print("Column names:", df.columns) print("\nFirst 5 records:") print(df.head()) plt.figure() sns.histplot(df['Age'], bins=10, kde=True) plt.title("Age Distribution") plt.xlabel("Age") plt.ylabel("Frequency") plt.show() plt.figure() sns.boxplot(x=df['Spending Score (1-100)']) plt.title("Spending Score") plt.show() plt.figure() sns.scatterplot(x='Age', y='Spending Score (1-100)', data=df) plt.title("Age vs Spending Score") plt.xlabel("Age") plt.ylabel("Spending Score") plt.show() plt.figure() sns.barplot(x='Gender', y='Spending Score (1-100)', data=df) plt.title("Gender vs Spending Score") plt.show() sns.pairplot(df[['Age', 'Annual Income (k$)', 'Spending Score (1-100)']]) plt.show() plt.figure() corr = df.corr(numeric_only=True) sns.heatmap(corr, annot=True, cmap="coolwarm") plt.title("Correlation Heatmap") plt.show() Consider the following Comcast_telecom dataset and import the same: 1. 2. 3. 4. 5. 6. Print the number of records and number of columns. Separate the numerical and categorical data types. Print the number of complains as per the type of status Print the records of the complaints received via “Internet” Print the name of the state which received the maximum number of complaints. Print the records of the customers from city “Atlanta” where complaints are received via “Customer Care Call” 7. Drop the ticket# 8. 9. 10. Print the number of open and closed complaints as per the “Zipcode” Print the names of the columns Print the second and third column —----------------- Sample Dataset —--------------------- Ticket #,Customer Complaint,Date,Time,Received Via,Status,State,City,Zipcode 1001,Internet speed issues,01-01-2023,10:30,Internet,Open,Georgia,Atlanta,30301 1002,Billing complaint,02-01-2023,11:00,Customer Care Call,Closed,T exas,Dallas,75001 1003,No signal,03-01-2023,09:45,Internet,Open,California,Los Angeles,90001 import pandas as pd # Import dataset df = pd.read_csv("Comcast_telecom.csv") # 1. Number of records and columns print("Records:" , df.shape[0]) print("Columns:" , df.shape[1]) # 2. Separate numerical and categorical columns numerical_cols = df.select_dtypes(include= 'number') categorical_cols = df.select_dtypes(include= 'object') print("\nNumerical Columns:\n" , numerical_cols.columns) print("\nCategorical Columns:\n" , categorical_cols.columns) # 3. Number of complaints per Status print("\nComplaints per Status:\n" , df['Status'].value_counts()) # 4. Complaints received via Internet internet_complaints = df[df['Received Via'] == 'Internet'] print("\nComplaints via Internet:\n" , internet_complaints) # 5. State with maximum complaints Perform following using Python: 11. Create a data frame “df_emp” with a minimum of 10 records of employees displaying employee id, employee name, salary, designation. 12. Calculate and display the basic descriptive statistics of column – salary # Create employee dataframe df_emp = pd.DataFrame({ 'Emp_ID': [101,102,103,104,105,106,107,108,109,110], 'Emp_Name': ['Alice' 'Bob' 'Charlie' 'David' 'Eva' 'Frank' 'Grace' 'Helen' 'Ian' , , , , , , , , , 'Jack'], 'Salary': [50000,55000,60000,52000,58000,62000,65000,70000,72000,75000], 'Designation': ['Analyst' , 'Developer' , 'Developer' , 'Analyst' 'HR' , , 'Manager' , 'Manager' 'Lead' 'Lead' , , , 'Director'] }) print(df_emp) print("\nSalary Statistics:\n" , df_emp['Salary'].describe()) import the online retail dataset i. Print the number of rows and columns ii. Print the column names iii. Print the data types iv. Print the InvoiceNo, and count of products per invoice v. Print CustomerID and average UnitPrice. vi. Print the Description and InvoiceDate of products sold either in the United Kingdom or Denmark. vii. ix. x. Perform univariate analysis on the UnitPrice. viii. Calculate the outliers with statistics for the UnitPrice column Print the records of products which are outliers as per their UnitPrice Plot a boxplot for the Quantity column —----------------- Sample Dataset —--------------------- InvoiceNo,StockCode,Description,Quantity,InvoiceDate,UnitPrice,CustomerID,Country 536365,85123A,White Hanging Heart T -Light Holder,6,01-12-2010 08:26,2.55,17850,United Kingdom 536365,71053,White Metal Lantern,6,01-12-2010 08:26,3.39,17850,United Kingdom 536366,84406B,Cream Cupid Hearts Coat Hanger,8,01-12-2010 08:28,2.75,13047,Denmark import pandas as pd import matplotlib.pyplot as plt # Import dataset df = pd.read_csv("Online_Retail.csv") # 1. Number of rows and columns print("Rows:" , df.shape[0]) print("Columns:" , df.shape[1]) # 2. Column names print("\nColumn Names:\n" , df.columns.tolist()) # 3. Data types print("\nData Types:\n" , df.dtypes) # 4. InvoiceNo and count of products per invoice print("\nProducts per Invoice:\n" , df.groupby('InvoiceNo')['StockCode'].count()) # 5. CustomerID and average UnitPrice print("\nAverage UnitPrice per Customer:\n" , df.groupby('CustomerID')['UnitPrice'].mean()) # 6. Description and InvoiceDate for UK or Denmark uk_denmark = df[df['Country'].isin(['United Kingdom ' , print("\nProducts sold in UK or Denmark:\n" , uk_denmark[['Description' , 'InvoiceDate']]) # 7. Univariate analysis on UnitPrice print("\nUnitPrice – Univariate Analysis:\n" , df['UnitPrice'].describe()) # 8. Calculate outliers using IQR Q1 = df['UnitPrice'].quantile(0.25) Q3 = df['UnitPrice'].quantile(0.75) IQR = Q3 - Q1 lower_bound = Q1 - 1.5 * IQR upper_bound = Q3 + 1.5 * IQR print("\nOutlier Statistics:") print("Q1:" , Q1) print("Q3:" , Q3) print("IQR:" , IQR) print("Lower Bound:" , lower_bound) print("Upper Bound:" , upper_bound) # 9. Records with outlier UnitPrice 'Denmark'])] outliers = df[(df['UnitPrice'] < lower_bound) | (df['UnitPrice'] > upper_bound)] print("\nOutlier Records based on UnitPrice:\n" , outliers) # 10. Boxplot for Quantity plt.boxplot(df['Quantity']) plt.title("Boxplot of Quantity") plt.ylabel("Quantity") plt.show() Consider the diabetes dataset and perform the following queries in Python: 1. Print the correlation matrix, and write inferences on the factors(columns) which influence BMI. 2. 3. Print the number of patients who have diabetes in the dataset(1 for outcome) Print the records of the patients who have BMI between 35 to 40 4. Print the “BloodPressure” , ”BMI” and “Outcome” of patients who have “BloodPressure” more than 100. 5. Perform a univariate analysis on the column Age. Visualize using histogram, kdeplot and boxplot. Write inferences, 6. Calculate the outliers with statistics for the column BMI. Print a boxplot to validate the answer. 7. Plot a bar chart showing the “pregnancies” count separately for diabetic and non-diabetic patients. 8. 9. Show the relation between “Glucose” and “DiabetesPedigreeFunction” . Print the records of the patients who are either diabetic or have glucose level more than 150. —----------------- Sample Dataset —--------------------- Pregnancies,Glucose,BloodPressure,SkinThickness,Insulin,BMI,DiabetesPedigreeFunction,Age,Outco me 6,148,72,35,0,33.6,0.627,50,1 1,85,66,29,0,26.6,0.351,31,0 8,183,64,0,0,23.3,0.672,32,1 # ============================== # Diabetes Dataset – Full Analysis # ============================== import pandas as pd import matplotlib.pyplot as plt import seaborn as sns # ------------------------------ # Load Dataset # ------------------------------ df = pd.read_csv("diabetes.csv") # ------------------------------ # 1. Correlation Matrix # ------------------------------ corr_matrix = df.corr() print("\nCorrelation Matrix:\n") print(corr_matrix) # Inference (for exam): # BMI has positive correlation with Glucose, BloodPressure and Outcome, # indicating higher BMI increases diabetes risk. # ------------------------------ # 2. Number of Diabetic Patients # ------------------------------ print("\nNumber of diabetic patients (Outcome = 1):") print(df['Outcome'].value_counts()[1]) # ------------------------------ # 3. Patients with BMI between 35 and 40 # ------------------------------ print("\nPatients with BMI between 35 and 40:\n") print(df[(df['BMI'] >= 35) & (df['BMI'] <= 40)]) # ------------------------------ # 4. BP > 100 BloodPressure, BMI, Outcome # ------------------------------ print("\nPatients with BloodPressure > 100:\n") print(df[df['BloodPressure'] > 100][['BloodPressure' , 'BMI' , 'Outcome']]) # ------------------------------ # 5. Univariate Analysis on Age # ------------------------------ # Histogram plt.hist(df['Age'], bins=6) plt.title("Histogram of Age") plt.xlabel(" Age") plt.ylabel("Frequency") plt.show() # KDE Plot sns.kdeplot(df['Age'], fill=True) plt.title("KDE Plot of Age") plt.show() # Boxplot plt.boxplot(df['Age']) plt.title("Boxplot of Age") plt.ylabel(" Age") plt.show() # Inference: # Most patients are aged between 25–50 years. # Distribution is slightly right skewed. # Some higher-age outliers are present. # ------------------------------ # 6. BMI Outliers using IQR # ------------------------------ Q1 = df['BMI'].quantile(0.25) Q3 = df['BMI'].quantile(0.75) IQR = Q3 - Q1 lower_bound = Q1 - 1.5 * IQR upper_bound = Q3 + 1.5 * IQR print("\nBMI Outlier Statistics:") print("Q1:" , Q1) print("Q3:" , Q3) print("IQR:" , IQR) print("Lower Bound:" , lower_bound) print("Upper Bound:" , upper_bound) # Boxplot to validate outliers plt.boxplot(df['BMI']) plt.title("Boxplot of BMI") plt.ylabel("BMI") plt.show() # ------------------------------ # 7. Bar Chart – Pregnancies vs Outcome # ------------------------------ df.groupby('Outcome')['Pregnancies'].sum().plot(kind= 'bar') plt.title("Pregnancies Count (Diabetic vs Non-Diabetic)") plt.xlabel("Outcome (0 = Non-Diabetic, 1 = Diabetic)") plt.ylabel("T otal Pregnancies") plt.show() # ------------------------------ # 8. Relationship: Glucose vs DiabetesPedigreeFunction # ------------------------------ plt.scatter(df['Glucose'], df['DiabetesPedigreeFunction']) plt.title("Glucose vs DiabetesPedigreeFunction") plt.xlabel("Glucose") plt.ylabel("DiabetesPedigreeFunction") plt.show() # ------------------------------ # 9. Diabetic OR Glucose > 150 # ------------------------------ print("\nPatients who are diabetic OR have Glucose > 150:\n") print(df[(df['Outcome'] == 1) | (df['Glucose'] > 150)]) Consider the Boston dataset and import it. 1. Print the records where "medv" ranges between 10 to 15 k dollars. 2. Print the price (medv) and crime rate(crim) of property which are on the bank of river charles(chas) 3. Print the correlation matrix of all the columns. 4. Print the data types 5. Print the average price of the property as per "chas" 6. Print histogram and kdeplot for the columns "lstat" and "crim" . Write inferences. 7. Print the boxplot for the column "nox" . 8. Filter the records which are outliers which belong to the column "medv" which denotes the price of property. 9. Print the average crime rate(crim) as per the number of radial highways connected to the property (rad) crim,zn,indus,chas,nox,rm,age,dis,rad,tax,ptratio,b,lstat,medv 0.00632,18.0,2.31,0,0.538,6.575,65.2,4.09,1,296,15.3,396.9,4.98,24.0 0.02731,0.0,7.07,0,0.469,6.421,78.9,4.9671,2,242,17.8,396.9,9.14,21.6 0.02729,0.0,7.07,0,0.469,7.185,61.1,4.9671,2,242,17.8,392.83,4.03,34.7 # ================================== # Boston Housing Dataset – Full Code # ================================== import pandas as pd import matplotlib.pyplot as plt import seaborn as sns # ------------------------------ # Load Dataset # ------------------------------ df = pd.read_csv("boston.csv") # ------------------------------ # 1. Records where MEDV between 10 and 15 # ------------------------------ print("\nProperties with MEDV between 10 and 15:\n") print(df[(df['medv'] >= 10) & (df['medv'] <= 15)]) # ------------------------------ # 2. MEDV and CRIM for properties on Charles River # ------------------------------ print("\nProperties on Charles River (CHAS = 1):\n") print(df[df['chas'] == 1][['medv' , 'crim ']]) # ------------------------------ # 3. Correlation Matrix # ------------------------------ print("\nCorrelation Matrix:\n") print(df.corr()) # ------------------------------ # 4. Data Types # ------------------------------ print("\nData Types:\n") print(df.dtypes) # ------------------------------ # 5. Average Property Price per CHAS # ------------------------------ print("\nAverage MEDV as per CHAS:\n") print(df.groupby('chas')['medv'].mean()) # ------------------------------ # 6. Histogram & KDE for LSTA T # ------------------------------ plt.hist(df['lstat'], bins=6) plt.title("Histogram of LSTA T") plt.xlabel("LSTA T") plt.ylabel("Frequency") plt.show() sns.kdeplot(df['lstat'], fill=True) plt.title("KDE Plot of LSTA T") plt.show() # Inference: # LSTA T is right-skewed. # Higher LSTA T values indicate lower house prices. # ------------------------------ # 7. Histogram & KDE for CRIM # ------------------------------ plt.hist(df['crim '], bins=6) plt.title("Histogram of CRIM") plt.xlabel("CRIM") plt.ylabel("Frequency") plt.show() sns.kdeplot(df['crim '], fill=True) plt.title("KDE Plot of CRIM") plt.show() # Inference: # Crime rate is highly right-skewed. # Most properties have low crime rates with few high-crime outliers. # ------------------------------ # 8. Boxplot for NOX # ------------------------------ plt.boxplot(df['nox']) plt.title("Boxplot of NOX") plt.ylabel("NOX") plt.show() # ------------------------------ # 9. Outliers in MEDV using IQR # ------------------------------ Q1 = df['medv'].quantile(0.25) Q3 = df['medv'].quantile(0.75) IQR = Q3 - Q1 lower_bound = Q1 - 1.5 * IQR upper_bound = Q3 + 1.5 * IQR print("\nMEDV Outlier Bounds:") print("Lower Bound:" , lower_bound) print("Upper Bound:" , upper_bound) print("\nMEDV Outlier Records:\n") print(df[(df['medv'] < lower_bound) | (df['medv'] > upper_bound)]) # ------------------------------ # 10. Average CRIM as per RAD # ------------------------------ print("\nAverage Crime Rate per RAD:\n") print(df.groupby('rad')['crim '].mean()) Print the descriptive statistics like mean, median etc for the column "indus" # Descriptive statistics for INDUS print("\nDescriptive Statistics for INDUS:\n") print(df['indus'].describe()) # Median (explicitly, for exam clarity) print("\nMedian of INDUS:" , df['indus'].median()) i. ii. iii. v. vi. vii. Create the above data frame “df_account” Print the second and third columns Print the 4th to 7th rows iv. Print the column names Print the records where balance is between 30 to 40 k Print the records where type is Savings Branch is “B04” Print the average Balance Branchwise viii. Plot a bar plot showing the number of Accounts per Branch. AcNo CustID Type BranchID Balance A00023 C02 Savings B04 90000 A00121 C01 Current B01 80567 A00234 C02 Current B04 12000 A01208 C06 Current B02 45000 A01208 C01 Current B02 45000 A00789 C04 Savings B04 4500 A00893 C05 Savings B06 67900 A00987 C03 Current B02 78600 # ============================== # Account DataFrame – Full Code # ============================== import pandas as pd import matplotlib.pyplot as plt # ------------------------------ # Create df_account DataFrame # ------------------------------ df_account = pd.DataFrame({ 'AcNo': ['A00023' 'A00121' 'A00234' 'A01208' 'A01208' 'A00789' 'A00893' , , , , , , , 'A00987'], 'CustID': ['C02' 'C01' 'C02' 'C06' 'C01' 'C04' 'C05' , , , , , , , 'C03'], 'Type': ['Savings' 'Current' 'Current' 'Current' 'Current' , , , , , 'Savings' , 'Savings' , 'Current'], 'BranchID': ['B04' 'B01' 'B04' 'B02' 'B02' 'B04' 'B06' , , , , , , , 'B02'], 'Balance': [90000,80567,12000,45000,45000,4500,67900,78600] }) print("\nAccount DataFrame:\n") print(df_account) # ------------------------------ # 1. Print second and third columns # ------------------------------ print("\nSecond and Third Columns:\n") print(df_account.iloc[:, 1:3]) # ------------------------------ # 2. Print 4th to 7th rows # ------------------------------ print("\n4th to 7th Rows:\n") print(df_account.iloc[3:7]) # ------------------------------ # 3. Print column names # ------------------------------ print("\nColumn Names:\n") print(df_account.columns.tolist()) # ------------------------------ # 4. Balance between 30k and 40k # ------------------------------ print("\nRecords with Balance between 30k and 40k:\n") print(df_account[(df_account['Balance'] >= 30000) & (df_account['Balance'] <= 40000)]) # ------------------------------ # 5. Type = Savings and Branch = B04 # ------------------------------ print("\nSavings Accounts in Branch B04:\n") print(df_account[(df_account['Type'] == 'Savings') & (df_account['BranchID'] == 'B04')]) # ------------------------------ # 6. Average Balance Branch-wise # ------------------------------ print("\nAverage Balance Branch-wise:\n") print(df_account.groupby('BranchID')['Balance'].mean()) # ------------------------------ # 7. Bar Plot – Number of Accounts per Branch # ------------------------------ df_account['BranchID'].value_counts().plot(kind= 'bar') plt.title("Number of Accounts per Branch") plt.xlabel("BranchID") plt.ylabel("Number of Accounts") plt.show() 1. 2. Write a Python program to accept inputs from users at run time and perform any 5 arithmetic operations. a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) print(" Addition:" , a + b) print("Subtraction:" , a - b) print("Multiplication:" , a * b) print("Division:" , a / b) print("Modulus:" , a % b) Accept a number from the user and print the sum of its digits 3. 4. 5. num = int(input("Enter a number: ")) sum_digits = 0 while num > 0: sum_digits += num % 10 num / /= 10 print("Sum of digits:" , sum_digits) Write a program to compare 3 numbers and print the largest one using logical operators. a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) c = int(input("Enter third number: ")) if a >= b and a >= c: print("Largest:" , a) elif b >= a and b >= c: print("Largest:" , b) else: print("Largest:" , c) Write a function to accept a number from user and print the factorial def factorial(n): fact = 1 for i in range(1, n + 1): fact *= i print("Factorial:" , fact) num = int(input("Enter a number: ")) factorial(num) Write a Python program to accept inputs from users at run time and perform any 5 arithmetic operations x = float(input("Enter first number: ")) y = float(input("Enter second number: ")) print(" Add:" , x + y) print("Subtract:" , x - y) print("Multiply:" , x * y) print("Divide:" , x / y) print("Power:" , x ** y) 6. 7. 8. 9. Calculate the distance between two points using the lambda function. FORMULA: √(〖 (x1- x2)〗^(2 )+〖 (y1-y2)〗^2 ) import math distance = lambda x1, y1, x2, y2: math.sqrt((x1 - x2)**2 + (y1 - y2)**2) x1 = int(input("Enter x1: ")) y1 = int(input("Enter y1: ")) x2 = int(input("Enter x2: ")) y2 = int(input("Enter y2: ")) print("Distance:" , distance(x1, y1, x2, y2)) Write a program to check if a given number is even or not using while loop num = int(input("Enter a number: ")) while num >= 0: if num % 2 == 0: print("Even") else: print("Odd") break Write a function dynsum() to accept a dynamic variable list of numbers from the user and calculate the sum of the numbers. def dynsum(*args): print("Sum:" , sum(args)) dynsum(10, 20, 30, 40) Write a program to create the following Sets in Python. A. 10,15,34,89,90 B. 2,4,6,10,15,30,40,90 set1 = {10, 15, 34, 89, 90} set2 = {2, 4, 6, 10, 15, 30, 40, 90} print("Union:" , set1 | set2) print("Intersection:" , set1 & set2) print("Difference (set1 - set2):" , set1 - set2) print("Symmetric Difference:" , set1 ^ set2) 10. Also perform Union ,Intersection ,difference and symmetric difference operations on the same. # Create the sets set1 = {10, 15, 34, 89, 90} 11. 12. 13. set2 = {2, 4, 6, 10, 15, 30, 40, 90} print("Set 1:" , set1) print("Set 2:" , set2) # Union print("\nUnion:") print(set1.union(set2)) # Intersection print("\nIntersection:") print(set1.intersection(set2)) # Difference print("\nDifference (Set1 - Set2):") print(set1.difference(set2)) print("\nDifference (Set2 - Set1):") print(set2.difference(set1)) # Symmetric Difference print("\nSymmetric Difference:") print(set1.symmetric_difference(set2)) Accept 10 numbers from the user and print the average. total = 0 for i in range(10): num = int(input(f"Enter number {i+1}: ")) total += num print(" Average:" , total / 10) Accept a number from the user and print its even or odd using lambda function. check = lambda x: "Even" if x % 2 == 0 else "Odd" num = int(input("Enter a number: ")) print(check(num)) Write a program to print the factors of a number taken from the user. num = int(input("Enter a number: ")) print("Factors are:") for i in range(1, num + 1): if num % i == 0: print(i)