Il 0% ha trovato utile questo documento (0 voti)
20 visualizzazioni14 pagine

Ai Lab1

Artificial Intelligence Coding Labs

Caricato da

maimoonaziz2003
Copyright
© © All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato DOCX, PDF, TXT o leggi online su Scribd
Il 0% ha trovato utile questo documento (0 voti)
20 visualizzazioni14 pagine

Ai Lab1

Artificial Intelligence Coding Labs

Caricato da

maimoonaziz2003
Copyright
© © All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato DOCX, PDF, TXT o leggi online su Scribd
Sei sulla pagina 1/ 14

Artificial Intelligence

CSC-462
Lab Report#01

Submitted Khalid Sayed Haleem


By: Maimoona Aziz
M. Bilal Babar
Registration FA20-BEE-086
No: FA20-BEE-094
FA20-BEE-105
Class: BEE-5B

Submitted Ms. Mehwish Mehmood


To:
LAB # 01 Introduction to Python – Data Structures
and Loops:
STATEMENT PURPOSE:
This lab is an introductory session on Python. It is a powerful object-oriented
programming language, comparable to Perl, Ruby, Scheme and Java. Some of
Python’s notable features are:
 Easy to use that makes it simple to get your first programs working.
 Easy to learn that makes it an excellent choice for beginners.
 Runs everywhere, including Mac OS X, Windows, Linux and Unix

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 02:


Display strings on screen.
LAB ACTIVITY 03:

LAB ACTIVITY 04:


Get an integer answer from division operation. Also get remainder of a
division operation in the output.
LAB ACTIVITY 05:
Calculate 43, 410, 429, 4150, 41000
LAB ACTIVITY 06:
Write following math expressions. Solve them by hand using operators’
precedence. Calculate their answers using Python. Match the results.

LAB ACTIVITY 07:


Combine numbers and text.
LAB ACTIVITY 08:
Take input from the keyboard and use it in your program.

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.

LAB ACTIVITY 11:


Calculate the sum of all the values between 0-10 using while loop.
LAB ACTIVITY 12:
Accept 5 integer values from user and display their sum. Draw
flowchart before coding in python.
LAB ACTIVITY 13:
Write a Python code to keep accepting integer values from user until 0 is
entered. Display sum of the given values.

LAB ACTIVITY 14:


Write a Python code to accept an integer value from user and check that
whether the given value is prime number or not.

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.

Potrebbero piacerti anche