Lab 1to7
Lab 1to7
#Code 2
#Variable Declaration
x=1
#to print the data type
print(type(x))
#For Printing
print(x)
#Code 3
#Variable Declaration
x = 5.23
#to print the data type
print(type(x))
#For Printing
print(x)
LAB 2
Topic Data Type and Print
Discussion 1.String
2.Boolean
Work on the computer #Variable Declaration
#Code 1
#String
#more line String input
a = '''Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.'''
#for Single Line output
b = "\nHello world"
print(a)
print(b)
#Code 2
x = True
y= False
print(type(x))
print(x)
print(y)
LAB 3
Topic Arithmetic Expression and input
Discussion 1.Arithmatic Expression (+ ,- ,/ ,* ,%)
2.Input
Work on the computer # Addition
a=5
b=3
addition = a + b
print(f"Addition: {a} + {b} = {addition}")
# Subtraction
subtraction = a - b
print(f"Subtraction: {a} - {b} =
{subtraction}")
# Multiplication
multiplication = a * b
print(f"Multiplication: {a} * {b} =
{multiplication}")
# Division
division = a / b
print(f"Division: {a} / {b} = {division}")
# Floor Division
floor_division = a // b
print(f"Floor Division: {a} // {b} =
{floor_division}")
# Modulus
modulus = a % b
print(f"Modulus: {a} % {b} = {modulus}")
#Input
# Integer input age = int(input("Enter your
age: ")) print(f"Your age is {age}.")
# Float input
weight = float(input("Enter your weight in kg:
")) print(f"Your weight is {weight} kg.")
# String input
name = input("Enter your name: ")
print(f"Hello, {name}!")
LAB 4
Topic If else and Relational operation
Discussion 1.if else
2.Relational operation (< ,>,==,!=,<= ,>=)
Work on the computer # Input: age and weight
#code 1
age = int(input("Enter your age: "))
weight = float(input("Enter your weight in kg:
"))
#Code 2
# Less than or equal to, greater than or equal
to
age = int(input("Enter your age: "))
weight = float(input("Enter your weight in kg:
"))
if age <= 25:
print("You are 25 years old or younger.")
else:
print("You are older than 25.")
LAB 5
Topic If else and logical operation
Discussion 1.if else
2.logical operation (or , and , not )
Work on the computer # Input: age and weight
age = int(input("Enter your age: "))
weight = float(input("Enter your weight in kg:
"))
# Combining relational and logical operations
if age >= 18 and weight < 60:
print("\nYou are an adult and weigh less
than 60 kg.")
else:
print("You weight is more than 60 or your
age is less than 18 years old .")
LAB 6
Topic If elif else , logical operation ,Relational
Operation
Discussion 1.if elif else
2. operations
Work on the computer # Input: temperature and humidity
temperature = float(input("Enter the
temperature in Celsius: "))
humidity = float(input("Enter the humidity
percentage: "))
LAB 7
Topic If elif else , logical operation ,Relational
Operation ,input and arithmetic expression
Discussion 1. If , elif , else ,
2. logical operation ,
3. Relational Operation ,
4. input
5. arithmetic expression
Work on the computer # Input: temperature in Celsius
temperature_celsius = float(input("Enter the
temperature in Celsius: "))