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
Question
thumb_up100%
In Zybooks for Python, I'm getting an error on the 2nd input. I've researched this question in bartleby and i am unable to see where I'm making the mistake.
Here's my code:
def print_shampoo_instructions(num_cycles):
if num_cycles < 1:
print("Too few.")
elif num_cycles > 4:
print("Too many.")
else:
i=0
while i<num_cycles:
print((i+1),": Lather and rinse.")
i=i+1
print("Done.")
RESULT:
Testing with input: 2
Your output
1 : Lather and rinse. 2 : Lather and rinse. Done.
checkTesting with input: 4
Your output
1 : Lather and rinse. 2 : Lather and rinse. 3 : Lather and rinse. 4 : Lather and rinse. Done.
clearTesting with input: 6
Output differs.
Your output
Too many.
Done.
Expected output
Too many.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 5 images
Knowledge Booster
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_forwardI need to create a program with python that will generate a password using a domain name the user has inputted. It will then use an algorithm that will alphabetize the domain name, capitalize all vowels, and add a number at the end the length of a domain name. I need to use loops and selection structures to implement the algorithm. The end will look like this: facebook>AbcEfOOk8 amazon>AAmnOz6arrow_forwardCould you show me a different way to write this code in python? I’m trying to make the code simple and easy to understandarrow_forward
- I have to create a program using python so that when the user inputs a state, it outputs the given info such as capital, state bird, and rank. I have most of it coded, but when I run the program I get an invalid syntax error, I'll attach a screenshot of what I have so far. I'll also attach what it's suppose to look like. Here are the instructions: 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.arrow_forwardWrite code in C++, C# or Python to solve the following problem: Instead of a regular Fibonacci number, you are supposed to calculate a special one as follows: F(n) = F(n-1)+ 2 * F(n-2) + 3 * F(n-3) As an example, if F(0) = F(1) = F(2) = 1, then we have: F(3) = F(2) + 2 * F(1) + 3 * F(0) = 1 + 2 + 3 = 6 F(4) = F(3) + 2 * F(2) + 3 * F(1) = 6 + 2 + 3 = 11 Given F(0), F(1), F(2), and N, your job is to calculate F(N). Input Format First number is F(0), second number is F(1), third number is F(2), and last number is N. Example input: 1 1 1 4 Constraints NA Output Format Print the Nth special Fibonnaci number. Example output: 11 Sample Input 0 1 1 1 4 Sample Output 0 11arrow_forwardI am learning C++ and would like to make cleaner code. I am learning on Udemy.com how having the main at the bottom of the program helps when making blocks of code. What I would like to do is take some code I already have, and have the user enter two prime colors to make a mixed color, then ask the user if they would like to mix another color with two of the same prime and one other prime color to get: yellow-green, yellow-orange, orange-red, red-purple, blue-green, and blue-purple. Is my logic flawed? What is the correct logic? How would I set up this code to have different functions outside the main with the main at the bottom? I know it is supposed to read the information first somehow. I just can't process how to write it. #include <iostream>#include <string> using namespace std; int main() { string arr[] = {"red", "blue", "yellow"}; int color1, color2; string mixedColor; char choice; do { cout << "Enter one prime color followed by a second…arrow_forward
- Please help me with this in python. I have attached question and output below.arrow_forwardwe showed you the code#for two versions of binary_search: one using recursion, one#using loops. For this problem, use the recursive one.##In this problem, we want to implement a new version of#binary_search, called binary_search_year. binary_search_year#will take in two parameters: a list of instances of Date,#and a year as an integer. It will return True if any date#in the list occurred within that year, False if not.##For example, imagine if listOfDates had three instances of#date: one for January 1st 2016, one for January 1st 2017,#and one for January 1st 2018. Then:## binary_search_year(listOfDates, 2016) -> True# binary_search_year(listOfDates, 2015) -> False##You should not assume that the list is pre-sorted, but you#should know that the sort() method works on lists of dates.##Instances of the Date class have three attributes: year,#month, and day. You can access them directly, you don't#have to use getters (e.g. myDate.month will access the#month of myDate).##You may…arrow_forwardn this lab, you complete a prewritten Python program for a carpenter who creates personalized house signs. The program is supposed to compute the price of any sign a customer orders, based on the following facts: The charge for all signs is a minimum of $35.00. The first five letters or numbers are included in the minimum charge; there is a $4 charge for each additional character. If the sign is make of oak, add $20.00. No charge is added for pine. Black or white characters are included in the minimum charge; there is an additional $15 charge for gold-leaf lettering.arrow_forward
- Write a JAVASCRIPT code to repeat the given string to n times and add to it the original string without using loops concat, + operator. for example:- n = 4 given string:- Programmer Output:- ProgrammerProgrammerProgrammerProgrammerarrow_forwardI am having an issue with this program, I keep getting the number 15 everytime I type in a code. There is also the instructions for the module itself. //PSEUDOCODE //Write a program that prompts the user for a binary number //(from 3 to 8 bits) as a String and converts it to base-10 decimal value //There are several ways to do this in Java but your program must use a for loop and first principles to perform the conversion //Print the base-10 number when the loop ends public static void main(String args[]) { long sum = 0; System.out.println("Enter a binary number: "); Scanner scan = new Scanner(System.in); String s = scan.next(); long result = 0; for (int i = 0; i < s.length(); i++) { result = (long) (result + (s.charAt(1) - '0') * Math.pow(2, s.length()- i - 1)); scan.close(); } System.out.println(result); }}arrow_forwardIn Java: Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9. Ex: If the input is: 1995 the output is: yes Ex: If the input is: 42,000 or 1995! the output is: no Hint: Use a loop and the Character.isDigit() function.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education