Write the following Python script program : 1. Your program should ask the user to input two integer numbers: start (S) and end (E). The range of numbers will be from S to E (inclusive). 2. The program should first print all the odd numbers from S to E, each on a new line. 3. Next, the program should print all the even numbers from S to E, each on a new line. 4. If a user enters something that's not an integer number for S or E, your program should handle this exception and print a warning message: "Invalid input, please enter integer numbers only".

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Write the following Python script program :
1. Your program should ask the user to input two integer numbers: start (S) and end (E).
The range of numbers will be from S to E (inclusive).
2. The program should first print all the odd numbers from S to E, each on a new line.
3. Next, the program should print all the even numbers from S to E, each on a new line.
4. If a user enters something that's not an integer number for S or E, your program should
handle this exception and print a warning message: "Invalid input, please enter integer
numbers only".
Here is a screenshot of the expected behavior, testing all scenarios described above. Replicate
this functionality in your script, including the formatting and outputs of all messages. The
program must work for any starting or ending integer values that the user enters.

 

### Python Program to Print Odd and Even Numbers

This example demonstrates a Python program that takes a range of integers and prints all odd and even numbers within that range.

#### Program Execution

Below is a sample execution of the program where it asks the user to enter a start and end integer, and then displays the odd and even numbers within that specified range.

```plaintext
eric@ifttlinux:~/lab_g$ ./lab_g_task_02_sdevil.py
Enter a start integer: 10
Enter an end integer: 33
Odd numbers from 10 to 33:
11
13
15
17
19
21
23
25
27
29
31
33

Even numbers from 10 to 33:
10
12
14
16
18
20
22
24
26
28
30
32
eric@ifttlinux:~/lab_g$
```

Let's go through the main sections of the program output.

1. **User Input:**
   - The program prompts the user to enter two integers, specifying the start and end of the range.
   - In this example, the start integer is `10` and the end integer is `33`.

2. **Output for Odd Numbers:**
   - The program prints odd numbers within the range. For the given range, the odd numbers are:
     ```
     Odd numbers from 10 to 33:
     11
     13
     15
     17
     19
     21
     23
     25
     27
     29
     31
     33
     ```

3. **Output for Even Numbers:**
   - The program prints even numbers within the range. For the given range, the even numbers are:
     ```
     Even numbers from 10 to 33:
     10
     12
     14
     16
     18
     20
     22
     24
     26
     28
     30
     32
     ```

This script can be highly useful for educational purposes to understand basic concepts of loops and conditional statements in Python programming.
Transcribed Image Text:### Python Program to Print Odd and Even Numbers This example demonstrates a Python program that takes a range of integers and prints all odd and even numbers within that range. #### Program Execution Below is a sample execution of the program where it asks the user to enter a start and end integer, and then displays the odd and even numbers within that specified range. ```plaintext eric@ifttlinux:~/lab_g$ ./lab_g_task_02_sdevil.py Enter a start integer: 10 Enter an end integer: 33 Odd numbers from 10 to 33: 11 13 15 17 19 21 23 25 27 29 31 33 Even numbers from 10 to 33: 10 12 14 16 18 20 22 24 26 28 30 32 eric@ifttlinux:~/lab_g$ ``` Let's go through the main sections of the program output. 1. **User Input:** - The program prompts the user to enter two integers, specifying the start and end of the range. - In this example, the start integer is `10` and the end integer is `33`. 2. **Output for Odd Numbers:** - The program prints odd numbers within the range. For the given range, the odd numbers are: ``` Odd numbers from 10 to 33: 11 13 15 17 19 21 23 25 27 29 31 33 ``` 3. **Output for Even Numbers:** - The program prints even numbers within the range. For the given range, the even numbers are: ``` Even numbers from 10 to 33: 10 12 14 16 18 20 22 24 26 28 30 32 ``` This script can be highly useful for educational purposes to understand basic concepts of loops and conditional statements in Python programming.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education