Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING PYTHON PROGRAMMING AND WHILE LOOPS, DO NOT USE BREAK,PASS AND CONTINUE, FOR LOOPS. Write a program that asks the user to enter a nu

USING PYTHON PROGRAMMING AND WHILE LOOPS, DO NOT USE BREAK,PASS AND CONTINUE, FOR LOOPS.

Write a program that

asks the user to enter a nu

mber, and then checks

different properties of the number using functions.

The program must contain a

main()

, as well as the following 3 functions:

checkOddOrEven()

o

Task: check if number is

odd or even

o

Input: userNum, an integer

o

Output: None

(p

rints out r

esults to the screen

)

checkPositive

()

o

Task: check if number is negative, positive, or zero

o

Input: userNum, an integer

o

Output: None

(p

rints out results to the screen

)

checkDivis

i

ble

()

o

Task: check if the given number is divisible by a second number

o

Input: u

serNum, an integer

The second number should be asked for

within

the function

itself, and is not passed in as a second formal parameter.

o

Output: None

(p

rints out results to the screen

)

Within

main()

, the user is asked for a number, and then each of the thr

ee

functions above are called, in the order they are shown.

SAMPLE OUTPUT

bash

-

4.1$ python hw5_part4.py

Enter the number you would like to check:

18

18 is even

18 is positive

Enter number to divide by:

2

18 is divisible by 2

bash

-

4.1$ python hw5_part4.py

Enter the number you would li

ke to check:

-

77

-

77 is odd

-

77 is negative

Enter number to divide by:

-

18

-

77 is not divisible by

-

18

bash

-

4.1$ python hw5_part4.py

Enter the number you would like to check:

0

0 is even

0 is zero

Enter number to divide by:

5

0 is divisible by 5

bash

-

4.1

$ python hw5_part4.py

Enter the number you would like to check:

35

35 is odd

35 is positive

Enter number to divide by:

4

35 is not divisible by 4

bash

-

4.1$ python hw5_part4.py

Enter the number you would like to check:

-

123456789

-

123456789 is odd

-

1234567

89 is negative

Enter number to divide by:

3

-

123456789 is divisible by 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions