Answer to Question #229958 in Python for Assignment

Question #229958
Write a python program that takes a number from the user. If the number is odd, print that many "*" and if the number is even, print that many "+" as output. Use for loop.

Example 1

Sample input: 5

Sample Output: *****

Example 2

Sample input: 10

Sample Output: ++++++++++
1
Expert's answer
2021-08-28T01:36:29-0400
n = int(input('Enter number her: '))
if n % 2 == 0:
  print(n * '+')
else:
  print(n * '*')

Enter number her: 5
*****
Enter number her: 10
++++++++++

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