1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Dmitry_Shevchenko [17]
3 years ago
11

How to implement switch statement in Python?

Computers and Technology
2 answers:
gregori [183]3 years ago
8 0
Make sure there is a function/method to handle the default case. Next, make a dictionary object and store each of the function beginning with the 0th index. After that, write a switch() function accepting the day of the week as an argument.
Jet001 [13]3 years ago
5 0

Answer:

Switch-case statements are a powerful tool for control in programming. In this article, Sreeram Sceenivasan goes over you can use a switch-case statement in Python.

Explanation:

Python doesn’t need a switch statement. You can do exactly the same thing with if/elif/else statements.

You might be interested in
1. Write a telephone lookup program. Read a data set of 1, 000 names and telephone numbers from a file that contains the numbers
Fed [463]

Answer:

Kindly note that, you're to replace "at" with shift 2 as the brainly text editor can't take the symbol

Explanation:

PhoneLookup.java

import java.io.FileReader;

import java.io.IOException;

import java.util.Scanner;

public class PhoneLookup

{

  public static void main(String[] args) throws IOException

  {

     Scanner in = new Scanner(System.in);

     System.out.println("Enter the name of the phonebook file: ");

     String fileName = in.nextLine();

     LookupTable table = new LookupTable();

     FileReader reader = new FileReader(fileName);

     table.read(new Scanner(reader));

   

     boolean more = true;

     while (more)

     {

        System.out.println("Lookup N)ame, P)hone number, Q)uit?");

        String cmd = in.nextLine();

       

        if (cmd.equalsIgnoreCase("Q"))

           more = false;

        else if (cmd.equalsIgnoreCase("N"))

        {

           System.out.println("Enter name:");

           String n = in.nextLine();

           System.out.println("Phone number: " + table.lookup(n));

        }

        else if (cmd.equalsIgnoreCase("P"))

        {

           System.out.println("Enter phone number:");

           String n = in.nextLine();

           System.out.println("Name: " + table.reverseLookup(n));

        }

     }

  }

}

LookupTable.java

import java.util.ArrayList;

import java.util.Collections;

import java.util.Scanner;

/**

  A table for lookups and reverse lookups

*/

public class LookupTable

{

  private ArrayList<Item> people;

  /**

     Constructs a LookupTable object.

  */

  public LookupTable()

  {

      people = new ArrayList<Item>();

  }

  /**

     Reads key/value pairs.

     "at"param in the scanner for reading the input

  */

  public void read(Scanner in)

  {

     while(in.hasNext()){

         String name = in.nextLine();

         String number = in.nextLine();

         people.add(new Item(name, number));

     }

  }

  /**

     Looks up an item in the table.

     "at"param k the key to find

     "at"return the value with the given key, or null if no

     such item was found.

  */

  public String lookup(String k)

  {

     String output = null;

     for(Item item: people){

         if(k.equals(item.getName())){

             output = item.getNumber();

         }

     }

     return output;

  }

  /**

     Looks up an item in the table.

     "at"param v the value to find

     "at"return the key with the given value, or null if no

     such item was found.

  */

  public String reverseLookup(String v)

  {

      String output = null;

         for(Item item: people){

             if(v.equals(item.getNumber())){

                 output = item.getName();

             }

         }

         return output;

  }

}

Item.java

public class Item {

  private String name, number;

 

  public Item(String aName, String aNumber){

      name = aName;

      number = aNumber;

  }

 

  public String getName(){

      return name;

  }

 

  public String getNumber(){

      return number;

  }

}

input.txt

Abbott, Amy

408-924-1669

Abeyta, Ric

408-924-2185

Abrams, Arthur

408-924-6120

Abriam-Yago, Kathy

408-924-3159

Accardo, Dan

408-924-2236

Acevedo, Elvira

408-924-5200

Acevedo, Gloria

408-924-6556

Achtenhagen, Stephen

408-924-3522

Kindly check the attached output image below.

3 0
3 years ago
What is one of the key components of a typical formula?
hoa [83]

A formula key components are:

  • Functions
  • References
  • Operators
  • Constants.

<h3>What is a formula?</h3>

This is known to be a kind of mathematical relationship or rule that is said to be expressed in form of symbols.

Therefore, A formula key components are:

  • Functions
  • References
  • Operators
  • Constants.

Learn more about formula from

brainly.com/question/2005046

#SPJ11

4 0
2 years ago
why is it when you put earbud aux cords in a phone or computer they sound weird until you move the aux cord? Then it is somehow
AfilCa [17]

Answer:

that might just be the headphone cord itself or it might be the port on the pc/phone

Explanation:

i had this happen with my old droid razr hd i thought it was the aux cord on my speaker and head phones but i used the same things on a friends phone and they worked just fine and this might be do to an old  or broken port on the phone /c my phone headphone port got used almost everyday and it was just the port you can replace this on some tech or you could just use bluetooth if the tech doesent have it buy and adapter.

            hope this helps!!!

4 0
3 years ago
For the following scenario, indicate whether the action is a good practice or bad practice for safeguarding your personally iden
a_sh-v [17]

Answer: it is good practice

Explanation: Even if you are able to guess the phrase that Sierra uses, you will find it very difficult to write them exactly as she does hence you cannot have access to her bank account

8 0
3 years ago
_____ is(are) often used in reports to quickly represent data and help the readers understand the data.
Ira Lisetskai [31]
Tables are used<span> to </span>present <span>numerical </span>data<span> in a wide variety of publications from newspapers, journals and textbooks to the sides of grocery packets.</span>
6 0
3 years ago
Other questions:
  • Suppose a worker needs to process 100 items. the time to process each item is exponentially distributed with a mean of 2 minutes
    5·1 answer
  • If you are viewing a webpage with customized or regenerated content, such as updated stock quotes, what type of webpage are you
    14·1 answer
  • A broadband router is used to do which of the following? run the programs on a computer locate lost files on a computer manage a
    6·1 answer
  • What are the pros and cons of editorial anonymity in Wikipedia
    10·2 answers
  • Given an int as the input, print all the factors of that number, one in each line. For example, if the input is 15 The output wi
    14·2 answers
  • What can help an interface user understand or navigate an online interface?​
    15·1 answer
  • Based on the description below which website is more appropriate
    14·2 answers
  • What is the benefit of hosting a website on a personali
    6·1 answer
  • A(n) ________ attempts to slow down or stop a computer system or network by sending repetitive requests for information.
    6·1 answer
  • a web server will utilize a directory protocol to enable users to authenticate with domain credentials. a certificate will be is
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!