Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
thumb_up100%
I have to create a
- Your program will initialize lists to store information about the states. You should have one list for the names of the states, one list for the names of the capitals, one list for the names of the state birds per state, and one list for the order number the state joined the union. Alternatively, you can use a db list of lists as demonstrated in the exercises in the book to store the information in one structure or dictionaries.
- Next ask the user to enter a name of a state.
- Find the index of that name.
- Use that index to report back to the user the name of the capital, state bird, and the order the state joined the union.
Transcribed Image Text:The image displays a Python script loaded in IDLE, which appears to be related to identifying state birds. Here's the transcription and description for educational purposes:
```python
birds = [
"Delaware Blue Hen",
"Northern mockingbird",
"Brown thrasher",
"Hawaiian goose",
"Mountain bluebird",
"Northern cardinal",
"Northern cardinal",
"Eastern goldfinch",
"Western meadowlark",
"Northern cardinal",
"Brown pelican",
"Chickadee",
"Baltimore oriole",
"Black-capped chickadee",
"American robin",
"Common loon",
"Northern mockingbird",
"Eastern bluebird",
"Western meadowlark",
"Western meadowlark",
"Mountain bluebird",
"Purple finch",
"Eastern goldfinch",
"Greater roadrunner",
"Eastern bluebird",
"Northern cardinal",
"Scissor-tailed flycatcher",
"Western meadowlark",
"Ruffed Grouse",
"Rhode Island Red",
"Carolina wren",
"Ring-necked pheasant",
"Northern mockingbird",
"California quail",
"Hermit thrush",
"Northern mockingbird",
"Willow goldfinch",
"Northern cardinal",
"American robin",
"Western meadowlark"
]
union={"State":[], "Capital":[], "Bird":[], "Rank":[]}
n=input("Enter the state name: ")
if n in state:
pos=state.index(n)
union["State"]+=[state[pos]]
union["Capital"]+=[capital[pos]]
union["Bird"]+=[bird[pos]]
union["Rank"]+=[pos]
print(union)
else:
print("State not found")
```
### Explanation:
- **Lists:** The script includes a list called `birds` that contains names of birds associated with different states.
- **Functionality:** The script defines a dictionary named `union` with keys as "State," "Capital," "Bird," and "Rank," all initialized with empty lists.
- **User Input:** It prompts the user to enter a state name with the input function `n=input("Enter the state name: ")`.
- **Search Logic:** It checks if the entered state exists in the `state` list
Transcribed Image Text:## Python Program: State Information Finder
### Python 3.7.9 Execution
#### Description:
This Python program helps users find specific information about a U.S. state they input. It provides details such as the state's capital, state bird, and its position in statehood order.
#### Sample Execution:
- **Program Prompt**:
- "Please enter the name of a state:"
- **User Input**:
- `Alaska`
- **Program Output**:
- "The capital of Alaska is Juneau, its state bird is the Willow Ptarmigan, and it is state number 49 in the union."
- **End of Session Message**:
- "Thank you for using state info finder."
### Hints for Program Development:
1. **Output Display**:
- Use the `print` statement to display results. Programs do not automatically output results like the interactive interpreter.
2. **Using the Index Function**:
- Implement the `index` function to find a user's input within a list. Example: `names.index(userInput)` returns the index of `userInput` within the `names` list.
3. **Aligning Information**:
- Keep state information aligned in multiple lists in the same element order. This alignment simplifies the use of the index function, allowing for efficient data retrieval.
This program is an educational tool designed to enhance understanding of simple interactive Python scripts, data handling, and user interaction.
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 3 steps with 2 images
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Using Python build your own song remixing solution. As an example: given the following American children’s song (this is ONE of the 3 songs I’m giving you in the starter code that includes the data you'll use for your program) Starter file: music.py (data file for my songs and playlist) here below; SONG = ['old macdonald had a farm - ee-i-ee-i-o.', 'and on that farm he had a cow - ee-i-ee-i-o.', 'with a moo moo here and a moo moo there', 'here a moo - there a moo - everywhere a moo moo', 'old macdonald had a farm - ee-i-ee-i-o.' ] Do This: Create a solution that allows users to: Load a new song from our playlist When requested, show the title of the song you’re currently remixing Continue the above operations on demand, until the user explicitly quits your program. Note that there is punctuation in some of the songs we've given you. When you remix a song, you should remove the punctuation (see the example reverse below). If you are unable to perform...arrow_forwardSamething this is not a graded question it's all in python.arrow_forwardIn Python: So this is part of a large project I am working on but I'm having a hard time finding out how to read from one text file and then correct that information to another or same txt file as well as to do it alphabetically. Any help is appreciated. The code I've added was from a previous project that was similar as to what this one wants. I can't use custom classes and I believe I'm supposed to be opening the bad information file, writing it and corrections to a temp file and then creating a new file with the right information. I'm in a beginner class and we haven't covered anything past lists. Problem #1: How much should I study outside of class? Issue: Your fellow students liked the 2nd version of study hour’s application and want to expand it again by adding the features listed below. Minimum Study Hours per Week per Class Grade 15 A 12...arrow_forward
- You've decided to test the wifi speed in the classroom at the beginning of every lecture. Create a program that will tell you if the wifi speed over the past 3 classes has increased, decreased, or neither. If the wifi speeds are sorted and increasing, then print out "The wifi is getting faster!". If the wifi speeds are sorted and decreasing, then print out "The wifi is getting slower!". If the wifi speeds are unsorted or if two or more speeds are the same, then print "The wifi speed is changing unpredictably." The user should input 3 non-negative numbers (double) separated by spaces. Sample runs: Enter wifi speeds over the last 3 classes: 162 180 225 The wifi is getting faster! Enter wifi speeds over the last 3 classes: 37.5 21.2 19.9 The wifi is getting slower! Enter wifi speeds over the last 3 classes: 162 135.3 225 The wifi speed is changing unpredictably. Ensure you are doing basic input validation, output Please enter a valid input. if the user inputs a negative wifi speed. Make...arrow_forwardHere is my c++ program. I want create a "class" to read string from "data.txt", and output "ok" in another txt "test.txt". But I found that the program output nothing...... (it seems that the file was not open) and I don't know how to solve it please help me,thanks.arrow_forwardIN PYTHON: Given a string representing a 10-digit phone number, output the area code, prefix, and line number using the format (800) 555-1212. Ex: If the input is: 8005551212 the output is: (800) 555-1212 Hint: Use string slicing operators. 18005551212 is not allowed.arrow_forward
- Write an improved version of the chaos . py program from Chapter 1 thatallows a user to input two initial values and the number of iterations, and then prints a nicely formatted table showing how the values changeover time. For example, if the starting values were . 25 and . 26 with 10iterations, the table might look like this: index 0.25 0.26----------------------------1 0 . 731250 0 . 7503602 0 . 766441 0 . 7305473 0 . 698135 0 . 7677074 0 . 821896 0 . 6954995 0 . 570894 0 . 8259426 0 . 955399 0 . 5606717 0 . 166187 0 . 9606448 0 . 540418 0 . 1474479 0 . 968629 0 . 49025510 0.118509 0 . 974630arrow_forwardThe language is Java. The chapter it is in is on Looping.arrow_forwardWrite a python program that takes a string as an input from the user. Then check which email domain the user is using and print it. For this question, assume you have only 4 email domains available and they are gmail, yahoo, outlook, and bracu. [You are NOT allowed to use split() and sting slicing for this task] Sample Input 1: tom@gmail.com Sample Output 1: The user is using gmail as a mailing domain. Explanation 1: Since gmail domain is being used by the user. Sample Input 2: kelvin@yahoo.com Sample Output 2: The user is using yahoo as a mailing domain. Explanation 2: Since yahoo domain is being used by the user. IIarrow_forward
- When we say arithmetic expression, we mean a kind of expression you can type in a very basic desk calculator. That is, neither variables nor brackets are allowed. It contains only numbers and four arithmetic operators, +, -, *, and /. The following are some examples of arithmetic expression: Any number string with or without signs - e.g. 3, -1, +10, 3.14, -0.70 and 099. Number strings mixed with arithmetic operators - e.g. 3+5, -1+2*3, 7/10-0.7, and -1.4-+8.2. An example of FA diagram for recognising a non-negative integer is given below. You may use it as a start point. You need to add a few more states and transitions to handle numbers with decimal point and signs (e.g. -5, +2, 0.21, -32.6, +99.05, but not the form 1.0E-3). Most importantly, you also need to add a few more things to deal with the arithmetic operators +, -, *, /.arrow_forwardIn python language, including print(song)arrow_forwardOne of the files is the instructions. One is what I have so far. My question's are: I'm confused about what they mean by holds the following data attributes. Do I write any code for that? ALSO: for list of number of gear teeth values- I'm not sure what they mean by should have a length equal to... etc. How would I write that in python? Thanksarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education