How does this code give me 17? (python)

j = 3

z = {}

z[2] = 1

z[7] = 3

z[5] = 2

for l in z:

j += l

print(j)


I don't understand where the 17 is coming from. I thought the square brackets were basically accessing the location (meaning the code would be like this "1, 2, 3." I even thought of individually adding 3 separately to all the numbers only for it to give me 15. Yeah, i've trying to understand this for 2 days lol.

Answers

Answer 1

Answer:

See explanation below and try out this code to see what exactly is happening

# Program

j = 3

z = { ]  # empty dictionary

print(z)

z[2] = 1 # z

print(z)

z[7] = 3

print(z)

z[5] = 2

print(z)   # prints out {2: 1, 7: 3, 5: 2}

for l in z:

   print("Initial value of j = ", j)

   print("Value of l(key) = ", l)

   j += l

  print("Updated value of j = ", j)

print("Final value of j=", j)

Explanation:

What you have is a dictionary object. We use { } to represent a dictionary. A dictionary consists of keys and values related to the keys. For example, you can have a  dictionary which contains names of students and their GPAs

This is declared as
student_grades = {"Amy": 4.3, "Zach":4.0", "Bill": 3.2}

The names are referred to as keys and the GPA as values
You can also have both key and value as integers. Fir example you could store the cubes of numbers from 1 to 5 in a dictionary

cubes = {1: 1, 2:8, 3: 27, 4: 64, 5:125}

If you wanted to add the cube for 6 then you would use cubes[6] = 216 This creates a new entry in the dictionary 6:216 so that the dictionary is now

cubes = {1: 1, 2:8, 3: 27, 4: 64, 5:125, 6:216}

In this short program here is what is happening


j = 3   # variable j created and value set to 3

z = { }  # this creates an empty dictionary named z

z[2] = 1  #adds an entry with key = 2 and value = 1; z = {2 : 1}

z[7} = 3  #key  7 and value 2 added => z = {2 : 1, 7 : 3}

z[5] = 2  #key 5, value 2 => z = {2: 1, 7 : 3, 5 : 2}

So now there are 3 entries in the dictionary i.e. 3 pairs of key-values

When you iterate through the dictionary as in

for l in z:
 - you are actually iterating over the keys so l = 2, 7 and 5 on each iteration

So you are accumulating the key values

Here is what happens

First execution of  loop => j = 3 , l = 2 (first key =2), j = 3 + 2 = 5

Second time: l = 7 (second key value) , j = 5 + 7 = 12

Third time: l = 5, j = 12 + 5 = 17

There is a lot more to dictionaries and sometimes it can get complicated. Suggest you search the internet for the same

Putting print() statements also helps you visualize what is happening. Code is provided in the answer section to help you


Related Questions

Discuss in detail which search engine you think is most functional for your needs. In your response, be sure to provide examples as to why this browser is most functional to your needs by using either a professional, academic, or personal setting.

Answers

The search engine that i think is most functional for my needs is Go ogle  and it is because when browsing for things in my field, it gives me the result I want as well as good optimization.

What is the most important search engine and why?

Go ogle currently leads the search market, with a startling 88.28% lead over Bing in second place.

It is one that dominates the market globally across all devices, according to statista and those of statcounter figures (in terms of desktop, mobile, and tablet).

Note that it give users the greatest results, the IT giant is said to be always changing as well as working hard to make better or improve the search engine algorithm.

Learn more about search engine from

https://brainly.com/question/671215
#SPJ1

Use the concepts and terms that you learned in this unit to describe the composition of this photograph:

Answers

The Elements of Composition in the above Photograph are:

FormTextureColorSpaceLightening

What is the composition in the photograph?

The photograph is made up of Geometric shapes which are known to be a  wonderful example of a photography composition.

An image's texture is how it appears to the eye. In photography, texture is emphasized by using shadow.

Note that Three factors such as hue, value, as well as saturation, define a color. Hence, Coloring describes the color's hue.

Learn more about Photography from

https://brainly.com/question/897676
#SPJ1



2. What does the unsigned decimal value of 99 as sum of powers of 2

Answers

Answer:

(99)₁₀  = (1100011)₂

Explanation:

I believe the question is asking you to convert 99 in base 10 to binary

If so, the above would be the answer easily computed using a programming calculator

If I have mis-interpreted your question, my apologies and you can report this answer

Kindly help me with this question

Answers

Answer:

yo traciahenny how are you :)

Identify a true statement of array.find(callback [, thisArg]) method.

A. It tests whether the condition returned by the callback function holds for all items in array.
B. It returns the value of the first element in the array that passes a test in the callback function.
C. It tests whether the condition returned by the callback function holds for at least one item in array.
D. It returns the index of the first element in the array that passes a test in the callback function.

Answers

Option c is correct. It tests whether the condition returned by the callback function holds for at least one item in array.

Every element in the array is put through the supplied test by the provided function using the every() method. It gives back a Boolean result. Until it locates the element for which callback function returns a false result, the every method calls the given callback function once for each element present in the array.

The every method immediately returns false if such an element is discovered. Every returns true if callback function does not return a truthy value for any of the items.

Only for array indexes with assigned values is callbackFn triggered. For empty slots in sparse arrays, it is not called.

The value of the element, the index of the element, and the Array object being traversed are passed as the three arguments to callbackFn.

To know more about callback function click on the link:

https://brainly.com/question/27961465

#SPJ4

What formula is used to determine a company's customer retention rate?

1. (The number of new customers during the period + the number of customers at the end of that
period)/ the number of customers at the start of the period x 100
2 . (The number of new customers during the period - the number of customers at the end of that
period)/ the number of customers at the start of the period / 100
3. (The number of customers at the end of the period - the number of new customers acquired
during the period)/ the number of customers at the start of the period x 100
4. (The number of new customers during the period - the number of customers at the end of that
period) x the number of customers at the start of the period x 100

Answers

The formula which is used to determine a company's customer retention rate is: 3. (The number of customers at the end of the period - the number of new customers acquired during the period)/ the number of customers at the start of the period x 100.

What is customer retention rate?

Customer retention rate can be defined as a measure of the number of customers that a business organization (company or firm) is able to successfully retain over a particular period of time and it is typically expressed as a percentage.

Mathematically, the customer retention rate of a business organization (company or firm) can be calculated by using this formula:

CRR = [(CE - CN)/CS] × 100

Where:

CRR represents customer retention rate of a company.CE represents the number of customers at the end of the period.CN represents the number of new customers acquired during the period.CS represents the number of customers at the start of the period.

In conclusion, we can reasonably infer and logically deduce that the customer retention rate of a company simply refers to the percentage of existing customers that a business organization (company or firm) is able to retain after a given period of time.

Read more on customer retention rate here: https://brainly.com/question/26675157

#SPJ1

To develop a website you can use the following technologies Except

Answers

To develop a website you can use the following technologies except search engine

This is because when creating a website, you need to use certain important things and programming languages such as HTML which means Hypertext Markup Language, and CSS, which means Cascading Style Sheets, Databases, Libraries, etc.

Hence, the use of a search engine is not used in the development of a website.

What is a Website?

This refers to the place where information is stored on the world wide web that can be accessed by anyone with internet access from anywhere around the world.

Hence, we can see that a search engine is used to find things on the internet and such is not used to create a website as there is the use of PHP which is known as Hypertext Preprocessor as it handles the security of the site and then CSS for the beautification of the website.

Read more about websites here:

https://brainly.com/question/25817628

#SPJ1

Analyze the (generic) concept of “windows” used on PCs and MACs as part of a user-friendly GUI interface(i.e. What are they? What are they used for? What do they look like? Do they move, and if so, how? Why do you think they were named “windows”?)

Answers

Microsoft adopted the name "Windows" because it allows different jobs and applications to run at the same time. Because a popular term like "Windows" cannot be trademarked, it is officially known as "Microsoft Windows." Microsoft Windows 1.0, launched in 1985, was the initial version of the operating system.

What is a Graphic User Interface Used for?

A graphical user interface (GUI) is computer software that allows a human to communicate with a computer.

The phrase "graphical user interface" (GUI) or simply "graphical interface" refers to a user interface that employs a mouse, icons, and windows. The name was coined to contrast with command line interfaces and full-screen character interfaces.

GUIs are important because they are:

Simple to useUsers can readily recognize, classify, and browse alternatives because data is represented by symbols, forms, and icons.Provide Data visualization which is recognized faster than words.Attractive.Shortcuts are provided.Multitasking is possible.

Learn more about Windows:
https://brainly.com/question/25243683
#SPJ1

PLEASE HELP!! QUICKLY! WILL GIVE BRAINLIEST!
Describe at least three important considerations when upgrading to new software in complete sentences.

Answers

Answer:

Storage

How it changes the layout

How it differs from the previous software

Explanation:

Storage is one of the most important things to think about because, if you do not have enough storage then the update only hurts you. Then plus you cannot even get the update in most cases. How it changes the layout and how it changes the computers is important because it can be what makes a person hate the newest software or not. If the layout changes to something you do not agree with, then it can leave a person all mixed up. Lastly how it differs is important because, how it differs from the previous can be the reason why or why not you even need the update. The differences could be good or bad. But whenever updating software always look at the terms and conditions, what it changes, and what it takes to update the software.

Write a python code that would ask the user to input a radius of a sphere and then would display the volume of the sphere. Then also display the square root of that number.

EXAMPLE: A radius of 5.5 should give a volume of 696.9099703213358 units cubed. The square root of that number is 26.399052451202408.

Answers

The python program that calculates the volume and the square of the volume is as follows

radius = float(input("Radius: "))

volume = (4.0/3.0) * (22.0/7.0) * radius**3

sqrtVolume = volume**0.5

print(f'The volume is {volume} units cubed')

print(f'The square root of that number is {sqrtVolume}')

How to write the program?

The complete program written in Python where comments are used to explain each line is as follows

#This gets the radius

radius = float(input("Radius: "))

#This calculates the volume

volume = (4.0/3.0) * (22.0/7.0) * radius**3

#This calculates the square root of the volume

sqrtVolume = volume**0.5

#This prints the volume

print(f'The volume is {volume} units cubed')

#This prints the square root of the volume

print(f'The square root of that number is {sqrtVolume}')

Read more about python programs at

https://brainly.com/question/26497128

#SPJ1

can anyone please help me really need help​

Answers

Answer:

Provided code for (b) and (c) in attached images

Explanation:

Please let me know if you have further questions

Lowell Thomas produced 4,000 units during his 40 hour workweek. Thomas's regular rate of pay is $0.12 per unit; he is paid an incentive bonus of four cents for each unit produced over 3,000. Thomas's overtime rate is a.$13.00 per hour b.$20.75 per hour c.$19.50 per hour d.$22.75 per hour

Answers

When Lowell Thomas produced 4,000 units during his 40 hour workweek and his regular rate of pay is $0.12 per unit, the overtime pay is C. $19.50 per hour.

What is overtime?

The number of hours a worker works in excess of what is required for a typical workweek is calculated as their overtime rate. Depending on how overtime is defined by the labor laws of each country and jurisdiction, this rate may have various implications in each.

The overtime premium or the overtime rate of pay are typical names for overtime compensation. The most common overtime rate is time and a half, which is 50% more than the employee's hourly pay. It means that you will receive 1.5 times your regular hourly rate for every hour of overtime worked.

The overtime will be calculated thus:

Multiply $0.12 4,000 = $480

Multiply regular pay, $0.04 1,000 = $40

Add: Bonus pay, $480 + $40 = $520,

Divide $520/40 = $13.00/hr

Multiply the rate: $13.00 * 1.5 = $19.50/hr.

Therefore, the overtime is $19.50.

Learn more about overtime on:

https://brainly.com/question/901346

#SPJ1

Use the concepts and terms that you learned in this unit to describe the composition of this photograph 10pts

Answers

The Elements of Composition in the above Photograph are:

LighteningTextureColorLightening

What is the composition in the photograph?

The photograph is made up of Geometric shapes which are known to be a  wonderful example of a photography composition.

An image's texture is how it appears to the eye. In photography, texture is emphasized by using shadow.

Note that the use of color as well as lightening is one that is seen in the image attached. Therefore, Coloring tells more about the color's hue.

Learn more about Photography from

https://brainly.com/question/897676
#SPJ1

can anyone help me please​

Answers

Answer:

See images below for code

Note the warning I have provided about program (c)

Explanation:

Note that I have given complete programs. But you are asked to only write the C segments corresponding to that problem.

In the third program, I have used the syntax

case 100 ... 102:
     printf("Paid\n");
     break;

This means that if the number lies in the range 100 -102 the corresponding statement will execute.

However, this is not recognized by all C compilers!

You can explain to the professor that you found this on the internet (stackoverflow.com is a great site for programing resources)

Otherwise you will have to split up that into 3 separate case statements as follows:

switch(inv)
{
case 100:
   printf("Paid\n");
   break;

case 101:
   printf("Paid\n");
   break;

case 102:
   printf("Paid\n");
   break;

Hope that helps you out


Which of the following correctly describes an external attack?

Answers

Your content is missing, I haven't seen what you mentioned

When a new encryption method is invented, you might think that it is kept secret so no one knows how to decode it. This actually isn’t the case; when someone invents a new encryption method, they publish the process and people begin trying to crack it. Why wouldn’t someone try to keep their encryption method secret? Explain your answer. Please help me!

Answers

Answer:

To test if the encryption method is effective.

Explanation:

If you kept a new encryption method secret, then when you use it hackers can try to crack it and whatever the encryption is protecting will be compromised. If you publish it beforehand while its not protecting anything, then you will know if its safe.

What do Advanced Placement courses and International Baccalaureate courses have in common?

A.
Both focus on career training and technical fields rather than college material.

B.
They teach remedial study skills to students who find high school courses challenging.

C.
They provide a way for students to enter the workforce right after high school.

D.
Both allow high school students access to college-level material.

Answers

The thing that  Advanced Placement courses and International Baccalaureate courses have in common is option D. Both allow high school students access to college-level material.

What is Advanced Placement courses and International Baccalaureate courses about?

Both the AP and IB programs, which are geared toward high school students, provide access to college-level coursework and the chance to receive college credit.

The AP program places a greater emphasis on subject-specific ability than the IB program does on encouraging students' creativity, critical thinking, and writing abilities. IB courses are more popular worldwide, but AP courses are far more accessible in US high schools.

Note that Both the AP and IB are excellent programs that colleges and universities take into account when deciding which students to admit. Even if you are enrolled in IB classes, you are still allowed to take AP courses and/or exams.

Learn more about Advanced Placement from

https://brainly.com/question/1193163
#SPJ1

Drag each tile to the correct box.
Mike is writing an essay using Microsoft Word on a Windows computer. Match each keyboard shortcut that he can use with its purpose.
Ctrl + X
F1
Purpose
pastes text saved in memory
runs the spelling and grammar check
opens the Help menu
cuts selected text
Ctrl + V
F7
Keyboard Shortcut

Answers

The correct matching of the tiles to their correct boxes is given below:

Ctrl + X

cuts selected text

runs the spelling and grammar check

F7

opens the Help menu

F1

Ctrl + V

pastes text saved in memory

What is Word Processing?

This refers to the device or program that is used to input data or information, make edits, process and format them, and then provide output to the finished product.

Hence, we can see that from the given question, it is clearly stated that Mike is writing an essay using Microsoft Word on a Windows computer and he needs to use the keyboard shortcuts.

With this in mind, the word processor he is using is known as MS Word or Microsoft Word and it has some keyboard shortcuts that can help Mike write, edit and format his essay so it would be in the right and proper way for him to output.

Read more about word processing here:

https://brainly.com/question/1596648

#SPJ1

Searching an Array for an Exact Match

Summary
In this lab, you use what you have learned about searching an array to find an exact match to complete a partially prewritten C++ program. The program uses an array that contains valid names for 10 cities in Michigan. You ask the user to enter a city name; your program then searches the array for that city name. If it is not found, the program should print a message that informs the user the city name is not found in the list of valid cities in Michigan.

The file provided for this lab includes the input statements and the necessary variable declarations. You need to use a loop to examine all the items in the array and test for a match. You also need to set a flag if there is a match and then test the flag variable to determine if you should print the the Not a city in Michigan. message. Comments in the code tell you where to write your statements. You can use the previous Mail Order program as a guide.

Instructions
Ensure the provided code file named MichiganCities.cpp is open.
Study the prewritten code to make sure you understand it.
Write a loop statement that examines the names of cities stored in the array.
Write code that tests for a match.
Write code that, when appropriate, prints the message Not a city in Michigan..
Execute the program by clicking the Run button at the bottom of the screen. Use the following as input:
Chicago
Brooklyn
Watervliet
Acme

CODE:
// MichiganCities.cpp - This program prints a message for invalid cities in Michigan.
// Input: Interactive
// Output: Error message or nothing

#include
#include
using namespace std;

int main()
{
// Declare variables
string inCity; // name of city to look up in array
const int NUM_CITIES = 10;
// Initialized array of cities
string citiesInMichigan[] = {"Acme", "Albion", "Detroit", "Watervliet", "Coloma", "Saginaw", "Richland", "Glenn", "Midland", "Brooklyn"};
bool foundIt = false; // Flag variable
int x; // Loop control variable

// Get user input
cout << "Enter name of city: ";
cin >> inCity;

// Write your loop here

// Write your test statement here to see if there is
// a match. Set the flag to true if city is found.




// Test to see if city was not found to determine if
// "Not a city in Michigan" message should be printed.


return 0;

} // End of main()

Answers

The program statements that complete the program are

for(x =0 ; x < NUM_CITIES; x++){

   if (citiesInMichigan[x] == inCity){

       foundIt = true;

   }

}

if(foundIt == false){

   cout<<"Not a city in Michigan";

}

How to complete the C++ program

The complete program in C++ language is as follows:

Note that the comments are used to explain each action

#include<iostream>

#include<string>

using namespace std;

int main(){

// Declare variables

string inCity; // name of city to look up in array

const int NUM_CITIES = 10;

// Initialized array of cities

string citiesInMichigan[] = {"Acme", "Albion", "Detroit", "Watervliet", "Coloma", "Saginaw", "Richland", "Glenn", "Midland", "Brooklyn"};

bool foundIt = false; // Flag variable

int x; // Loop control variable

// Get user input

cout << "Enter name of city: ";

cin >> inCity;

// Write your loop here

for(x =0 ; x < NUM_CITIES; x++){

   // Write your test statement here to see if there is

   // a match. Set the flag to true if city is found.

   if (citiesInMichigan[x] == inCity){

       foundIt = true;

   }

}

// Test to see if city was not found to determine if

// "Not a city in Michigan" message should be printed.

if(foundIt == false){

   cout<<"Not a city in Michigan";

}

return 0;

} // End of main()

Read more about programs at

https://brainly.com/question/26497128

#SPJ1

can anyone help me correct my code ​

Answers

Answer:

#include <stdio.h>

//below is the function prototype for the checkStatus function

//It simply tells the compiler what the return type and

//parameter types it takes. It is nothing more than a copy

//of the function header (line 16)

int checkStatus();

int main(){

   int status;

   status = checkStatus();

   printf("Your vaccination status code is %d\n", status);

 

}

int checkStatus(){

 int selection;

  printf("~ Status of vaccination ~\n");

  printf("-------------------------\n");

  printf("1. Pending for appointment\n");

  printf("2. Completed first dose\n");

  printf("3. Completed second dose\n");  

  printf("4. Exit\n\n");  

  printf("Enter your selection(1 - 4): ");

  scanf("%d", &selection);

   

  return selection;

}

Explanation:

With a _____, you can emphasize one data point by exploding it.
a. Column chart
b. 3-D Area chart
c. Line chart
d. 3-D Pie chart

Answers

With a _____, you can emphasize one data point by exploding it.

a. Column chart

b. 3-D Area chart

c. Line chart

d. 3-D Pie chart

With the help of a 3-D-Pie chart, you can emphasize one data point by exploding it. Thus, the correct option for this question is D.

What are the characteristics of a  3-D Pie chart?

The characteristics of a  3-D Pie chart are as follows:

It significantly contains each row as a separate slice of the pie.It is automatically labeled with two labels. This divides the given data into a series of segments in which each segment represents a particular category. 3-D pie chart comprises a circle that significantly disintegrates into sectors where each sector represents a proportion of the summation of all values in a datasheet.

According to the context of the question, it type of chart illustrates numerous data and information in a small piece of the segment that makes it easily understandable to the individuals.

Therefore, with the help of a 3-D-Pie chart, you can emphasize one data point by exploding it. Thus, the correct option for this question is D.

To learn more about the Pie charts, refer to the link:

https://brainly.com/question/796269

#SPJ2

What is the Occupational Outlook Handbook?

A.
a personality test and self-assessment that job seekers often take

B.
a book of job listings and promotion requirements for different regions

C.
a collection of salary information and job descriptions gathered by the government

D.
a training manual for guidance counselors and career counselors

Answers

Explanation:

a

a personality test and self assessment that job seeker often take

There are about 1,932 calories in a 14-pound watermelon. How many calories are there in 1 pound of the watermelon?

Answers

Answer:

138

Explanation:

1932:14

x:1

1932/14 = 138

Therefore x = 138

There are 138 calories per pound of watermelon

Hope that helps

4. Many people follow their favorite news sites through social media. This lets them get
stories they are interested in delivered directly to them and also benefits these
organizations since their stories get to the readers. What disadvantage might this have for
these news sites?
lot of replies many of them hostile

Answers

Teens who use social media may be subjected to peer pressure, cyber harassment, and increased mental health risk.

What is social media?

Social media refers to the means by which people interact in virtual communities and networks to create, share, and/or exchange information and ideas.

It is a useful tool for communicating with others both locally and globally, as well as for sharing, creating, and disseminating information.

Through reviews, marketing tactics, and advertising, social media can influence consumer purchasing decisions.

Multiple studies have found a strong link between excessive social media use and an increased risk of depression, anxiety, loneliness, self-harm, and self-arm ideation.

Negative experiences such as inadequacy about your life or appearance may be promoted by social media.

Thus, these can be the disadvantage to use sites like news as it may be fake sometimes.

For more details regarding social media, visit:

https://brainly.com/question/24687421

#SPJ1

three reason about family to make the most sense for my reader?

Answers

Answer:

Love

Comfortable

Trust

Explanation:

Three reasons why you should always be with your family is that most times they love you, and you love them. Being with them all of the time makes you more comfortable around them, being through their best and their worst. Lastly being with them so much, you get to know them, and with knowledge comes trust of knowledge. You already most times have trust with your family.

Which of the following is a programming language that is interpreted? (5 points)

Assembly
Java
Machine
Python

Answers

Answer: python


i just did a test on this

I am working on a code, but I keep getting a KeyError at line 71.

Traceback (most recent call last):
File "main.py", line 71, in
pronunciation += vowels_dict[key]
KeyError: 'l'

Why do I keep getting this error, and how do I fix my code to get rid of this error? Even when I got rid of that line, it gave me a KeyError at line 67.

Traceback (most recent call last):
File "main.py", line 67, in
pronunciation += consonants_dict[key]
KeyError: 'a'

My code is below:

valid_letters = 'aeioupkhlmnw'
invalid_letters = 'bcdfgjqstvxyz'

pronunciation = ''

consonants_dict = {
'p':'p',
'k':'k',
'h':'h',
'l':'l',
'm':'m',
'n':'n',
'w':'w',
'aw':'w',
'iw':'v',
'ew':'v',
'uw':'w',
'ow':'w'
}

vowels_dict = {
'a':'ah-',
'e':'eh-',
'i':'ee-',
'o':'oh-',
'u':'oo-'
}

vowels_no_hyphen_dict = {
'a':'ah',
'e':'eh',
'i':'ee',
'o':'oh',
'u':'oo'
}

vowels_dict_capitalized = {
'A':'Ah-',
'E':'Eh-',
'I':'Ee-',
'O':'Oh-',
'U':'Oo-'
}

vowel_pairs_dict = {
'ai':'eye-',
'ae':'eye-',
'ao':'ow-',
'au':'ow-',
'ei':'ay-',
'eu':'ehoo-',
'iu':'ew-',
'oi':'oy-',
'ou':'ow-',
'ui':'ooey-'
}

hawaiian_word = input('Enter a hawaiian word: ')
hawaiian_word = hawaiian_word.lower()

for i in range(len(hawaiian_word)):
if hawaiian_word[i] in valid_letters:
for key in hawaiian_word:
if hawaiian_word[i] in consonants_dict:
pronunciation += consonants_dict[key]
elif hawaiian_word[0][0] in vowels_dict:
pronunciation += vowels_dict_capitalized[key]
elif hawaiian_word[i] in vowels_dict:
pronunciation += vowels_dict[key]
elif hawaiian_word[i-2] in vowels_dict:
pronunciation += vowels_no_hyphen_dict[key]

if hawaiian_word[i] in invalid_letters:
print('Invalid word, ' + hawaiian_word[i] + ' is not a valid hawaiian character.')


print(hawaiian_word.upper() + ' is pronounced ' + pronunciation)

Answers

Answer:

multiple things probably

Explanation:

Well the code is a bit confusing to read since the lack of indents but I'll try my best to interpret what you were trying to do.

By the looks of the exception you provided, it seems that the key "I" does not exist in your dictionary: "vowels_dict"

Same thing applies with the key "a" not existing in your dictionary: "consonants_dict"

This makes sense since by looking at your code since they obviously don't exist in their respective dictionaries.

I tried pasting the code into VisualStudio to get a better look at it and I tried to fix the indenting and to ensure I got it correct I provided what I indented below

"

for i in range(len(hawaiian_word)):

   if hawaiian_word[i] in valid_letters:

       for key in hawaiian_word:

           if hawaiian_word[i] in consonants_dict:

               pronunciation += consonants_dict[key]

   elif hawaiian_word[0][0] in vowels_dict:

       pronunciation += vowels_dict_capitalized[key]

   elif hawaiian_word[i] in vowels_dict:

       pronunciation += vowels_dict[key]

   elif hawaiian_word[i-2] in vowels_dict:

       pronunciation += vowels_no_hyphen_dict[key]

   if hawaiian_word[i] in invalid_letters:

       print('Invalid word, ' + hawaiian_word[i] + ' is not a valid hawaiian character.')

"

So there are a few issues I noticed, and I'm not exactly sure how to fix them since I'm not exactly sure what is supposed to be done.

1.

hawaiian_word[0][0] is redundant and likely not what you think.

The think with this line is it first returns the first letter of hawaiian_word which is now a one letter string, and now you get the first letter of this one letter string... which is the same string. You're likely trying to do something else but like I explained I'm not quite sure.

2.

for key in hawaiian_word:

   if hawaiian_word[i] in consonants_dict:

       pronunciation += consonants_dict[key]

So no runtime error should occur here since you're first checking if the key even exists, but I noticed your dictionary is defined as: "consonants_dict = {

'p':'p',

'k':'k',

'h':'h',

'l':'l',

'm':'m',

'n':'n',

'w':'w',

'aw':'w',

'iw':'v',

'ew':'v',

'uw':'w',

'ow':'w'

}

"

and you'll notice the last few keys have two letters, except your for loop is going through the word one letter at a time so these keys will never be used.

3. (probably the cause of your error)

the line in each elif statement you have some code along the lines of: pronunciation += dictionary[key]

except this key is only being defined in the for loop and and never changes. This key is actually just going to be the last letter of the word in each case assuming the first if condition is met the for loop runs and key is finally set to the last letter and never changes until it runs again but even then after it finishes it is set to the last letter. This word is unlikely to be in each dictionary. I'm assuming you meant to actually do:

elif hawaiian_word[0][0] in vowels_dict:

   key = hawaiian_word[0][0]

   pronunciation += vowels_dict_capitalized[key]

elif hawaiian_word[i] in vowels_dict:

   key = hawaiian_word[i]

   pronunciation += vowels_dict[key]

elif hawaiian_word[i-2] in vowels_dict:

   key = hawaiian_word[i-2]

   pronunciation += vowels_no_hyphen_dict[key]

because you're checking if the current letter you're on in word is in the dictionary but then you use something completely different?

Which part of a MAC address is unique to each manufacturer?
a. the network identifier
b. the physical address
c. The OUI
d. The device manufacturer

Answers

Answer:  A. the network identifier

Hope this helps!

Question 8 of 10
Which words would best complete this if-then statement?
If you are taking Computer Science Essentials:
A. Then you
dislike computers.
B. Then you are a student.
C. Then you dislike programming.
D. Then you are a teenager.

Answers

The words that would best complete this if-then statement is option B. Then you are a student.

What is if-then statement in computer?

A statement with a hypothesis and a conclusion is known as a conditional statement (also known as an If-Then Statement). "If this happens, then that will happen" is another approach to define a conditional statement. The initial clause, or "if," of a conditional statement is the hypothesis.

Note that the hypothesis is a prediction of what will transpire in your experiment. The terms "IF" and "THEN" are frequently used when writing the hypothesis. For instance, "I will fail the exam if I don't read." Your independent and dependent variables are reflected in the "if" and "then" statements.

Therefore, it is an expression in a high-level programming language that compares two or more sets of data and evaluates the outcomes. The THEN instructions are followed if the results are accurate; otherwise,

Learn more about if-then statement from

https://brainly.com/question/4322377
#SPJ1

(while-loop). Generate a random integer from 1 to 100. Prompt the user to guess the number. Display "Too high" or "Too low", depending on the guess. When the user guesses the right number, display "You got it!". You must keep track of the number of times the user takes to guess the number and report it when the number is correct.
Hints: To generate the random number, use the one below:

import random as rd
answer = rd.randrange(1,101)

TEST CASES: Suppose the number to guess is 40.

Enter guess: 1-100: 50
Too high!

Enter guess: 1-100: 25
Too low!

Enter guess: 1-100: 35
Too low!

Enter guess: 1-100: 40
You got it!

You took 4 tries to guess the number.

Investment Problem: Multiplier Accumulator
Prompt the user to enter the initial investment amount, the annual interest, and the number of years for the investment.
Compute the balance that will be achieved at the end of each of the requested years. Round the balance to 2 decimal places.
Algorithm Hints:

Use a for-loop and range function to generate the year (1, 2, 3,…). The number of iterations is the number of years.
Using the formula (see below), compute the investment balance at the end of each year. Note that I know you could always use Python's exponentiation operator (**) to calculate the final result. But I want you to use iteration (looping) to find the answer! Hint: this is an example of an accumulator that uses multiplication.
For example, if you have $1 and get 4% interest, the amount at the end of the first five years would be:
FV = FV*(1 + APR)**year = 1 * (1 + 0.04) ** 1

FV = FV*(1 + APR)**year = 1 * (1 + 0.04) ** 2

FV = FV*(1 + APR)**year = 1 * (1 + 0.04) ** 3

FV = FV*(1 + APR)**year = 1 * (1 + 0.04) ** 4

FV = FV*(1 + APR)**year = 1 * (1 + 0.04) ** 5

etc.....

If you have an amount that is different than $1 (e.g., $10,000), multiplying $10,000 by the final FV quantity for each year will give you the future value for $10000.

Suggestion: to check your answer, use the exponentiation operator, calculate the result using the above formula, and compare that result with the one using your accumulator approach. The answers should be very close.
Also, you know that \n inside quotes generates a new line. Similarly, \t generates a tab stop, which you can use to generate the two columns in the output.
TEST CASE:

Enter initial investment: $5000

Enter interest rate: 2.5

Enter number of years: 29

Year Balance

1 $5125.0
2 $5253.12
3 $5384.45
4 $5519.06
5 $5657.04
6 $5798.47
7 $5943.43
8 $6092.01
9 $6244.31
10 $6400.42
11 $6560.43
12 $6724.44
13 $6892.56
14 $7064.87
15 $7241.49
16 $7422.53
17 $7608.09
18 $7798.29
19 $7993.25
20 $8193.08
21 $8397.91
22 $8607.86
23 $8823.05
24 $9043.63
25 $9269.72
26 $9501.46
27 $9739.0
28 $9982.48
29 $10232.04

Answers

Using the knowledge of computational language in JAVA it is possible to describe Generate a random integer from 1 to 100, Prompt the user to guess the number and  Display "Too high" or "Too low".

Writting the code:

import java.util.Random;

import java.util.Scanner;

 

public class GFG {

   public static void main(String[] args)

   {

 

       // stores actual and guess number

       int answer, guess;

 

         // maximum value is 100

       final int MAX = 100;

 

       // takes input using scanner

       Scanner in = new Scanner(System.in);

 

       // Random instance

       Random rand = new Random();

 

       boolean correct = false;

 

       // correct answer

       answer = rand.nextInt(MAX) + 1;

 

       // loop until the guess is correct

       while (!correct) {

 

           System.out.println(

               "Guess a number between 1 and 100: ");

 

           // guess value

           guess = in.nextInt();

 

           // if guess is greater than actual

           if (guess > answer) {

               System.out.println("Too high, try again");

           }

 

           // if guess is less than actual

           else if (guess < answer) {

               System.out.println("Too low, try again");

           }

 

           // guess is equal to actual value

           else {

 

               System.out.println(

                   "Yes, you guessed the number.");

 

               correct = true;

           }

       }

       System.exit(0);

   }

}

See more about JAVA at brainly.com/question/12975450

#SPJ1

Other Questions
2 Please help Anyone help pls giving 20 points Read the excerpt from The Great Gatsby. Then answer the question that follows.There was music from my neighbour's house through the summer nights. In his blue gardens men and girls came and went like moths among the whisperings and the champagne and the stars.Which of the following figurative language devices is present in this passage? Alliteration Idiom Personification Simile The clients loan papers were lost when the sales office was broken into. pls help me on this one i need them quick Iin a cross between two individuals bbgg and bbgg, what ratio of phenotypes would be expected in the offspring if the two genes show independent assortment?. Write in detail about the Himalayas? HURRY Find all solutions to the equation x3 + 100x + 8x2 = 800.10, 8, 1010, 8, 108, 10i, 10i8, 10i, 10i Solving a value mixture problem using a system of linear....Suppose that there are two types of tickets to a show: advance and same-day. Advance tickets cost $20 and same-day tickets cost $35. For one performance,there were 60 tickets sold in all, and the total amount paid for them was $1500. How many tickets of each type were sold?Number of advance tickets sold:Number of same-day tickets sold: 2 Find x and y130 answer The equation y = 0.44x + 87 models the cost y of renting a car if the car is driven x miles. According to the model, what is the best estimate of the cost for renting a car if you plan to drive 545 miles? Please round your answer to the nearest dollar. (A.) Given the one-to-one function f(x)= 7x - 2, find it's inverse function.Which is f ^ -1(x)= 1/7x - 2/7(B.) The graphs of f and f^ -1 are symmetric with respect to the line defined byy = _______ pc. Narrative Write a you made Thave been an incident in which narrow escape or your life would peril. (400-450 words). Saturdar Alight story about a in peril. Availability to manage the difficlties that are a part of life is called Together, Luke and James have never eaten more than 16 pieces of pizza at one time.Which equation describes y, the total number of pieces that Luke has eaten at one time givenx, the number of pieces that James has eaten?a. y _16-x c. y=16-x d. not here What is the distance between points A(2,9) and B(-2,6)? Round to the nearest whole number. Use a law of exponents to write (-3mn^5)^4 as a product of powers El seor Ramrez quiere organizar un festival, pero los artistas que quiere contratar estn ocupados. Completa las oraciones para contar lo que los artistas estn haciendo, usando el presente progresivo. 2. Plot events can also convey details that suggestthe theme. Closely reread paragraphs 18-29and explain how the details in these paragraphs.help you begin to identify the theme (or message) of the folktale. Highlight evidence from the textand make annotations to explain your ideas.in the wise old woman which muscle groups are used during riding, squats, push ups, planks, mountain climbers, trunk rotation, overhead press, lunges, arm extension, arm flexion, superman exercises on floor and burpees, etc.