Answer to Question #260151 in Python for zgr

Question #260151

5. Big-Sightedness

by CodeChum Admin

I got my grandmother a new phone because I thought that we could talk more everyday by texting. Well, let’s just say that my grandma’s eyes aren’t the best anymore so she can’t really see what I text her and because of that she wants to ditch texting and stick with carrier pigeons. You know how embarrassing it is for a kid like me to be seen using carrier pigeons?!?! Well, anyway, I was hoping that you could make a program that takes my text and make it bigger, a LOT bigger. How about you test it out by only using the letters A, B, and C first.


Input


1. My text


Description

This is a string with characters A, B, and C.

Constraints

It is guaranteed that all letters are in uppercase.

Output


The first line will contain a message prompt to input my text.

The succeeding lines will contain the enlarged text.


1
Expert's answer
2021-11-02T03:58:39-0400



SOLUTION TO THE ABOVE QUESTION


In this question we will use the pygame package. A user will enter a string and the enlarged text will be displayed in a pygame window.


SOLUTION CODE


import pygame
from pygame.locals import *

pygame.init()
pygame.font.init()
# font object..................................
def create_font(t,s=72,c=(255,255,0), b=False,i=False):
    font = pygame.font.SysFont("Arial", s, bold=b, italic=i)
    text = font.render(t, True, c)
    return text
# Text to be rendered with create_font
my_string = input("Enter your String: ")
game_over = create_font(my_string)


SURF = pygame.display.set_mode((600, 400))
loop = True
clock = pygame.time.Clock()
while loop == True:
    SURF.fill((0,0,0))
    x, y = pygame.mouse.get_pos()
    SURF.blit(game_over, (100,150))
    for e in pygame.event.get():
        if e.type == QUIT:
            loop = 0
    pygame.display.update()
    clock.tick(60)

pygame.quit()


SAMPLE PROGRAM OUTPUT



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog