Answer to Question #182947 in Python for Rania

Question #182947

Write a python program that prompts the user to enter a few details: fullname, age, job, country and salary which are going to be included in an html file. 


1
Expert's answer
2021-04-19T01:40:58-0400
# A simple example of reading write data to a file 
# and opening it in a browser
import webbrowser
name = input("Enter fullname: ")
age = input("Enter age: ")
job = input("Enter job: ")
country = input("Enter country: ")
salary = input("Enter salary: ")

html= f"""
<!DOCTYPE html>
<html lang="en">
<head>
    <title>A simple HTML document</title>
</head>
<body>
    <p>Full name {name}<p>
    <p>Age {age}<p>
    <p>Job  {job}<p>
    <p>Country  {country}<p>
    <p>Salary  {salary}<p>
</body>
</html>
"""
file_name = "example.html"
with open(file_name, "w") as file:
    file.write(html)
# open in browser
webbrowser.open(file_name)

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
APPROVED BY CLIENTS