Question

PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv Write a program that reads the inputs...

PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv

Write a program that reads the inputs repeatedly using a while loop. The code should skip the even numbers and print only the odd numbers. Inputs are always valid.

Input:

a) 3 7 6 4 5 9 0 2 3

b) 3 4 6 5 3 4

Output:

a) 3

7

5

9

3

b) 3

5

3

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

import sys
length=len(sys.argv)
i=1
lst=[]
while(length>1):
lst.append(int(sys.argv[i]))
i=i+1
length=length-1
for i in lst:
if not i%2==0:
print(i)

Output:

Add a comment
Know the answer?
Add Answer to:
PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv Write a program that reads the inputs...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT