Computer Science, asked by faisaljbrn558, 1 year ago

Write a program that uses input to prompt a user for their name and then welcomes them. Note that input will pop up a dialog box. Enter sarah in the pop-up box when you are prompted so your output will match the desired output.

Answers

Answered by jayanid78
8

Answer:

Solution:

# The code below almost works

name = input('Enter your name')

print('Hello',name)

HOPE IT DOES HELP YOU

Answered by prachikalantri
0

Language Used : Python Programming (GUI - Tkinter)

Program :

import tkinter as tk

from tkinter import simpledialog

from tkinter import messagebox  

root = tk.Tk()

root.withdraw()

username = simpledialog.askstring(title="Test",prompt="What's your Name?:")

#printing the statement on shell

print("Hello",username,"!")

#printing the statement on a message box  

messagebox.showinfo("Greetings", "Hello "+str(username)+"!")

Input :

A pop-up window opens, asking for your name. You can see that in the attachments given below

Output :

On shell :

Hello Sarah!

On Message box :

See the ATTACHMENTS given below.

Explanation :

All you need to do is, to import the libraries simpledialog and messagebox from tkinter.

Then, use the function askstring() from simpledialog to get a pop-up asking for your name.

Once you input your name, you can print it directly on the shell, or you can use showinfo() from messagebox, to greet using pop-up.

Note : I have added the attachments of the interpretation and the execution of programs with their outputs. Take a look!

Quick Tip : In python, you must and should follow Indentation. Following the indentation property in any programming language will help you in quickly analyzing the code, if an error occurs.

#SPJ2

Similar questions