Answer to Question #245118 in Python for Raju

Question #245118

First Negative Number

Given N inputs, write a program to print the first negative number.


1
Expert's answer
2021-10-02T18:22:30-0400
N = 10
neg_number = None
for i in range(N):
    x = float(input())
    if x < 0 and neg_number is None:
        neg_number = x

if neg_number is not None:
    print(f'The first negative number is {neg_number}')
else:
    print('There was not negative numbers')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS