Cairo University**We aren't endorsed by this school
Course
SCIENCE 123
Subject
Computer Science
Date
Jan 7, 2025
Pages
3
Uploaded by CoachFogRook44
Cairo University –Institute Of Statistical Studies And Researches Academic Year: 2018-2019 Semester:1 Date: 08-12-2018 Level: Professional Diploma Computer system principles and programming Course code: SE102 Time: 1 Hours Model B # Exam. Sheets: 4 1Q1) Choose True or False. (5 Marks) 1.'a' == 'b' or 1 == 2 2.2 + 3 * 5 == 2 + (3 * 5) 3.True or False 4.Python syntax is case-sensitive 5.int(2.9) ==3 Q2) What is the output of the following Code? L=[2,4,6,8,5,6](5 Marks) 1.print (len(L)) 2.print (L[2]) 3.x = 0 for i in range(3): x = x + L[i] print (x)4.print (L[-2]) 5.print (L[2:4]) Q3) What is the output of the following Code(15 Marks) 1.def foo(m, n): if m == 0: return n + 1 elif m > 0 and n == 0: return foo(m-1, 1) elif m > 0 and n > 0: return foo(m-1, foo(m, n-1)) print(foo(1, 0)) print (foo(1, 1)) 2.i = 10 while i < 7: i = (i + 1) % 5 print(i) 3.def A(x): x = x + 5 def B(x): x = 12 x = 76 B(x) A(x) print (x)
24.number = 6 while number < 10: number += 3 print(number) 5.x = 10 if x < 7: print (x) x = 23 if x > 7: print (x) else: print (x + 1) 6.balance = 10 while True: if balance < 5: break balance = balance+1 print (balance) 7.def nPrint(message, n): while n > 0: print(message) n -= 2 nPrint('a', 4) 8.class test: def __init__(self,a): self.a=a def dislay(self): for i in range(3): print(self.a) obj=test("H") print (obj.a) 9.class t: def __init__(self): self.variable = 'Old' self.Change(self.variable) def Change(self, var): var = 'New' obj=t() obj.Change("C") print(obj.variable) 10.mysum=0 for i in range(1, 11, 2): mysum += i if mysum == 5: break mysum += 1 print(mysum)
3Q4) Answer the following Questions (7 Marks) 1.What is the decimal representation for the binary number (10010)2? 2.What is the binary representation for the decimal number (13)10? 3.What is the hexadecimal representation for the binary number (1011)2? 4.Is Java an interpreted or compiled Language? Justify your Answer. 5. Discuss multiple inheritance in Python. Q5) Write a program? (13Marks) 1.Print odd numbers from 1 to 100. 2.Write a Python class named triangle constructed by a three side length and a method which will compute the perimeter of the triangle (perimeter of the triangle= sum of its three sides). 3.Write a Python program to sum all the items in a list. 4.Write a Python function to determine the largest number. The function accept three integers values form the user.