Ai Lab1
Ai Lab1
CSC-462
Lab Report#01
ACTIVITY OUTCOMES:
From this lab we are able to see the basic operations on strings and numbers, basic
use of conditionals and basic use of loops.
LAB ACTIVITY 09:Let us take an integer from user as input and check
whether the given value is even or not.
LAB ACTIVITY 10:
Let us modify the code to take an integer from user as input and check
whether the given value is even or odd. If the given value is not even then it
means that it will be odd. So here we need to use if-else statement an
demonstrated below.
Home Activities
Activity 1:
Write a Python code to accept marks of a student from 1-100 and display the grade
according to the following formula.
Grade F if marks are less than 50 Grade E if marks are between 50 to 60 Grade D
if marks are between 61 to 70 Grade C if marks are between 71 to 80 Grade B if
marks are between 81 to 90 Grade A if marks are between 91 to 100.
Code:
print("Enter Marks Obtained in 3 Elective Subjects: ")
A1 = int(input("First Elective Marks: "))
A2 = int(input("Second Elective Marks: "))
A3 = int(input("Third Elective Marks: "))
tot = A1+A2+A3
avg = tot/3
print ("Your average is", avg)
if avg>=91 and avg<=100: print("Your Grade is A")
elif avg>=81 and avg<90: print("Your Grade is B")
elif avg>=71 and avg<80: print("Your Grade is C")
elif avg>=61 and avg<70: print("Your Grade is D")
elif avg>=50 and avg<60: print("Your Grade is E")
elif avg>=0 and avg<50: print("Your Grade is F")
else: print("Invalid Input!")
Output:
Activity 2:
Write a program that takes a number from user and calculate the factorial of that
number.
Code:
Output:
Assignment:
Fibonacci series is that when you add the previous two numbers the next number is
formed. You have to start
from 0 and 1. E.g. 0+1=1
→ 1+1=2 → 1+2=3 →
2+3=5 → 3+5=8 →
5+8=13
So the series becomes 0 1
1 2 3 5 8 13 21 34 55
…………
Steps: You have to take an
input number that shows
how many terms to be
displayed. Then use loops
for displaying the
Fibonacci series up to that
term e.g. input no is =6
the output should be 0 1 1
235
Code:
Output:
Critical Analysis/Conclusion:
In this lab, we learnt about the basics of the python language and python SHELL.
We also performed the In lab activities and learned basic operations on string &
numbers; Also the basic uses of conditionals & loops. Then, further implemented
was what we got to know in our Home tasks using types of loops including if/else,
while and its further applications and uses.