You are on page 1of 3

UNIVERSITY OF ENGINEERING

AND TECHNOLOGY
MARDAN

LAB TASKS – 01

NAME : HAROON MASIH


REG NO : 19MDBCS040
SUBJECT : AI LAB
BATCH : 2ND
DEPARTMENT: COMPUTER SCIENCE
1) If statement:

a = 33
b = 200
if b > a:
  print ("b is greater than a")

Output:
b is greater than a

2) String:

a = "Hello"
print (a)

Output:
Hello

3) Rang Function:

Create a sequence of numbers from 0 to 5, and print each item in the


sequence:

x = range (6)
for n in x:
  print(n)

Output:
0
1
2
3
4
5

4) List:

lst = ["apple", "banana", "cherry"]
print(lst)

Output:

['apple', 'banana', 'cherry']

5) Nested Loop:
Print each adjective for every fruit:

adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]

for x in adj:
  for y in fruits:
    print(x, y)

Output:

red apple
red banana
red cherry
big apple
big banana
big cherry
tasty apple
tasty banana
tasty cherry

WHILE LOOP

i = 1
while i < 6:
  print(i)
  i += 1

Output:
1
2
3
4
5

FOR LOOP

fruits = ["apple", "banana", "cherry"]
for x in fruits:
  print(x)

Output:

apple
banana
cherry

You might also like