0% found this document useful (0 votes)
23 views5 pages

Lab 1to7

lab notes

Uploaded by

musfiqul.showmik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views5 pages

Lab 1to7

lab notes

Uploaded by

musfiqul.showmik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

LAB 1

Topic Data Type and Print


` 1.int
2.Float
Work on the computer #Code 1
#Printing
print("Hello world")
#Printing with new line
print("Hello \n world ")

#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:
"))

# If-else statements and logical operations

# Checking if the person is a minor or an


adult
if age < 18:
print("You are a minor.")
else:
print("You are an adult.")

#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: "))

# Combining relational and logical operations


if temperature > 30 and humidity > 70:
print("\nIt's hot and humid.")
elif temperature <= 30 and humidity > 70:
print("\nIt's cool but humid.")
elif temperature > 30 and humidity <= 70:
print("\nIt's hot and dry.")
else:
print("\nIt's cool and dry.")

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: "))

# Convert Celsius to Fahrenheit


temperature_fahrenheit =
(temperature_celsius * 9/5) + 32
print(f"\nTemperature in Fahrenheit:
{temperature_fahrenheit:.2f}°F")

# Provide weather advice based on


temperature
if temperature_fahrenheit < 32:
print("It's freezing outside. Wear warm
clothes.")
elif temperature_fahrenheit >= 32 and
temperature_fahrenheit < 50:
print("It's cold outside. Bundle up!")
elif temperature_fahrenheit >= 50 and
temperature_fahrenheit < 70:
print("It's cool outside. A light jacket might
be enough.")
elif temperature_fahrenheit >= 70 and
temperature_fahrenheit < 90:
print("It's warm outside. Enjoy the pleasant
weather!")
else:
print("It's hot outside. Stay hydrated and
seek shade if needed.")

You might also like