Question

In: Computer Science

Generate a Personal Web Page: Write a program that asks the user (you) for the following...

Generate a Personal Web Page:

Write a program that asks the user (you) for the following information:

  • Enter his/her name
  • Enter degree major
  • Enter your future career and a brief description of the career

Once the user has entered the requested input, the program should create an HTML file, write the html file utilizing the tags below, and display the user entered text in the placeholder of the red text for a simple Web page.

Your program should include the following functions:

  • main
    • Get the information from the user
    • Create the html file for writing
    • Write the html by calling the write_html function and sending the information to write
    • Close the file
  • write_html
    • write the html tag
    • write the head element by calling the write_head function and sending the name of the html file created above
    • write the body by calling a write_body function and sending all of the information to write the body)
    • write the closing html tag
  • write_head

, the name of your web page that will show in the browser tab, and closing title tag

  • write the opening head tag
  • write the opening title tag
  • write the closing head tag
  • write_body
    • Body tags are shown below. Make sure that you replace the red placeholder text with the variable used to store the user input

This is what I have but it is throwing errors:

def main():
print('Enter the following information to create your')
print('your personal web page')

name = input('Enter your full name: ')
major = input('Enter your degree major: ')
career = input('Describe your ideal future career: ')

f = open('profile.html', 'w')

write_html()

f.close()

def write_html():
html = '<html>\n' +\
write_head(f) +\
write_body() +\
'</html>\n'

def write_head():
head = '<head>\n' +\
print('My Personal Web Page') +\
'</head>\n'

def write_body():
body = '<body>\n' +\
'<h1>' + name + '</h1>\n' +\
'<hr />\n' +\
'<h2>' + major + '</h2>\n' +\
'<hr />\n' +\
'<hr />' + career + '</hr>\n' +\
'</body>'

main()

Solutions

Expert Solution

'''

Python version : 3.6

Python program to generate a Personal Web Page

'''

# main function to input the name, major and career from user and call write_html to create the html file

def main():

               # input the details from user

               print('Enter the following information to create your')

               print('your personal web page')

               name = input('Enter your full name: ')

               major = input('Enter your degree major: ')

               career = input('Describe your ideal future career: ')

               f = open('profile.html', 'w') # open the file in write mode

               write_html(f, name, major, career) # call write_html to populate the html file

               f.close() # close the file

# function to write html, head and body tags to html file  

def write_html(f, name, major, career):

               f.write( '<html>\n') # output the opening html tag

               write_head(f) # call function to write the head part

               write_body(f, name, major, career) # call function to write the body part

               f.write('</html>') # output the closing html tag

# function to write the head part of the html        

def write_head(f):           

               f.write('<head>\n') # output the opening head tag

               f.write('<title>\n') # output the opening title tag

               f.write('My Personal Web Page\n') # output the title of the page

               f.write('</title>\n') # output the closing title tag

               f.write('</head>\n') # output the closing head tag

# function to write the body part of the html        

def write_body(f, name, major, career):

               f.write('<body>\n') # output the opening body tag

               # output the name, major and career in body

               f.write('<h1>'+name+'</h1>\n<hr/>\n')

               f.write('<h2>'+major+'</h2>\n<hr/>\n')  

               f.write('<hr/>'+career+'<hr/>\n')

               f.write('</body>\n') # output the closing body tag

              

#call the main function  

main()

#end of program             

Code Screenshot:

Output:


Related Solutions

Program specifics: Write a C++ program that does the following: a. Asks the user for the...
Program specifics: Write a C++ program that does the following: a. Asks the user for the distance to the pin and the depth of the green (both in yards). (Note: The pin is the hole in the green and the depth is the diameter of the green, assuming it is circular.) b. Asks the user for an integer club number from 2 to 10, where 10 is the pitching wedge (this club lifts the ball out of rough, sand, etc)....
// JavaLanguage . You need to write a program that asks the user for an array...
// JavaLanguage . You need to write a program that asks the user for an array size, and then asks the user to enter that many integers. Your program will then print out the sum , average, largest and smallest of the values in the array.
Coding in C++: For this verse, you need to write a program that asks the user...
Coding in C++: For this verse, you need to write a program that asks the user to input the inventory id number (integer) and the price (float) for 5 inventory items. Once the 5 inventory items are input from the user, output the results to the screen. Please ensure you use meaningful names for your variables. If your variables are not named meaningfully, points will be deducted.
Write a program that asks the user to enter an array of 8 characters then you...
Write a program that asks the user to enter an array of 8 characters then you have to check if characters ‘b’ or ‘a’ appears within the characters and replace them with ‘B’ or ‘A’. For example you enter “a m a l a a b d” The output should be “A m A l A A B d”
Write a program that asks the user for an integer. The program checks and prints to...
Write a program that asks the user for an integer. The program checks and prints to the screen whether the number is prime or not. For example, if user enters 17, the program should print “17 is prime”; if the user enters 20, the program should print “20 is not prime”. please do it with a “ while Loop”, Thanks..
Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
Write a C++ program that asks the user to enter the monthly costs for the following...
Write a C++ program that asks the user to enter the monthly costs for the following expenses incurred from operating your automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should then display the total monthly cost of these expenses, and a projected total annual cost of these expenses. Label each cost. The labels should be left aligned and have a column width of 30 characters. The cost should be aligned right and displayed with two decimal places...
Write a program that asks the user to enter the monthly costs for the following expenses...
Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: Loan payment Insurance Gas Oil Tires Maintenance Write a function that takes these six items as arguments and computes the total cost of these expenses. Write a main program that asks the user for these six items and calls your function. Print total monthly cost and the total annual cost for these expenses.
Write a program that asks the user to enter the monthly costs for the following expenses...
Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. Using the following test data: 310.34 104.95 78.34 12.34 8.12 45.00 Your output should look like this: Enter the monthly loan payment amount: Enter the monthly cost of insurance:...
Write a Python program that asks the user to enter the monthly costs for the following...
Write a Python program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: Loan payment Insurance Gas Oil Tires Maintenance Write a function that takes these six items as arguments and computes the total cost of these expenses. Write a main program that asks the user for these six items and calls your function. Print total monthly cost and the total annual cost for these expenses. Your function should...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT