Assignment (4) dasdsd PDF

Title Assignment (4) dasdsd
Author ahmed gamal
Course Production technology
Institution جامعة القاهرة
Pages 2
File Size 285.1 KB
File Type PDF
Total Downloads 46
Total Views 182

Summary

dasdas 1123123 123sad asd123 23amdas das...


Description

COURSE: ADVANCED PROGRAMMING (ELC482E) LECTURER: DR. ALI ALLAM - DR. MOHAMED SOBHY TEACHING ASSISTANT: MS. MARY WILLIAM

ASSIGNMENT (4) 1. Write a program to print each of the following figures using "nested loops":

(a)

(b)

(c)

(d)

(e)

********** ********** ********** ********** **********

(f)

*+*+*+*+ *+*+*+*+ *+*+*+*+ *+*+*+*+ 12345678 XXXXXXXX 12345678 XXXXXXXX 12345678 XOXOXOXO OXOXOXOX XOXOXOXO OXOXOXOX XOXOXOXO OXOXOXOX XOXOXOXO OXOXOXOX * ** *** **** ***** ****** ******* ********

(g)

(h)

Bonus

XXXXXXXX XXXXXXX XXXXXX XXXXX XXXX XXX XX X * ** *** **** ***** **** *** ** * 1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 *************** ************** ************* ************ *********** ********** ********* ********

Page 1 of 2

COURSE: ADVANCED PROGRAMMING (ELC482E) LECTURER: DR. ALI ALLAM - DR. MOHAMED SOBHY TEACHING ASSISTANT: MS. MARY WILLIAM 2. Write a program that prints the multiplication table up to 10, for a number entered by the user. For example: Enter a number: 5 1 2 3 4 5 6 7 8 9 10 --------------------------------------------------------------------------------------------------------------1 1 2 3 4 5 6 7 8 9 10 2 2 4 6 8 10 12 14 16 18 20 3 3 6 9 12 15 18 21 24 27 30 4 4 8 12 16 20 24 28 32 36 40 5 5 10 15 20 25 30 35 40 45 50

3. Write a program that prints all the prime numbers below 100. A prime number is that which has exactly two different divisors (1 and itself). i.e. the program should print the following numbers: 2 3 5 7 11 …… 89 97. 4. Modify the previous program to print the first ten prime numbers, as follows: The first ten prime numbers are: 2 3 5 7 11 13 17 19 23 29

5. Trace each of the following programs and write down the expected output:

(a)

for j in range(1,4): for i in range (1,11): if i%3==0: print("*", end="") else: print("+", end="") print()

(c)

x=1 while(x=x): print("*", end="") y=y-1 print() x+=1

(b)

(d)

x=10 while(x>=1): y=1 while(y...


Similar Free PDFs