Develop a Python program that uses one loop within another loop (nested loops),
ID: 3734929 • Letter: D
Question
Develop a Python program that uses one loop within another loop (nested loops), to draw a pattern that looks 1. The pattern is made by printing blanks spaces (") and asterisks" 2. The loops can be either for in loops, while loops, or one of each. 3. Your Project a4, or your Project #3, are really good starting points for this project 4. The Lecture on Loops(04) has a description of nested for loops on slide 58, and nested while loops on slide 60 how It may be easier to start with a visible character instead of a blank space. That way you can count many are being printed. Once the counts are correct, you can then change it to a blank space s. Use input and int functions to get a count value, from the user that is running the program. 7. The inner loop ill terate through the number characters across. That number will match the court 8. The 'outer loop 9. Hint: you can calculate the middle of each column, and the middle row with: value that the user entered will iterate through the number rows down. That number will also match the count value that the user entered middle count 112 where count is the value that the user entered. 10. Hint2: You want to print the asterisk w hen the inner loop is in the middle or the outer loop is in the middle. Else you want to print a space 11. Once completed, email the code (with Subject of Completed Midterm) to Jonathon.kaufman@marist.eduExplanation / Answer
count = int(input("Enter the size : ")) middle = count // 2 for i in range(count): for j in range(count): if i == middle or j == middle: print("*",end="") else: print(" ",end="") print()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.