86.1k views
1 vote
Given an int variable n that has already been declared and initialized to a positive value, use a while loop to print a single line consisting of n asterisks. Use no variables other than n.Write an expression that evaluates to true if and only if the value of the integer variable x is equal to zero.

User Gwasshoppa
by
4.3k points

1 Answer

3 votes

Answer:

i = 0

output = ""

while (i < n):

output += "*"

i += 1

if (i == 0):

print(False)

else:

print(output)

User Marcelo Dos Santos
by
3.6k points