In: Computer Science
For Homework 4, we are going to present the user with a series of menus, accept as input the action they wish to take, and act appropriately. You must practice basic input validation to ensure that the menu option they chose is valid.
#***************************************************************************** # Name: # User name: # Homework No: 4 # Date Due: 3/26/2019 # # Description: # A brief but complete description of what the program does # # Bug Report: # A description of the known bugs in the program you could not fix. # If you did not implement specific functionality, that should be reported # in this section as well #***************************************************************************** import platform import webbrowser def mainMenu(): # output main menu to user print("\n") # get input from user # take appropriate action based on the user input # Hint: call openWebsite() or getComputerInfo() when appropriate def openWebsite(): # output web sites menu to user print("\n") # get input from user # take appropriate action based on the user input # Look at https://docs.python.org/2/library/webbrowser.html # We want to open the appropriate web page in a new browser tab # Hint: use webbrowser.open_new_tab(url) # The URLs are the following: # UD: http://www.udayton.edu # BCM: http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/chemistry/#BCM # CHM: http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/chemistry/ # CME: http://catalog.udayton.edu/undergraduate/schoolofengineering/programsofstudy/chemicalandmaterialsengineering/#MAJOR # EAS: http://catalog.udayton.edu/allcourses/edt/ # ECT: http://catalog.udayton.edu/allcourses/ect/ # ERL: https://udayton.edu/education/departments_and_programs/edt/programs/undergraduate/erl/index.php # EYA: https://udayton.edu/education/departments_and_programs/edt/programs/undergraduate/eya/index.php # GEO: http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/geology/#GEO # MCT: http://catalog.udayton.edu/allcourses/mct/ # MEE: http://catalog.udayton.edu/allcourses/mee/ # MTH: http://catalog.udayton.edu/allcourses/mth/ # PHY: http://catalog.udayton.edu/allcourses/phy/ def getComputerInfo(): # output computer info menu to user print("\n") # get input from user # take appropriate action based on the user input # Look at https://docs.python.org/2/library/platform.html for the list of functions which perform the necessary actions # Use the appropriate functions in the section "15.15.1. Cross Platform" # call the mainMenu() function mainMenu()
############### PGM START ############################################
# -*- coding: utf-8 -*-
#*****************************************************************************
# Name:
# User name:
# Homework No: 4
# Date Due: 3/26/2019
#
# Description:
# A brief but complete description of what the program
does
#
# Bug Report:
# A description of the known bugs in the program you
could not fix.
# If you did not implement specific functionality, that
should be reported
# in this section as well
#*****************************************************************************
import platform
import webbrowser
def mainMenu():
flag=True
while(flag):
choice=int(input("__MAIN
MENU___\n1. Open Website\n2. Computer Info\n3. Exit\nEnter your
choice: "))
if choice==1:
openWebsite()
elif choice==2:
getComputerInfo()
elif choice==3:
flag=False
print("\nExiting....\n")
else:
print("\nInvalid choice!!!!!!!!!\n")
def openWebsite():
# output web sites menu to user
print("\n")
# get input from user
# take appropriate action based on the user
input
# Look at
https://docs.python.org/2/library/webbrowser.html
# We want to open the appropriate web page in a
new browser tab
# Hint: use webbrowser.open_new_tab(url)
print("\n___Website Menu____\n1. UD\n2. BCM\n3.
CHM\n4. CME\n5. EAS\n6. ECT\n7. ERL\n")
print("8. EYA\n9. GEO\n10. MCT\n11. MEE\n12.
MTH\n13. PHY\n")
choice=int(input("Enter the choice: "))
if choice==1:
webbrowser.open_new_tab("http://www.udayton.edu")
elif choice==2:
webbrowser.open_new_tab("http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/chemistry/#BCM")
elif choice==3:
webbrowser.open_new_tab("http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/chemistry/")
elif choice==4:
webbrowser.open_new_tab("http://catalog.udayton.edu/undergraduate/schoolofengineering/programsofstudy/chemicalandmaterialsengineering/#MAJOR")
elif choice==5:
webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/edt/")
elif choice==6:
webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/ect/")
elif choice==7:
webbrowser.open_new_tab("https://udayton.edu/education/departments_and_programs/edt/programs/undergraduate/erl/index.php")
elif choice==8:
webbrowser.open_new_tab("https://udayton.edu/education/departments_and_programs/edt/programs/undergraduate/eya/index.php")
elif choice==9:
webbrowser.open_new_tab("http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/geology/#GEO")
elif choice==10:
webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/mct/")
elif choice==11:
webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/mee/")
elif choice==12:
webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/mth/")
elif choice==13:
webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/phy/")
else:
print("\nInvalid
choice!!!!!\n")
def getComputerInfo():
print("\n___Computer Info Menu___\n")
print("1. Machine\n2. Processor\n3. Node\n4.
System\n")
choice=int(input("Enter your choice: "))
if choice==1:
print("Machine Type:
"+str(platform.machine())+"\n")
elif choice==2:
print("Processor:
"+str(platform.processor())+"\n")
elif choice==3:
print("Network Name:
"+str(platform.processor())+"\n")
elif choice==4:
print("System Type:
"+str(platform.system())+"\n")
else:
print("\nInvalid
Choice!!!!!!\n")
# call the mainMenu() function
mainMenu()
##################### PGM END #############################################
OUTPUT
#########