Question
simple PYTHON 3 language. please comment each line I want to understand. I know the picture says java but please complete code in PYTHON. please use menu driven
[E] The back button used in a web browser is a great example of how stacks may be used. When a user visits a new web page,
0 0
Add a comment Improve this question Transcribed image text
Answer #1
CODE:
stack = ["null"]  # to make a simple stack i am using a list to implement it
# and I have kept a null value which defines that the stack is empty
while True: # this loop will run until it encounters a break statement
    n = int(input("1. Open a new Website\n2. Go Back\n3. Exit")) # taking input from the user
    if n == 1: # if user wants to enter a new website then pushing into the stack as the last item
        p = input()
        stack.append(p)
    elif n == 2: # else if user wants to go back then popping the last website he browsed
        temp = stack.pop()
        if temp != "null": # and if if reaches null then it means there is no more websites to go back to
            print("Your last visit website is", temp)
        else:
            print("you are in the home page.")
    else:
        break

-3.py x ftest2.py test.py x ftest 2.py X stack = [null] # to make a simple stack i am using a list to implement it # and I

- U II 12 JU I LLY GIVI 1. Open a new Website 2. Go Back 3. Exit websitel.com 1. Open a new Website 2. Go Back 3. Exit websit

FOR ANY OTHER QUERY PLEASE COMMENT.

Add a comment
Know the answer?
Add Answer to:
simple PYTHON 3 language. please comment each line I want to understand. I know the picture...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • CODE MUST BE IN PYTHON 3 The objective of this lab is to solve problems using...

    CODE MUST BE IN PYTHON 3 The objective of this lab is to solve problems using the Stack ADT Q1. Write a program that uses the Stack implementation given to you browser has both a back and a forward button which allows the user to in Stack.py to simulate navigation in a web browser. Every web navigate to previously seen web pages. Your task is to implement this functionality using two Stack objects called forward stack and back stack. The...

  • Use python 3 to solve: Every web browser has both a back and a forward button...

    Use python 3 to solve: Every web browser has both a back and a forward button which allows the user to navigate to previously seen web pages. Your task is to implement this functionality using two stacks: ·        The input to your program will be a sequence of commands. The ">" and "<" tokens will be used to indicate forward and back, respectively. All other input will be web addresses (you can assume they will always be valid). ·        You...

  • Please help me with this project by using Android Studio. I need to know the xml...

    Please help me with this project by using Android Studio. I need to know the xml and the java activities in both activities. Also the manifest activity. I appreciate the effort and I'll rate you with 5 stars. 1. SUMMARY This project will simulate the card game Concentration for one player. In Concentration, all cards, or pictures in this case, are upside down. Two cards are chosen, and if they match they are taken out of the game. If they...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around...

    Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around risk and threat management, fostering an environment in which objectives seem clear: manage risk, manage threat, stop attacks, identify attackers. These objectives aren't wrong, but they are fundamentally misleading.In this session we'll examine the state of the information security industry in order to understand how the current climate fails to address the true needs of the business. We'll use those lessons as a foundation...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT