0% found this document useful (0 votes)
14 views

CET111 Lab4 Students

Python

Uploaded by

lolo.walid
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 views

CET111 Lab4 Students

Python

Uploaded by

lolo.walid
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/ 4

Department of Computer Science Technology

CET111 - Introduction to Computer and Programming


Fall 2024 - Lab Manual #4
Instructors: Dr. Mohamed Awwad

Topics Covered:
● Conditional Statements:

○ if

○ else

○ elif

Page 1 of 4
A. Conditional Statements
Exercise 1. (Even / Odd)

Write a Python program that prompts the user to input an integer and displays whether this
number is even or odd.

Input#1: Input#2:
Enter a number: 4 Enter a number: 11

Output#1: Output#2:
4 is an even number. 11 is an odd number.

Exercise 2. (Finding Maximum of Two Numbers)

Write a Python program that takes two floats as input and prints the maximum of the two
numbers.
Input:
Enter number 1: 5
Enter number 2: 11

Output:
Max is 11

Exercise 3. (Finding Maximum of Three Numbers)

Extend the previous program to take three numbers as input and print the maximum of the three
numbers.

Input:
Enter number 1: 20
Enter number 2: 4
Enter number 3: 32

Output:
Max is 32

Page 2 of 4
Exercise 4. (Simple Calculator)

Write a Python program for a basic calculator that takes two numbers and an arithmetic
operation (+, -, *, /) as input and displays the result of the operation. The program should handle
division by zero gracefully.

Terminal:

Exercise 5.

Write a Python program that checks if the temperature is between 70 and 80 degrees
Fahrenheit, inclusive and if it's sunny or at least not raining. If both conditions are met, it prints
“It's a good day for a picnic”; Otherwise, it prints “Stay Home”.

Input:
Temperature: 80
Is it sunny? True
Is it raining? True

Output:
It’s a good day for a picnic

Page 3 of 4
Exercise 6.

Write a program that prompts the user to enter an integer and checks whether the number is
divisible by both 5 and 6, divisible by 5 or 6, or just one of them (but not both). Here is a sample
run:

Output:
Enter an integer: 10
Is 10 divisible by 5 and 6? False
Is 10 divisible by 5 or 6? True
Is 10 divisible by 5 or 6, but not both? True

Exercise 7.

Write a program that prompts the user to enter a three-digit integer and determines whether it is
a palindrome number. A number is a palindrome if it reads the same from right to left and from
left to right. Here is a sample run of this program:

Input#1: Input#2:
Enter a number: 123 Enter a number: 121

Output#1: Output#2:
Not palindrome Palindrome

Page 4 of 4

You might also like