0% found this document useful (1 vote)
458 views1 page

Python Assignment 2 Decision

This document provides instructions for Assignment 2 on decision structures for a programming fundamentals course. It includes 6 questions asking students to write programs that use conditional logic and control flows, such as checking if a number is positive/negative/zero, even/odd, calculating expenses with/without a discount, determining the state of water based on temperature, checking for pairs in an input, and nested if/else statements checking amount against multiple thresholds. Students are instructed to solve the questions by hand on paper without coding on a computer.

Uploaded by

shakeel Asghar
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 (1 vote)
458 views1 page

Python Assignment 2 Decision

This document provides instructions for Assignment 2 on decision structures for a programming fundamentals course. It includes 6 questions asking students to write programs that use conditional logic and control flows, such as checking if a number is positive/negative/zero, even/odd, calculating expenses with/without a discount, determining the state of water based on temperature, checking for pairs in an input, and nested if/else statements checking amount against multiple thresholds. Students are instructed to solve the questions by hand on paper without coding on a computer.

Uploaded by

shakeel Asghar
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/ 1

PROGRAMMING FUNDAMENTALS

Assignment No: 2
Decision Structure
BS(IT)- Due Date: November 19 th , 2019, Beginning of Class
BS(CS)- Due Date: November 21 st , 2019, Beginning of Class
Instructor: Najia Saher email: [email protected]

Instructions: Do not code on a computer. Solve the questions by hand on paper. Do your work neatly.

Question 1: Write a program that reads an integer and prints whether it is negative, zero, or positive.

Question 2: Write a program to check whether the given number is even or odd (using ? : ternary operator )

Question 3: Write a program to calculate the total expenses. Quantity and price per item are input by the user
and discount of 10% is offered if the expense is more than 5000.

Question 4: Write a program that reads a temperature value and the letter C for Celsius or F for Fahrenheit. Print
whether water is liquid, solid, or gaseous at the given temperature at sea level.
Help:
For Fahrenheit:
Temperature reading less than or equal to 32 = Solid
Temperature reading greater than 32 and less than 212 = Liquid
Temperature reading greater than or equal to 212 = Gaseous
For Celsius:
Temperature reading less than or equal 0 = Solid
Temperature reading greater than 0 and less than 100 = Liquid
Temperature reading greater than or equal to 100= Gaseous

Question 5: Write a program that reads four integers and prints “two pairs” if the input consists of two matching
pairs (in some order) and “not two pairs” otherwise.
For example,
1 2 2 1 two pairs
1 2 2 3 not two pairs
2 2 2 3 two pairs
2 2 2 2 two pairs

Question 6: Write a program that reads amount and Check if amount is less than 1000. If not, then print “program
ends because amount is larger than 1000” but if yes, then Print “ amount is smaller than 1000 so please go into this
if/else” and inside this if/else , check the followings: Is amount less than 500 too , then print “stay in this if and go
to its nested if” and again check, is amount less than 300 too , then print “oh! Ok , it's a small amount entered”
else , go into one more if inside else part and check if amount is not equal to 1000, then print “ “oh! Ok , it's silently
larger amount entered” .
1 Assignment: Programming Fundamentals

You might also like