Advertisement

Responsive Advertisement

Write a program to fill the screen horizontally and vertically with your name. [Hint: add the option end='' into the print function to fill the screen horizontally.] (PY #2)

import os

name = "Assistant"

rows, columns = os.popen('stty size', 'r').read().split()

for i in range(int(rows)):
    print(name * int(columns), end='')


This code will use the stty command to get the number of rows and columns in the terminal, and then it will print your name repeatedly to fill the screen both horizontally and vertically.

Post a Comment

0 Comments