Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 9.1, Problem 8CP
What will the following code display?
stuff = {1 : 'aaa', 2 : 'bbb', 3 : ‘ccc’}
print(len (stuff))
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
PYTHON ONLYPlease create a code that checks if 'user' favourite game is in the top 3 games. if the game is in the top 3 then it should say: "common favourite game" if else then "uncommon favourite game"code:
TOP_3_GAMES = {'', 'CALL OF DUTY', 'LEAGUE OF LEGENDS', 'VALORANT'}
What is this code's purpose?$Error=[] ;
Assign pizzasInStore's first element's numCalories with the value in pizzasInStore's second element's numCalories.
#include <stdio.h>#include <string.h>
typedef struct Pizza_struct { char pizzaName[75]; int numCalories;} Pizza;
int main(void) { Pizza pizzasInStore[2];
scanf("%s", pizzasInStore[0].pizzaName); scanf("%d", &pizzasInStore[0].numCalories);
scanf("%s", pizzasInStore[1].pizzaName); scanf("%d", &pizzasInStore[1].numCalories);
/* Your code goes here */
printf("A %s slice contains %d calories.\n", pizzasInStore[0].pizzaName, pizzasInStore[0].numCalories); printf("A %s slice contains %d calories.\n", pizzasInStore[1].pizzaName, pizzasInStore[1].numCalories);
return 0;}
I tried 10 time but I cant solve it so please help me
Chapter 9 Solutions
Starting Out with Python (4th Edition)
Ch. 9.1 - An element in a dictionary has two parts. What are...Ch. 9.1 - Which part of a dictionary element must be...Ch. 9.1 - Suppose ' start' : 1472 is an element in a...Ch. 9.1 - Suppose a dictionary named employee has been...Ch. 9.1 - What will the following code display? stuff = {1 :...Ch. 9.1 - Prob. 6CPCh. 9.1 - Suppose a dictionary named inventory exists. What...Ch. 9.1 - What will the following code display? stuff = {1 :...Ch. 9.1 - What will the following code display? stuff = {1 :...Ch. 9.1 - What is the difference between the dictionary...
Ch. 9.1 - Prob. 11CPCh. 9.1 - Prob. 12CPCh. 9.1 - What does the values method return?Ch. 9.2 - Prob. 14CPCh. 9.2 - Prob. 15CPCh. 9.2 - Prob. 16CPCh. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - Prob. 22CPCh. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - Prob. 25CPCh. 9.2 - Prob. 26CPCh. 9.2 - After the following code executes, what elements...Ch. 9.2 - Prob. 28CPCh. 9.2 - After the following code executes, what elements...Ch. 9.2 - After the following code executes, what elements...Ch. 9.2 - After the following code executes, what elements...Ch. 9.2 - Prob. 32CPCh. 9.3 - Prob. 33CPCh. 9.3 - When you open a file for the purpose of saving a...Ch. 9.3 - When you open a file for the purpose of retrieving...Ch. 9.3 - Prob. 36CPCh. 9.3 - Prob. 37CPCh. 9.3 - Prob. 38CPCh. 9 - You can use the __________ operator to determine...Ch. 9 - You use ________ to delete an element from a...Ch. 9 - The ________ function returns the number of...Ch. 9 - You can use_________ to create an empty...Ch. 9 - The _______ method returns a randomly selected...Ch. 9 - The __________ method returns the value associated...Ch. 9 - The __________ dictionary method returns the value...Ch. 9 - The ________ method returns all of a dictionary's...Ch. 9 - The following function returns the number of...Ch. 9 - Prob. 10MCCh. 9 - Prob. 11MCCh. 9 - This set method removes an element, but does not...Ch. 9 - Prob. 13MCCh. 9 - Prob. 14MCCh. 9 - This operator can be used to find the difference...Ch. 9 - Prob. 16MCCh. 9 - Prob. 17MCCh. 9 - The keys in a dictionary must be mutable objects.Ch. 9 - Dictionaries are not sequences.Ch. 9 - Prob. 3TFCh. 9 - Prob. 4TFCh. 9 - The dictionary method popitem does not raise an...Ch. 9 - The following statement creates an empty...Ch. 9 - Prob. 7TFCh. 9 - Prob. 8TFCh. 9 - Prob. 9TFCh. 9 - Prob. 10TFCh. 9 - What will the following code display? dct =...Ch. 9 - What will the following code display? dct =...Ch. 9 - What will the following code display? dct =...Ch. 9 - What will the following code display? stuff =...Ch. 9 - How do you delete an element from a dictionary?Ch. 9 - How do you determine the number of elements that...Ch. 9 - Prob. 7SACh. 9 - What values will the following code display? (Dont...Ch. 9 - After the following statement executes, what...Ch. 9 - After the following statement executes, what...Ch. 9 - After the following statement executes, what...Ch. 9 - After the following statement executes, what...Ch. 9 - After the following statement executes, what...Ch. 9 - What will the following code display? myset =...Ch. 9 - After the following code executes, what elements...Ch. 9 - Prob. 16SACh. 9 - Prob. 17SACh. 9 - Prob. 18SACh. 9 - After the following code executes, what elements...Ch. 9 - Prob. 20SACh. 9 - Write a statement that creates a dictionary...Ch. 9 - Write a statement that creates an empty...Ch. 9 - Assume the variable dct references a dictionary....Ch. 9 - Assume the variable dct references a dictionary....Ch. 9 - Prob. 5AWCh. 9 - Prob. 6AWCh. 9 - Prob. 7AWCh. 9 - Prob. 8AWCh. 9 - Prob. 9AWCh. 9 - Prob. 10AWCh. 9 - Assume the variable dct references a dictionary....Ch. 9 - Write code that retrieves and unpickles the...Ch. 9 - Course information Write a program that creates a...Ch. 9 - Capital Quiz The Capital Quiz Problem Write a...Ch. 9 - File Encryption and Decryption Write a program...Ch. 9 - Unique Words Write a program that opens a...Ch. 9 - Prob. 5PECh. 9 - File Analysis Write a program that reads the...Ch. 9 - World Series Winners In this chapters source code...Ch. 9 - Name and Email Addresses Write a program that...Ch. 9 - Blackjack Simulation Previously in this chapter...Ch. 9 - Word Index Write a program that reads the contents...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Complete the table on the next page by filling in private, protected, public, or inaccessible in the right-hand...
Starting Out with C++ from Control Structures to Objects (9th Edition)
If a method in a subclass has the same signature as a method in the superclass, does the subclass method overlo...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
What action is possible with a static member function that isnt possible with an instance member function?
Starting Out with C++: Early Objects (9th Edition)
Use the following tables for your answers to questions 3.7 through 3.51 : PET_OWNER (OwnerID, OwnerLasst Name, ...
Database Concepts (7th Edition)
Private Sub Handles btnOutput.Click
End Sub
Introduction To Programming Using Visual Basic (11th Edition)
What is the purpose of the let constructs in functional languages?
Concepts of Programming Languages (11th 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
- Write EBNF formarrow_forwardText-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. Modify the application below (week3.py) so that the selection variable is sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. You will need to add an if statement in the choice() function to make the correct selection.arrow_forwardC# Question Write a statement that declares an array of integers called lotteryPicks and assigns it to the value returned from calling a method named FillArray. The method takes a 3 value parameters, a string called prompt and 2 integers called low and high. Use the following literal values, “lottery numbers”, 1 and 69 as actual parameters in the callarrow_forward
- Treasure Hunter description You are in front of a cave that has treasures. The cave canrepresented in a grid which has rows numbered from 1to , and of the columns numbered from 1 to . For this problem, define (?, )is the tile that is in the -th row and -column.There is a character in each tile, which indicates the type of that tile.Tiles can be floors, walls, or treasures that are sequentially representedwith the characters '.' (period), '#' (hashmark), and '*' (asterisk). You can passfloor and treasure tiles, but can't get past wall tiles.Initially, you are in a tile (??, ). You want to visit all the treasure squares, andtake the treasure. If you visit the treasure chest, then treasurewill be instantly taken, then the tile turns into a floor.In a move, if you are in a tile (?, ), then you can move tosquares immediately above (? 1, ), right (?, + 1), bottom (? + 1, ), and left (?, 1) of thecurrent plot. The tile you visit must not be off the grid, and must not be awall patch.Determine…arrow_forwardJAVA ONLYPlease create a code that checks if 'user' favourite game is in the top 3 games. if the game is in the top 3 then it should say: "common favourite game" if else then "uncommon favourite game"code: TOP_3_GAMES = {'', 'CALL OF DUTY', 'LEAGUE OF LEGENDS', 'VALORANT'}arrow_forward* A = [2-31; 20 -1; 1 4 5], then det(A) is 49 39 27 33 Other:arrow_forward
- products := [5] string {"bread", "milk", "eggs", "butter", "sugar"} price := [5] float64{1.29, 3.75, 3.33, 2.97, 5.28} use a "counting loop" to print the products with their prices example: bread: $1.29 milk: $3.75 eggs: $3.33 butter: $2.97 sugar: $5.28arrow_forwardIn Python, grades_dict = {'Wally': [87,96,70], 'Eva': [100,87,90], 'Sam': [94,77,90], 'Katie': [100,81,82], 'Bob': [83,65,85]} Write your own describe function that produces the same 8 statistical results, for each one of the columns, that the built-in describe() function does. Note 1: Use the sample standard deviation formula (that is, the denominator is: N-1) Note 2: Your algorithm should work for any number of columns not just for 5 Note 3: You can use the np.percentile() for the 25% and 75% percentile as well as the sort() built-in functionsarrow_forwardint grades[100]; int i; for (i=0;i <= 100;i++) { grades[i) = 100; } The above C++ code is the proper way to initialize the grades array, TRUE or FLASE True Falsearrow_forward
- Full Code: #include#include#include #define seed 5457 #define max(a,b) \({ __typeof__ (a) _a = (a); \__typeof__ (b) _b = (b); \_a > _b ? _a : _b; }) #define min(a,b) \({ __typeof__ (a) _a = (a); \__typeof__ (b) _b = (b); \_a < _b ? _a : _b; }) int initializeArray(int [], const int);void randperm(int b[], int n);int checkboard(int b[], int n);void displayboard(int b[], int n);double factorial(double n); int main(){srandom(seed);int mini[21], maxi[21];double meani[21], sizei[21], sizei_f[21];int n;for (n=4; n<=20; n++){int b[n];initializeArray(b,n);printf("~~~~~~~~~PRINTING FOR %d~~~~~~~~~~~~~\n",n); int total = 0;int x;for (x = 0; x<10; x++){int count = 1;randperm(b,n);while(!checkboard(b,n)){randperm(b,n); count++;}if (x==0){mini[n] = count;maxi[n] = count;displayboard(b,n);}mini[n] = min(mini[n],count);maxi[n] = max(maxi[n], count);total += count;}meani[n] = total/10.0f;double size = pow(n,n);sizei[n] = size;double size_f = factorial(n);sizei_f[n] = size_f;…arrow_forwardBulgarian solitaire def bulgarian_solitaire(piles, k): You are given a row of piles of pebbles, all identical, and a positive integer k so that the total number of pebbles in these piles equals k*(k+1)//2, the arithmetic sum formula that equals the sum of positive integers from 1 to k. Almost as if intended as a metaphor for the bleak daily life behind the Iron Curtain, all pebbles are identical and you don't have any choice in your moves. Each move picks up one pebble from each pile (even if doing so makes that pile vanish), and creates a new pile from the resulting handful. For example, starting with[7, 4, 2, 1, 1], the first move turns this into [6, 3, 1, 5]. The next move turns that into [5, 2, 4, 4], which then turns into the five-pile configuration [4, 1, 3, 3, 4], and so on. This function should count how many moves are needed to convert the given initial piles into the goal state where each number from 1 to k appears as the size of exactly one pile, and return that count. These…arrow_forwarddef division_calculator(a, b): ''' Question 4 You are asked to write a small division calculator, where you are taking 'a' as dividend and 'b' as the divider. You will need to return both the quotient and the remainder. Your returned result should be the: "a is divided by b, with the quotient equals 'quotient' and remainder equals 'remainder'" Note: You must use f-string to do this question. Args: a (int), b (int) Returns: string >>> division_calculator(3, 1) "3 is divided by 1, with the quotient equals 3 and remainder equals 0." ''' # print(division_calculator(9, 3))arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License