You are on page 1of 3

Assignment4

Name: shroog ghilab Alharbi


ID: 1917238

Q1 (1mark): Create a function that can accept two arguments name and
age and print its value
def student(nam,age):
print ('Name is:',nam)
print ('Age is:',age)

Q2(1 marks): Invoke the function you wrote in Q1.


student('ahmed',20)

Q3(2 marks): If you have the following snippet:


def multia(a, b):
print(a * b)
What will the output be for the following instructions?
a) multia (5, b=2)
10

CIT221 1st Semester/2022 Abeer Aziz


b) multia(a=2, 2)
error

Q4(1 mark) Suppose a dictionary days is declared as:


days={1:"Sun", 2:"Mon", 3:"Wed"}

Write a statement in Python to change Wed to Tue.

days={1:"Sun", 2:"Mon", 3:"Wed"}


days[3]='Tue'
print (days)

CIT221 1st Semester/2022 Abeer Aziz


Q5(1 mark) print the count of the number of occurrences of item 50 from a
tuple
Given: tuple1 = (50, 10, 60, 70, 50)
Expected output: 2
y=0
tuple1 = (50, 10, 60, 70, 50)
for x in tuple1:
if x == 50:
y = y +1

print(y)

CIT221 1st Semester/2022 Abeer Aziz

You might also like