Try doing a task 3 different ways:
a. Use an interactive Python session (shell) to print out a line of 5 stars 10 times (so there will be 10 lines of output, each line containing 5 stars)
b. Write a function that does the same thing as above, having each line printed individually (you can do this either in the shell or in a module; either way, just copy and paste your code when submitting)
a.
Code:
for i in range(10):#this loop iterates 10 times
print("*****")#For every iteration we print 5
stars
Output and indentation:
b.
Code:
def fivestar():#function
for i in range(10):#this loop iterates 10 times
print("*****")#every time the loop iterates it prints 5 stars
fivestar()
#HEre we call the function
Output:
indentation:
Get Answers For Free
Most questions answered within 1 hours.