| 1. |
2.2 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. Please correct your code and re-run. # The code below almost works name = input("sarah") print("hello sarah"). Your Output Desired Output Hello Sarah Setting: Hide editor This software is based on Skulpt and CodeMirror. The source code for this auto-grader is |
|
Answer» program that USES input to prompt a user for their name and then welcomes them. 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. Learn more : About GUI. brainly.in/question/16402094 Sailent features of python. brainly.in/question/12206981 |
|