Generalfx
Generalfx
5. Assign the values 20, 30, and 40 to the variables x, y, and z respectively in a
single line.
Question 2:
Question 3:
3.1 Write a Python script that demonstrates the use of the following types of operators:
comparison operators, logical operators, bitwise operators, membership operators, and
identity operators. Include examples of each type of operator and show how they can be
used in various expressions. Make sure to print the results of each operation to
demonstrate their functionality.
Question 4:
2. Use comparison operators to compare these variables and print the results:
• Check if c is equal to 5.
3. Use logical operators to combine multiple comparisons and print the results:
5. Use membership operators to check for the presence of elements in a list, then
print the results:
• Create a list with the values [7, 12, 5, 18, 25, 32].
• Assign d to be equal to a.
• Check if a is d.
• Check if a is not b.
• Check if x is y.
Question 5:
2. Create a list grades containing the following integer values: [85, 92, 78, 90, 88].
• "name": "Alice"
• "age": 25
• "height": 5.9
• If the average of the grades list is greater than 80, print "Average grade is
greater than 80".
6. Use a loop to iterate through the grades list and print each grade.
Question 6:
1. Create a list of dictionaries where each dictionary represents a student with the
following keys: "name", "age", and "grades". The "grades" key should hold a list
of grades.
• If a student's age is less than 20, skip the student using continue.
Question 7:
• Call the plot_data function to plot the generated data with the title
"Scatter Plot of Random Data".