Introduction to Software Design
Lab03-2. Python_Loop
Eun-ki Lee, Minseo Kim
2025. 3. 20.
Problem #1
• Take a positive integer 𝑛 , then calculate σ𝑛𝑘=1 2𝑘 − 1 by
using a while-loop statement.
2025. 3. 20. 1
Problem #2
• Calculate σ10
𝑖=1 𝑘=1 𝑖 + 𝑘 by using a for-loop statement.
σ 20
2025. 3. 20. 2
Problem #3
• Take an integer 𝑛 which is larger than 1 as input, then find
the value of 𝑎2 , … , 𝑎𝑛 by iterating over following
recurrence formula.
𝑎𝑛+1 = 2𝑎𝑛 + 5, 𝑎1 = −4
2025. 3. 20. 3
Problem #4
• Take a positive integer as input, and output a pattern of stars where
the number of lines is equal to the input integer.
• The number of stars in each line should be ( 𝑙𝑖𝑛𝑒 𝑛𝑢𝑚𝑏𝑒𝑟 × 2 − 1)
(e.g. the third line should have 5 stars).
• The stars should be right-aligned.
2025. 3. 20. 4
Problem #5
• Take a positive integer number as input, and generate blocks equal
to the input integer.
• Each block needs to be separated by one line of space.
• The number of lines in each block should be ( 𝑙𝑖𝑛𝑒 𝑛𝑢𝑚𝑏𝑒𝑟 × 2 −
1) (e.g. the third block should have 5 lines), and the number of
stars in each line of the block should be (((𝑏𝑙𝑜𝑐𝑘 𝑛𝑢𝑚𝑏𝑒𝑟) +
𝑙𝑖𝑛𝑒 𝑛𝑢𝑚𝑏𝑒𝑟 ) × 2 − 1) (e.g. the third line of third block should
have 11 stars).
• The stars should be left-aligned.
2025. 3. 20. 5
Problem #5
2025. 3. 20. 6
Submission
• Upload the .zip file to LMS by 23:59(today)
• Zip three files(*.py) as ‘ student id’_’name’ .zip
• e.g.2025123456_ 김한양 .zip
2025. 3. 20. 7