You are on page 1of 2

Pharos University in Alexandria

Faculty Of Computer Science & Artificial Intelligent


Computer Science Department
Spring 2022 – 2023
Course Name: Introduction to AI
Course code: AI102
Lecturer: Dr. Sahar Ghanem
TA: Eng. Esraa Habiba - Eng. Saeed Zalat – Eng. Rowan Essam

Lab (10)
Revision Python

Question 1:
What is output of the following examples:
1. Print (14//4, 14%4, 14.0/4)
2. print (2*'No' + 3*'!')
print (2 * ('No' + 3*'!'))
3. print('how\nis it\nnow')
4. for z in [2, 4, 7, 9]:
print(z - 1)
5. def func(x):
return x - 1

print(func(3) * func(5))
6. print(list(range(3)))

Question 2:
Suppose you take a list of words from the user, wordList. Write Python
code that will write one line for each word, repeating that word twice.
For example if wordList is ['Jose', 'Sue', 'Ivan'], then your code would
print
Jose Jose
Sue Sue
Ivan Ivan
Question 3:

Question 4:
Write a python program that contains a function to calculate the factorial
of user input considering the factorial of zero and negative numbers.

You might also like