Using loops of any kind, lists, or is not allowed. Angela loves reading books. She recently started reading an AI generated series called “Harry Trotter”. Angela is collecting books from the series at her nearest bookstore. Since the series is AI generated, the publishers have produced an infinite collection of the books where each book is identified by a unique integer. The bookstore has exactly one copy of each book. Angela wants to buy the books in the range [l,r], where l ≤ r. As an example, the range [−3,3] means that Angela wants to buy the books  − 3,  − 2,  − 1, 0, 1, 2, and 3. Dan also loves the series (or maybe annoying Angela – who knows, really), and he manages to sneak into the bookstore very early to buy all of the books in the range [d,u], where d ≤ u. When Angela later visits, sadly she will not find those books there anymore. For example, if Angela tries to buy books [−2,3] and Dan has bought books [0,2], Angela would only receive books  − 2,  − 1, and 3. The reading recommendation score of the books is the product of the book numbers received. So if Angela gets books  − 2,  − 1, and 3, for instance, the reading recommendation score will be  − 2 ×  − 1 × 3 = 6. Your task is to write a program that will help Angela determine whether the reading recommendation score of the books she receives is NEGATIVE, ZERO, POSITIVE, or EMPTY. Filename Your filename for this question must be q2.py. Input There are four lines of input. The first line of input will contain the integer l, the lower bound of the collection of books that Angela would like to buy. The second line of input will contain the integer r, the upper bound of the collection of books that Angela would like to buy. The third line of input will contain the integer d, the lower bound of the collection of books that Dan buys. The fourth line of input will contain the integer u, the upper bound of the collection of books that Dan buys. Output Let s be the reading recommendation score of the book collection Angela receives. If s is less than 0, print NEGATIVE. If s is exactly 0, print ZERO. If s is greater than 0, print POSITIVE. If s does not exist, print EMPTY. Sample Input 1 1 10 3 7 Sample Output 1 POSITIVE Sample Input 2 1 3 1 3 Sample Output 2 EMPTY Sample Input 3 -5 5 -2 3 Sample Output 3 NEGATIVE Sample Input 4 -1 3 -2 -1 Sample Output 4 ZERO

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
Question

 

[Python Language]

Using loops of any kind, lists, or is not allowed.

Angela loves reading books. She recently started reading an AI generated series called “Harry Trotter”.

Angela is collecting books from the series at her nearest bookstore. Since the series is AI generated, the publishers have produced an infinite collection of the books where each book is identified by a unique integer. The bookstore has exactly one copy of each book.

Angela wants to buy the books in the range [l,r], where l ≤ r. As an example, the range [−3,3] means that Angela wants to buy the books  − 3,  − 2,  − 1, 0, 1, 2, and 3.

Dan also loves the series (or maybe annoying Angela – who knows, really), and he manages to sneak into the bookstore very early to buy all of the books in the range [d,u], where d ≤ u. When Angela later visits, sadly she will not find those books there anymore.

For example, if Angela tries to buy books [−2,3] and Dan has bought books [0,2], Angela would only receive books  − 2,  − 1, and 3.

The reading recommendation score of the books is the product of the book numbers received. So if Angela gets books  − 2,  − 1, and 3, for instance, the reading recommendation score will be  − 2 ×  − 1 × 3 = 6.

Your task is to write a program that will help Angela determine whether the reading recommendation score of the books she receives is NEGATIVE, ZERO, POSITIVE, or EMPTY.

Filename

Your filename for this question must be q2.py.

Input

There are four lines of input.

  • The first line of input will contain the integer l, the lower bound of the collection of books that Angela would like to buy.
  • The second line of input will contain the integer r, the upper bound of the collection of books that Angela would like to buy.
  • The third line of input will contain the integer d, the lower bound of the collection of books that Dan buys.
  • The fourth line of input will contain the integer u, the upper bound of the collection of books that Dan buys.

Output

Let s be the reading recommendation score of the book collection Angela receives.

  • If s is less than 0, print NEGATIVE.
  • If s is exactly 0, print ZERO.
  • If s is greater than 0, print POSITIVE.
  • If s does not exist, print EMPTY.

Sample Input 1

1 10 3 7

Sample Output 1

POSITIVE

Sample Input 2

1 3 1 3

Sample Output 2

EMPTY

Sample Input 3

-5 5 -2 3

Sample Output 3

NEGATIVE

Sample Input 4

-1 3 -2 -1

Sample Output 4

ZERO

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

what if i don't want use sets ether or import math

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

what if I don't wont use import math in my code 

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

line 20, in <module>
    if(ans==0):
NameError: name 'ans' is not defined

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

line 6, in <module>
    original_list = range*l, r+1, 1
TypeError: unsupported operand type(s) for *: 'type' and 'in

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

line 17, in <module>
    ans = math.prod(ls)
NameError: name 'math' is not defined

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

    iflen(ls)==0:
                ^
SyntaxError: invalid syntax

 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Random Class and its operations
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.
Similar questions
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