Practical_1: Variables and Assignments#
Exercise 1:#
Declare a variable x
and assign it the value 10
.
# Exercise 1
Exercise 2:#
Assign the value True
to a variable called is_valid
.
# Exercise 2
Exercise 3:#
Create a string variable name
with the value “Python Programming”.
# Exercise 3
Exercise 4:#
Assign the result of 5 + 3
to a variable sum_result
.
# Exercise 4
Exercise 5:#
Assign multiple variables in one line: a = 5
, b = 10
, c = 15
.
# Exercise 5
Exercise 6:#
Assign the value of one variable x
to another variable y
.
# Exercise 6
Exercise 7:#
Assign a floating-point number 9.8
to a variable gravity
.
# Exercise 7
Exercise 8:#
Create a variable country
and assign it the string value of your favorite country.
# Exercise 8
Exercise 9:#
Change the value of variable age
from 25
to 26
in two separate steps.
# Exercise 9
Exercise 10:#
Use one variable to store the result of subtracting two numbers 20 - 7
.
# Exercise 10
Exercise 11:#
Assign an integer value and a floating-point value to two different variables.
# Exercise 11
Exercise 12:#
Assign a boolean value False
to a variable is_completed
.
# Exercise 12
Exercise 13:#
Swap the values of two variables x
and y
.
# Exercise 13
Exercise 14:#
Assign a complex number 3 + 4j
to a variable complex_num
.
# Exercise 14
Exercise 15:#
Reassign a variable from an integer to a string.
# Exercise 15
Exercise 16:#
Create two variables first_name
and last_name
, and assign them your first and last names.
# Exercise 16
Exercise 17:#
Create a variable temperature
and assign it the value of 35.5
.
# Exercise 17
Exercise 18:#
Assign the result of the multiplication of two numbers 8 * 6
to a variable product
.
# Exercise 18
Exercise 19:#
Assign a sentence of your choice to a variable sentence
.
# Exercise 19
Exercise 20:#
Use an assignment to convert a string '50'
into an integer variable int_value
.
# Exercise 20
Exercise 21:#
Assign the result of dividing 144
by 12
to a variable quotient
.
# Exercise 21
Exercise 22:#
Assign the remainder of 47 divided by 5
to a variable remainder
.
# Exercise 22
Exercise 23:#
Create a variable is_student
and assign it the value True
.
# Exercise 23
Exercise 24:#
Use a variable to store the result of a modulo operation: 45 % 4
.
# Exercise 24
Exercise 25:#
Create a variable pi
and assign it the value 3.14159
.
# Exercise 25
Exercise 26:#
Create two variables length
and width
, assign them values, and calculate the area of a rectangle.
# Exercise 26
Exercise 27:#
Assign a negative number to a variable negative_value
.
# Exercise 27
Exercise 28:#
Assign a string containing a special character (e.g., “Hello, World!”) to a variable greeting
.
# Exercise 28
Exercise 29:#
Create a variable population
and assign it a large integer value (in billions).
# Exercise 29
Exercise 30:#
Use a variable to store the result of raising 2
to the power of 8
.
# Exercise 30
Exercise 31:#
Assign a list of your favorite fruits to a variable fruits
.
# Exercise 31
Exercise 32:#
Assign a tuple of three numbers to a variable coordinates
.
# Exercise 32
Exercise 33:#
Assign a dictionary with keys name
and age
to a variable person
.
# Exercise 33
Exercise 34:#
Use variables to store the sum of two floating-point numbers.
# Exercise 34
Exercise 35:#
Create a variable is_sunny
and assign it the result of a comparison 10 > 5
.
# Exercise 35
Exercise 36:#
Assign a string and an integer to two different variables, then print both on one line.
# Exercise 36
Exercise 37:#
Reassign a variable that originally held a number to a boolean value.
# Exercise 37
Exercise 38:#
Create a variable is_weekend
and assign it the result of False
.
# Exercise 38
Exercise 39:#
Assign a multi-line string to a variable description
.
# Exercise 39
Exercise 40:#
Use variables to store the result of the absolute value of -25
.
# Exercise 40
Exercise 41:#
Assign the result of a floor division 100 // 6
to a variable floor_div_result
.
# Exercise 41
Exercise 42:#
Assign the result of adding a floating-point number to an integer to a variable mixed_sum
.
# Exercise 42
Exercise 43:#
Use variables to store a combination of string concatenation.
# Exercise 43
Exercise 44:#
Assign an empty list to a variable empty_list
.
# Exercise 44
Exercise 45:#
Assign a boolean value based on the comparison of two variables a = 10
and b = 15
.
# Exercise 45
Exercise 46:#
Assign a long sentence to a variable and count its characters using len()
.
# Exercise 46
Exercise 47:#
Assign a fractional result 7 / 3
to a variable division_result
.
# Exercise 47
Exercise 48:#
Create a variable speed
and assign it the value of 100 kilometers per hour.
# Exercise 48
Exercise 49:#
Assign a multi-variable equation like y = 3x + 5
where x = 4
to a variable y
.
# Exercise 49
Exercise 50:#
Use variables to calculate and store the average of three numbers.
# Exercise 50