In: Computer Science
1) Use Python to answer the below questions.
a) What is the output of the following python code?
def function(x):
return x * 5
print(func(7) * func(5))
b) What is the output of the following code fragment?
required_course = "Programming", "Security",
"Cybersecurity"
a,b,c =
required_course
print(b)
ANSWER 1 : Output is 875
#CREATING A FUNCTION NAMED AS func
def func(x):
#MULTIPLYING VALUE OF X INTO 5
return x*5
#PASSING THE VALUE OF X ONE BY ONE TO THE FUNCTION func AND THEN
#FINALLY PRINTING THE FINAL VALUE OF X
print((func(7)*func(5)))
Output :
WORKING :
7*5=35
5*5=25
35*25=875
ANSWER 2 : Output is "Security".
#Adding 3 string into a variable
required_course = "Programming", "Security", "Cybersecurity"
#adding the values of required_course into
#new variables a, b and c
a,b,c = required_course
# Printing the value of b variable
print(b)
Output :
WORKING :
required_course = "Programming", "Security", "Cybersecurity"
a= "Programming"
b= "Security"
c= "Cybersecurity"
print(b)
O/P = Security