Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 8.3, Problem 14CP
What is the output of the following code?
ch = 'a'
ch2 = ch.upper ()
print (ch, ch2)
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
what does the following code output: float (4)?
(Python matplotlib or seaborn)
CPU Usage
We have the hourly average CPU usage for a worker's computer over the course of a week. Each row of data represents a day of the week starting with Monday. Each column of data is an hour in the day starting with 0 being midnight.
Create a chart that shows the CPU usage over the week. You should be able to answer the following questions using the chart:
When does the worker typically take lunch?
Did the worker do work on the weekend?
On which weekday did the worker start working on their computer at the latest hour?
cpu_usage = [
[2, 2, 4, 2, 4, 1, 1, 4, 4, 12, 22, 23,
45, 9, 33, 56, 23, 40, 21, 6, 6, 2, 2, 3], # Monday
[1, 2, 3, 2, 3, 2, 3, 2, 7, 22, 45, 44,
33, 9, 23, 19, 33, 56, 12, 2, 3, 1, 2, 2], # Tuesday
[2, 3, 1, 2, 4, 4, 2, 2, 1, 2, 5, 31,
54, 7, 6, 34, 68, 34, 49, 6, 6, 2, 2, 3], # Wednesday
[1, 2, 3, 2, 4, 1, 2, 4, 1, 17, 24, 18,
41, 3, 44, 42, 12, 36, 41, 2, 2, 4, 2, 4], # Thursday
[4, 1, 2, 2, 3, 2, 5, 1, 2, 12, 33, 27,
43, 8,…
[Fish
Tank]
You play with a clown fish that has an initial size so. The fish can eat other fish in a tank organized in m columns and n rows. The fish at column i and row j has a positive size si,j.
When your fish eats another fish, it grows by that amount. For example, if your clown fish has a size of 10 and eats a fish of size 5, it becomes of size 15. You cannot eat a fish that
is bigger than your size. The game starts by eating any fish in the first (left-most) column that is not bigger than yours. After that, you advance one column at a time by moving
right. You have only three allowed moves. You either stay at the same row, move one row higher or one row lower. You will always move to the right. Thus, you will make exactly
m moves to advance from left to right. Your goal is to exit the fish tank from the right with the biggest possible size.
The figure below shows an example with the best answer highlighted. In this case, the final fish size is 71 (10+8+7+24+22). You are required…
Chapter 8 Solutions
Starting Out with Python (4th Edition)
Ch. 8.1 - Assume the variable name references a string....Ch. 8.1 - What is the index of the first character in a...Ch. 8.1 - If a string has 10 characters, what is the index...Ch. 8.1 - Prob. 4CPCh. 8.1 - Prob. 5CPCh. 8.1 - Prob. 6CPCh. 8.2 - Prob. 7CPCh. 8.2 - Prob. 8CPCh. 8.2 - Prob. 9CPCh. 8.2 - What will the following code display? mystring =...
Ch. 8.3 - Prob. 11CPCh. 8.3 - Prob. 12CPCh. 8.3 - Write an if statement that displays Digit" if the...Ch. 8.3 - What is the output of the following code? ch = 'a'...Ch. 8.3 - Write a loop that asks the user Do you want to...Ch. 8.3 - Prob. 16CPCh. 8.3 - Write a loop that counts the number of uppercase...Ch. 8.3 - Assume the following statement appears in a...Ch. 8.3 - Assume the following statement appears in a...Ch. 8 - This is the first index in a string. a. 1 b. 1 c....Ch. 8 - This is the last index in a string. a. 1 b. 99 c....Ch. 8 - This will happen if you try to use an index that...Ch. 8 - This function returns the length of a string. a....Ch. 8 - This string method returns a copy of the string...Ch. 8 - This string method returns the lowest index in the...Ch. 8 - This operator determines whether one string is...Ch. 8 - This string method returns true if a string...Ch. 8 - This string method returns true if a string...Ch. 8 - This string method returns a copy of the string...Ch. 8 - Once a string is created, it cannot be changed.Ch. 8 - You can use the for loop to iterate over the...Ch. 8 - The isupper method converts a string to all...Ch. 8 - The repetition operator () works with strings as...Ch. 8 - Prob. 5TFCh. 8 - What does the following code display? mystr =...Ch. 8 - What does the following code display? mystr =...Ch. 8 - What will the following code display? mystring =...Ch. 8 - Prob. 4SACh. 8 - What does the following code display? name = 'joe'...Ch. 8 - Assume choice references a string. The following...Ch. 8 - Write a loop that counts the number of space...Ch. 8 - Write a loop that counts the number of digits that...Ch. 8 - Write a loop that counts the number of lowercase...Ch. 8 - Write a function that accepts a string as an...Ch. 8 - Prob. 6AWCh. 8 - Write a function that accepts a string as an...Ch. 8 - Assume mystrinc references a string. Write a...Ch. 8 - Assume mystring references a string. Write a...Ch. 8 - Look at the following statement: mystring =...Ch. 8 - Initials Write a program that gets a string...Ch. 8 - Sum of Digits in a String Write a program that...Ch. 8 - Date Printer Write a program that reads a string...Ch. 8 - Prob. 4PECh. 8 - Alphabetic Telephone Number Translator Many...Ch. 8 - Average Number of Words If you have downloaded the...Ch. 8 - If you have downloaded the source code you will...Ch. 8 - Sentence Capitalizer Write a program with a...Ch. 8 - Prob. 10PECh. 8 - Prob. 11PECh. 8 - Word Separator Write a program that accepts as...Ch. 8 - Pig Latin Write a program that accepts a sentence...Ch. 8 - PowerBall Lottery To play the PowerBall lottery,...Ch. 8 - Gas Prices In the student sample program files for...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
A syntax error does not prevent a program from being compiled and executed.
Starting Out with Programming Logic and Design (4th Edition)
______programming is centered around functions, or procedures, whereas ____ programming is centered around obje...
Starting Out with C++: Early Objects (9th Edition)
Let y1andy2 be two solutions of A(x)r+B(x)y+C(x)y=0 on an open interval I where A, B, and C are continuous and ...
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Write a function called m that takes as its argument a value of type e m (as defined in this chapter ) and retu...
Programming in C
Alphabetic Telephone Number Translator Many companies use telephone numbers like 555-GET-FOOD so the number is ...
Starting Out with Java: From Control Structures through Objects (6th Edition)
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
- Design void printStart(char *str, char ch). We know that str contains only uppercase words and Spaces, and the first and last characters are not Spaces, and there is only one space between two adjacent words. Ask to print all words in str beginning with the capital letter ch, separated by Spaces, on the screen. (please use c++)arrow_forwardcomputer science | c++ code | it's not graded. Correct answer will upvoted else downvoted. It is given a non-negative integer x, the decimal portrayal of which contains n digits. You need to shading every its digit in red or dark, so the number shaped by the red digits is separable by A, and the number framed by the dark digits is detachable by B. No less than one digit should be shaded in every one of two tones. Consider, the include of digits hued in red is r and the include of digits hued in dark is b. Among all potential colorings of the given number x, you need to output any to such an extent that the worth of |r−b| is the base conceivable. Note that the number x and the numbers shaped by digits of each tone, may contain driving zeros. Input :The principal line contains one integer t (1≤t≤10) — the number of experiments. Then, at that point, t experiments follow. Each experiment comprises of two lines. The main line contains three integers n, A, B (2≤n≤40, 1≤A,B≤40).…arrow_forward*Please help in javascript* Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray). Given values for red, green, and blue, remove the gray part. Ex: If the input is: 130 50 130 the output is: 80 0 80 import java.util.Scanner; public class LabProgram {public static void main(String[] args) {/* Type your code here. */}}arrow_forward
- Code in python: A certain company has encoded the accounts of its customers and requires that you provide an algorithm that, given an account code, informs if it is valid according to the following description: The account codes are made up of 4 digits counted from right to left, plus the verification digit. The verifying digit is obtained by adding the digits of the account number of the even positions and multiplying the digits of the odd positions, from the new result the residue of the division is extracted for 10, which represents the verifying digit. Develop the code in python as a check digit class that returns 1 if it is correct or 0 if not Heading: Extract digits, verifier calculation, Account verification, Integral algorithmarrow_forwardusing c++ programming ::::: 16. (Pick 5 Lotto) Write a program to simulate a pick-5 lottery game. Your program should generate and store 5 distinct numbers between 1 and 9 (inclusive) into an array. The program prompts the user to enter five distinctbetween 1 and 9 and stores the number into another array. The programthen compares and determines whether the two arrays are identical. If thetwo arrays are identical, then the user wins the game; otherwise the program outputs the number of matching digits and their position in the array.Your program must contain a function that randomly generates thepick-5 lottery numbers. Also, in your program, include the functionsequential search to determine if a lottery number generated hasalready been generated.arrow_forwardWrite application that prints matrix with rows and columns, number of rows and columns are input parameters (Have main method) Use DART programming languagearrow_forward
- Broken Cabins Problem Statement: There is an Office consisting of m cabins enumerated from 1 to m. Each cabin is 1 meter long. Sadly, some cabins are broken and need to be repaired. You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken cabins. To be precise, a piece of tape of integer length t placed at some positions will cover segments 5,5+1-sit-1. You are allowed to cover non-broken cabins, it is also possible that some pieces of tape will overlap. Time is money, so you want to cut at most k continuous pieces of tape to cover all the broken cabins. What is the minimum total length of these pieces? Input Format The first line contains three integers n,m and k(1sns10°, namsloº, Isksn) - the number of broken cabins, the length of the stick and the maximum number of pieces you can use The second line contains n integers bl,b2,bn (Isbism) - the positions of the broken cabins. These integers are given in increasing…arrow_forwardLO: (Remember) Students will recall how to read from standard input. LO: (Apply) Students will write loops that iterate as long as a condition is true. Write a program that reads words from standard input and displays them to standard output. When the word "end" is read, print it out and then stop reading input. Full Screen * maln.cpp New #include 2 using namespace std; 1 3 4- /* 5 * Reads and displays words from standard input until hitting a stop word. 6 */ 7- int main() { 8 9. 10 return 0; 11 annarrow_forwardCode in Pythonarrow_forward
- integer) Write a function that computes the sum of the digits in an integer. Use the following function header:def sumDigits(n):For example, sumDigits(234) returns 9 (Hint: Use the % operator to extract digits, and the // operator to remove the extracted digit. For instance, toextract 4 from 234, use 234 % 10 To remove 4 from 234, use 234 // 10 (=23) Use a loop to repeatedly extract and remove the digits until all the digits are extracted.) Write a test program that prompts the user to enter an integer and displays the sum of all its digits.arrow_forwardWhat is the output of the code below? def mystery_func(input, num, t = 0, x = 10, y = 10)[this function multiples all arguments together (except t) and raises the result to the power of t and returns this]print(mystery_func(2, 3))arrow_forward(Learning Objective: students will be able to apply their knowledge of the built-in random package to generate simulations of simple phenomena.) Write a function: • dicesim(D1,D2,trials) that takes as input the number of sides on die 1 (D1) and die2 (D2) and the number of trials. Your function should repeatedly sum pairs of random numbers between 1 and D1 and 1 and D2 and keep track of how many times each sum occurs. The function returns a numpy array with the fraction each sum of rolls occured. Since the numbers are chosen at random, the fractions will differ some from run to run. One run of the function print(p22.dicesim(6,6,10000)) resulted in: [0. 0. 0.0259 0.0615 0.0791 0.1086 0.139 0.1633 0.1385 0.114 0.0833 0.0587 0.0281] or displayed using the code from Section 16.1.1.: PMF of X Note: you should submit a file with only the standard comments at the top and the function. The grading scripts will then import the file for testing.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY