Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
142 views5 pages

Assignment 3-1

The document provides instructions for Assignment 03 in Programming Fundamentals, including submission guidelines, a list of 16 programming questions to complete with details for each question, and notes to keep code files for later evaluation. Students are asked to write Python programs to solve problems related to Armstrong numbers, Fibonacci series, harmonic numbers, population growth modeling, number conversion, guessing games, loops, growth rates, lockers, HCF and LCM, patterns, and series sums. The assignment is due by January 6th, 2023.

Uploaded by

Tahir PGC
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views5 pages

Assignment 3-1

The document provides instructions for Assignment 03 in Programming Fundamentals, including submission guidelines, a list of 16 programming questions to complete with details for each question, and notes to keep code files for later evaluation. Students are asked to write Python programs to solve problems related to Armstrong numbers, Fibonacci series, harmonic numbers, population growth modeling, number conversion, guessing games, loops, growth rates, lockers, HCF and LCM, patterns, and series sums. The assignment is due by January 6th, 2023.

Uploaded by

Tahir PGC
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment 03

Programming Fundamentals-CS-1104
Fall 2022
Department of Software Engineering,
Faculty of Computer Science & Information
Technology,
The Superior University Gold Campus, Lahore.
Submission Deadline: Friday 11:59 PM, January 6 th , 2023
__________________________________________________
__
Question CLO Domian/BT Level Total Marks
1-16 4 C6 160

Advice and Submission Guidelines for Assignment

• Make sure that you read and understand each and every instruction. If you have
any questions or comments you are encouraged to discuss (only) with your
colleagues and instructor.
• In case of coding assignment, paste all codes and screenshots of output on word
file, later you can convert this word file into PDF file as well. Upload PDF file on
the LMS and keep code files with you (better in your own email) as it will be used
for evaluation and viva.
• All the program output screen should contain your name, your Registration
number and Question number.
• All the submitted evaluation instruments (quizzes, assignments, lab work, exams,
and the project) will be checked for plagiarism.
• Later Submission and Plagiarism will be dealt as per university Policy
• Start early otherwise you will struggle with the assignment.

Note: Keep all your code files. It will be required at any time of evaluation.

1. Write a program to print out all Armstrong numbers between 1 and 500. If sum of
cubes of each digit of the number is equal to the number itself, then the number is
called an Armstrong number.
For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 ) (10 Marks)

2. Write a program to print Fibonacci series of n terms where n is input by user : 0 1 1 2


3 5 8 13 24 .....
(10 Marks)
3. Write a program to print the nth harmonic number where n is the input given by the
user.
(10 Marks)
4. If P is the population of the first day of the year, B is the birth rate and D is the death
rate, the estimated population at the end of the year is given by formula:
Pn +(B*Pn)/100–(D*Pn)/100
The population growth rate is given by the formula:
B-D
Write a program that prompts the user to enter the starting population, birth and death
rates and n, the number of years. The program should then calculate and print the
estimated population after n years. Your program must contain the following
parameters:
GrowthRate: Take the birth and death rates as input and returns the population
growth rate.
Estimated Population: Take the current population, population growth rate and n,
the number of years as input and display the estimated population after n years. Your
program should not accept negative birth rate, negative death rate or population less
than 2.
(10 Marks)
5. Operators such as >>, which read input from the keyboard, must be able to convert a
series of digits into a number. Write a program that does the same thing. It should
allow the user to type up to six digits, and then display the resulting number as a type
long integer. The digits should be read individually, as characters, using getche().
Constructing the number involves multiplying the existing value by 10 and then
adding the new digit.
Here’s some sample interaction:
Enter a number: 123456
Number is: 123456
(10 Marks)
6. Write a program that generates a random number and asks the user to guess what the
number is. If the user’s guess is higher than the random number, the program should
display “Too high, try again.” If the user’s guess is lower than the random number,
the program should display “Too low, try again” The program should use a loop that
repeats until the user correctly guesses the random number. Also keep the count of
number of guesses that the user makes. When the user correctly guesses the random
number, the program should display the number of guesses.
(10 Marks)
7. Write a program that uses while loops to perform the following steps:
a. Prompt the user to input two integers: firstNum and secondNum
(firstNum must be less than secondNum, if not then ask the user to enter
number again).
b. Output all odd numbers between firstNum and secondNum.
c. Output the sum of all even numbers between firstNum and secondNum.
d. Output the numbers and their squares between 1 and 10.
e. Output the sum of the square of the odd numbers between firstNum
and secondNum.
f. Output all uppercase letters.
(10 Marks)
8. The population of a town A is less than the population of town B. However, the
population of town A is growing faster than the population of town B. Write a
program that prompts the user to enter the population and growth rate of each town.
The program outputs after how many years the population of town A will be greater
than or equal to the population of town B and the populations of both the towns at that
time. (A sample input is: Population of town A = 5000, growth rate of town A = 4%,
population of town B = 8000, and growth rate of town B = 2%.)
(10 Marks)
9. A high school has 1000 students and 1000 lockers, one locker for each student. On the
first day of school, the principal plays the following game: She asks the first student
to go and open all the lockers. She then asks the second student to go and close all the
even-numbered lockers. The third student is asked to check every third locker. If it is
open, the student closes it; if it is closed, the student opens it. The fourth student is
asked to check every fourth locker. If it is open, the student closes it; if it is closed,
the student opens it. The remaining students continue this game. In general, the nth
student checks every nth locker. If the locker is open, the student closes it; if it is
closed, the student opens it. After all the students have taken their turn, some of the
lockers are open and some are closed.
Write a program that prompts the user to enter the number of lockers in a school.
After the game is over, the program outputs the number of lockers that are opened.
Test run your program for the following inputs: 1000, 5000, 10000.
(10 Marks)
10. Write a program to print the HCF and LCM of two numbers entered by the user.
(10 Marks)
11. Write a program that prints the pyramid like following. Ask the user to enter the
number of rows in a pyramid and the character to be shown in pyramid.
(10 Marks)

12. Write a program that prints the diamond like following. The number of rows in
diamond should be at least equal to 10 and use * to draw the shape.
(10 Marks)
13. Write a program to find the factorial of a given number. Continue to repeatedly asks
for a number and calculates its factorial, until the user enters 0, at which point it
terminates. (10 Marks)
14. Write a program to print the following pattern. (10 Marks)

15. Write a program to print the following pattern: (10 Marks)


16. Find sum of series:  (10 Marks)

You might also like