0% found this document useful (0 votes)
14 views7 pages

Anis Ahmed

This document contains a student's submission of answers to programming questions for their Object Oriented Programming class. It includes 4 questions - the first asks the student to write a program that checks if a user input integer is even or odd, and the remaining questions ask the student to write programs using for and while loops to print natural numbers, calculate sums and products. The student provides the code for each question and example inputs and outputs.

Uploaded by

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

Anis Ahmed

This document contains a student's submission of answers to programming questions for their Object Oriented Programming class. It includes 4 questions - the first asks the student to write a program that checks if a user input integer is even or odd, and the remaining questions ask the student to write programs using for and while loops to print natural numbers, calculate sums and products. The student provides the code for each question and example inputs and outputs.

Uploaded by

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

Federal Urdu University Of Arts, Science

And Technology Karachi

Submitted By

Name : Anis Ahmed


Father name : Nasir Mehmood
Class : BSCS 2nd Semester
Section : B
Subject : Object Oriented Programming

Submitted To : Dr. Kashif Laeeq


Q.NO:01 "The number is even. "If the integer is odd, print "The number is odd." If the input is
not an integer, print "Invalid input, please enter Write a Python program that takes an integer
as input from the user. If the integer is even, print an integer."

Ans. INPUT:

OUTPUT 1:

OUTPUT 2:
OUTPUT 3:

Q,no2:(a) Write a Python program that prints the first 10 natural numbers using a for loop.

INPUT:

OUTPUT:
Q.no2: (b) Write a Python program that prints the first 10 natural numbers using a while
loop.

INPUT:

OUTPUT:
Q.no2: (c) Write a Python program that calculates the sum of all even numbers from 1 to
50 (inclusive) using a for loop and prints the result.

INPUT:

OUTPUT :
Q.no2: (d) Write a Python program that calculates the product of all odd numbers from 1 to
15 (inclusive) using a while loop and prints the result.

INPUT:

OUTPUT :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy