algorithm
algorithm
----------------------------------------------------------------------------
Q2: Start.
Initialize an empty list.
Take input from the user to populate the list. Allow the user to stop input using a
specific keyword (e.g., "done").
Calculate:
Range: Difference between the maximum and minimum values.
Average Deviation: Average of the absolute differences between each value and
the mean.
Absolute Deviations: Absolute differences between each value and the mean.
Squared Deviations: Squared differences between each value and the mean.
Standard Deviation: Square root of the variance (mean of squared deviations).
Display the results.
End.
---------------------------------------------------------------------------------
Q3:Start.
-----------------------------------------------------------------------------------
--
Q4:
Start.
Declare variables for each data type: integer, float, string, boolean, list, tuple,
set, and dictionary.
Assign sample values to each variable.
For each variable:
Print its value.
Print its data type using type().
End.
-----------------------------------------------------------------------------------
Q5:
Start.
Declare variables to perform operations.
Demonstrate arithmetic operators:
Addition, subtraction, multiplication, division, modulus, exponentiation, and
floor division.
Demonstrate comparison operators:
Equality, inequality, greater than, less than, etc.
Demonstrate logical operators:
AND, OR, NOT.
Showcase operator precedence by combining multiple operators in an expression.
Print the results of all operations.
End.
-----------------------------------------------------------------------------------
--
Q6:
Start.
Declare example variables of different types (integer, float, string, boolean,
list, tuple, etc.).
Perform the following conversions:
Integer ↔ String
String ↔ Float
String ↔ Boolean
List ↔ Tuple
List ↔ Set
Print the results of each conversion.
End.
-----------------------------------------------------------------------------
Q7.
Start.
Prompt the user to enter their name.
Prompt the user to enter their age.
Print a greeting message using the provided name and age.
End.
-----------------------------------------------------------------------------
Q8:
Start.
Write single-line comments to explain specific parts of the code.
Write multi-line comments for a detailed explanation of the program or larger
sections of code.
Execute the program to validate its functionality.
End.
-----------------------------------------------------------------------------
Q9:
Start.
Import the built-in math module.
Prompt the user to input a number.
Calculate the square root of the number using the math.sqrt() function.
Print the square root result.
Print the value of π using math.pi.
End.
-----------------------------------------------------------------------------
Q10:
Start.
Demonstrate if-else:
Check if a number is positive, negative, or zero.
Demonstrate a for loop:
Print the elements of a list.
Demonstrate a while loop:
Count down from a given number to 1.
End.
-----------------------------------------------------------------------------
Q11:
Start.
Define a function named greet_user that:
Accepts a name as a parameter.
Prints a greeting message using the provided name.
Prompt the user to enter their name.
Call the greet_user function with the input name.
End.
-----------------------------------------------------------------------------
Q12:
Start.
Declare example variables and values for demonstration.
Demonstrate the use of:
abs(): To compute the absolute value of a number.
max(): To find the maximum value in a list.
min(): To find the minimum value in a list.
len(): To determine the length of a list.
round(): To round a float to the nearest integer (or to specified decimal
places).
Print the results of each function.
End.
---------------------------------------------------------------------------------
Q13:
Start.
Import the built-in random module.
Use the randint() function from the random module to generate a random integer in
the range 1 to 100.
Print the generated random number.
End.
---------------------------------------------------------------------------
Q14:
Start.
Create and open a file in write mode (w).
Write some data to the file.
Close the file.
Open the file in read mode (r) and read its content.
Open the file in append mode (a) and add new data.
Open the file again in read mode and read it line by line.
Close the file after each operation.
End.
------------------------------------------------------------------------------
Q15:
Start.
Import the necessary libraries: numpy, matplotlib, and sklearn.
Generate a dataset or load an existing one.
Use the K-Means algorithm to cluster the data into k groups.
Extract cluster centroids and labels from the K-Means model.
Visualize the clustered data points and their corresponding centroids on a scatter
plot.
End.