Write a function called count_types that returns a dictionary with keys that are Pokemon types and values that are the number of times that type appears in the dataset. The order of the keys in the returned dictionary does not matter. In terms of efficiency, your solution should NOT iterate over the whole dataset once for each type of Pokemon since that would be overly inefficient. For example, assuming we have parsed pokemon_test.csv and stored it in a variable called data:

Answers

Answer 1

Answer:

Explanation:

The following code is written in Python. It creates a function called count_types which takes in three parameters. The pokemon in question, the data set, and a dictionary with all the pokemon types and values (Empty to start). Then it simply uses the built-in Python count feature to count the number of times that the Pokemon appears in the data set. Finally it saves that pokemon as a key and count as a value to the dictionary.

def count_types(pokemon, data, my_dict):

   count = data.count(pokemon)

   my_dict += {pokemon: count}


Related Questions

were is the hype house

Answers

Answer:

LA

Explanation:

where the rich people live

Answer:

los angeles

Explanation:

they're also very much in the shade right now

1. What does it mean for a website to be "responsive"?

Answers

this just means that the website will be able to render on many different sized screens

Create a program that allows the user to pick and enter a low and a high number. Your program should generate 10 random numbers between the low and high numbers picked by the user. Store these 10 random numbers in a 10 element array and output to the screen.
In java code please.

Answers

Answer:

import java.util.Scanner;

import java.util.Arrays;

import java.util.Random;

public class Main {

 public static void main(String[] args) {

   Scanner scan = new Scanner(System.in);

   System.out.print("Enter low: ");

   int low = scan.nextInt();

   System.out.print("Enter high: ");

   int high  = scan.nextInt();

   scan.close();

   int rndnumbers[] = new int[10];

   Random r = new Random();

   for(int i=0; i<rndnumbers.length; i++) {

     rndnumbers[i] = r.nextInt(high-low+1) + low;

   }

   for(int i=0; i<rndnumbers.length; i++) {

     System.out.printf("%d: %d\n", i, rndnumbers[i]);

   }

 }

}

Declare an array of 10 integers. Initialize the array with the following values: 000 101 202 303 404 505 606 707 808 909 Write a loop to search the array for a given number and tell the user if it was found. Do NOT write the entire program. Example: User input is 404 output is "found". User input is 246 output is "not found"

Answers

Answer:

In C++:

#include <iostream>

using namespace std;

int main(){

   int myArray[10] = {000, 101, 202, 303, 404, 505, 606, 707, 808, 909};

   int num;

   bool found = false;

   cout<<"Search for: ";

   cin>>num;

   for(int i = 0;i<10;i++){

       if(myArray[i]==num){

           found = true;

           break;

       }

   }

   if(found){ cout<<"found"; }

   else { cout<<"not found"; }

   return 0;

}

Explanation:

This line initializes the array

int myArray[10] = {000, 101, 202, 303, 404, 505, 606, 707, 808, 909};

This line declares num as integer

   int num;

This initializes boolean variable found to false

   bool found = false;

This prompts user for input

   cout<<"Search for: ";

This gets user input

   cin>>num;

This iterates through the array

   for(int i = 0;i<10;i++){

This checks if num is present in the array

       if(myArray[i]==num){

If yes, found is updated to true

           found = true;

And the loop is exited

           break;

       }

   }

If found is true, print "found"

   if(found){ cout<<"found"; }

If found is false, print "not found"

   else { cout<<"not found"; }

g Write a program that reads a list of words, and a character. The output of the program is every word in the list of words that contains the character at least once. For coding simplicity, follow each output word by a comma, even the last one. Assume at least one word in the list will contain the given character. The number of input words is always less than and equal to 10. If the user enters more than 10 words before the character, the program will output Too many words and exit.

Answers

Answer:

Here you go, alter this as you see fit :)

Explanation:

array = []

cnt = 0

while cnt < 11:

   x = input("Enter a word: ")

   array.append(x)

   cnt += 1

   y = input("Add another word?(Y/n):  ")

   if y.lower() == "n":

       break

letter = input("\nChoose a letter: ")

if len(letter) != 1:

   print("Error: too many characters")

   quit()

for n in range(len(array)):

   if letter.lower() in array[n].lower():

       print(array[n], end= ",")

. What projects would Excel best be used for?

Answers

Answer:

Projects that require spreadsheet organization and/or calculations between data

Explanation:

That is why Excel is a spreadsheet program

List the three ways Python can handle colors.

Answers

Answer:

Try using coloramapackage in python for text colour & has cross platform support across Windows & Linux. It can also be used in conjunction with existing ANSI libraries like Termcolor. This approach would be better than manually printing ASCII sequences for text colouring on terminals. from colorama import Fore, Back, Style

Explanation:

Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment.

Answer Choices:
A. num % 2 == 0;
B. num % 0 == 2;
C. num % 1 == 0;
D. num % 1 == 2;

Answers

Answer:

num % 2 == 0

Explanation:

Functions are collection of code segments that are executed when called or evoked

The correct statement that can replace "MISSING CONDITION" is (a) num % 2 == 0

From the question, we understand that the condition is to return true if the number is an even number.

To do this, we simply take the modulus of the number and 2.

If the result of the modulus is 0, then the number is evenIf otherwise, then the number is odd

Hence, the correct statement that can replace "MISSING CONDITION" is (a) num % 2 == 0

Read more about missing code segments at:

https://brainly.com/question/18430675

Does modern technology make our lives better,worse ,or doesn’t really make a change in your life ?Whats your opinion ?

Answers

It makes life better. Easy to communicate, everything you need is at your disposal, from whether forecasts to a calculator on your phone

what 80s Disney movie was called the movie that nearly killed Disney? P.S. look it up

Answers

Answer:

The black cauldron

Explanation:

it was the most expensive animated film of its time ever made

Answer: The Black Couldren.

Explanation:

What is the output of the following code snippet if the variable named cost contains 100? if cost < 70 or cost > 150 : discount = 0.8 * cost else : discount = cost print("Your cost is ", discount)

Answers

Answer:

The output is: Your cost is  100

Explanation:

Given

The above code snippet

and

[tex]cost = 100[/tex]

Required

Determine the output of the code

if cost < 70 or cost > 150

The above condition checks if cost is less than 70 or cost is greater than 150

This condition is false because 100 is neither less than 70 nor is it greater than 150

So, the else statement will be executed.

discount = cost

Which means

discount = 100

So, the print instruction will print: Your cost is  100

String[][] arr = {{"Hello,", "Hi,", "Hey,"}, {"it's", "it is", "it really is"}, {"nice", "great", "a pleasure"},

{"to", "to get to", "to finally"}, {"meet", "see", "catch up with"},
{"you", "you again", "you all"}};
for (int j = 0; j < arr.length; j++) {
for (int k = 0; k < arr[0].length; k++) {
if (k == 1) { System.out.print(arr[j][k] + " ");
}
}
}
What, if anything, is printed when the code segment is executed?

Answers

Answer:

Explanation:

The code that will be printed would be the following...

Hi, it is great to get to see you again

This is mainly due to the argument (k==1), this argument is basically stating that it will run the code to print out the value of second element in each array within the arr array. Therefore, it printed out the second element within each sub array to get the above sentence.

When the code segment is executed, the output is "Hi, it is great to get to see you again "

In the code segment, we have the following loop statements

for (int j = 0; j < arr.length; j++) {for (int k = 0; k < arr[0].length; k++) {

The first loop iterates through all elements in the array

The second loop also iterates through all the elements of the array.

However, the if statement ensures that only the elements in index 1 are printed, followed by a space

The elements at index 1 are:

"Hi," "it" "is" "great" "to" "get" "to" "see" "you" "again"

Hence, the output of the code segments is "Hi, it is great to get to see you again "

Read more about loops and conditional statements at:

https://brainly.com/question/26098908

Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems. A. procedural abstraction B. API C. modularity D. library

Answers

Answer:

procedural abstraction

Explanation:

The term that refers to a solution to a large problem that is based on the solutions of smaller subproblems is A. procedural abstraction.

Procedural abstraction simply means writing code sections that are generalized by having variable parameters.

Procedural abstraction is essential as it allows us to think about a framework and postpone details for later. It's a solution to a large problem that is based on the solutions of smaller subproblems.

Read related link on:

https://brainly.com/question/12908738

Veronica is looking for a reliable website with information about how old you have to be to use social media. What should she look for?

Answers

Answer:

The URL of the website

Explanation:

Look for .gov and .edu as they are often reliable sources

What styles can the calendar be printed in? Check all that apply.

Quick
Daily style
Weekly Agenda style
Weekly Calendar style
Monthly Agenda style
Monthly style
Bifold style
Trifold style

Answers

Please Help! Unit 6: Lesson 1 - Coding Activity 2
Instructions: Hemachandra numbers (more commonly known as Fibonacci numbers) are found by starting with two numbers then finding the next number by adding the previous two numbers together. The most common starting numbers are 0 and 1 giving the numbers 0, 1, 1, 2, 3, 5...
The main method from this class contains code which is intended to fill an array of length 10 with these Hemachandra numbers, then print the value of the number in the array at the index entered by the user. For example if the user inputs 3 then the program should output 2, while if the user inputs 6 then the program should output 8. Debug this code so it works as intended.

The Code Given:

import java.util.Scanner;

public class U6_L1_Activity_Two{
public static void main(String[] args){
int[h] = new int[10];
0 = h[0];
1 = h[1];
h[2] = h[0] + h[1];
h[3] = h[1] + h[2];
h[4] = h[2] + h[3];
h[5] = h[3] + h[4];
h[6] = h[4] + h[5];
h[7] = h[5] + h[6];
h[8] = h[6] + h[7]
h[9] = h[7] + h[8];
h[10] = h[8] + h[9];
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
if (i >= 0 && i < 10)
System.out.println(h(i));
}
}

Answer:

Daily style

Weekly Agenda style

Weekly Calendar style

Monthly style

Trifold style

or

B, C, D, F, H

do you know that the 80s was not one of Disney's best decades? what was a reason?

Answers

Answer:

They produced a movie called the black couldren that nearly killed them.

write a function insert_string_multiple_times() that has four arguments: a string, an index into the string, a string to insert, and a count. the function will return a string with count copies of the insert-string inserted starting at the index. note: you should only write the function. do not put any statements outside of the function. examples: insert_string_multiple_times('123456789',3,'xy',3) '123xyxyxy456789' insert_string_multiple_times('helloworld',5,'.',4) 'hello....world' insert_string_multiple_times('abc',0,'a',2) 'aaabc' insert_string_multiple_times('abc',0,'a',0) 'abc'

Answers

Answer:

Written in Python:

def insert_string_multiple_times(str1,indto,str2,count):

   splitstr = str1[:indto]

   for i in range(count):

       splitstr+=str2

       

   splitstr +=str1[indto:]

   print(splitstr)

Explanation:

This line defines the method

def insert_string_multiple_times(str1,indto,str2,count):

In the above definition:

str1 represents the string

indto represents index to insert a new string

str2 represents the new string to insert

count represents the number of times str2 is to be inserted

This gets the substring from the beginning to indto - 1

   splitstr = str1[:indto]

This performs an iterative operation

   for i in range(count):

This appends str2 to the first part of the separated string

       splitstr+=str2

This appends the remaining part of the separated string        

   splitstr +=str1[indto:]

This prints the new string

   print(splitstr)

what is musical technology specifically, the origins of its genesis & its importance to the baroque era

Answers

Answer:

There were three important features to Baroque music: a focus on upper and lower tones; a focus on layered melodies; an increase in orchestra size. Johann Sebastian Bach was better known in his day as an organist. George Frideric Handel wrote Messiah as a counterargument against the Catholic Church

What does the term "death by powerpoint" refer to when dealing with Powerpoint presentations?

Answers

Answer:

Death by PowerPoint is a phenomenon caused by the poor use of presentation software. Key contributors to death by PowerPoint include confusing graphics, slides with too much text and presenters whose idea of a good presentation is to read 40 slides out loud.

Explanation:

Hope this helps :)

Giving brainliest if you answer question.

Answers

The length of the inclined plane divided by the vertical rise, or you can call it run to rise ratio. The mechanical advantage would increase as the slope of the incline decreases, but problem is that the load will have to go a longer distance. The mechanical advantage would be slope of the incline. I also got confused on a question like this and did some research. Hope this helps!

Write a program with the total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. The input should be an integer, with the unit as "cents". For example, the input of 126 refers to 126 cents. 1 Dollar = 100 cents 1 Quarter = 25 cents 1 Dime = 10 cents 1 Nickel = 5 cents 1 Penny = 1 cent Ex: If the input is:

Answers

Answer:

In Python:

cents = int(input("Cents: "))

dollars = int(cents/100)

quarters = int((cents - 100*dollars)/25)

dimes = int((cents - 100*dollars- 25*quarters)/10)

nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)

pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels

if not(dollars == 0):

   if dollars > 1:

       print(str(dollars)+" dollars")

   else:

       print(str(dollars)+" dollar")

if not(quarters == 0):

   if quarters > 1:

       print(str(quarters)+" quarters")

   else:

       print(str(quarters)+" quarter")

if not(dimes == 0):

   if dimes > 1:

       print(str(dimes)+" dimes")

   else:

       print(str(dimes)+" dime")

if not(nickels == 0):

   if nickels > 1:

       print(str(nickels)+" nickels")

   else:

       print(str(nickels)+" nickel")

if not(pennies == 0):

   if pennies > 1:

       print(str(pennies)+" pennies")

   else:

       print(str(pennies)+" penny")

   

Explanation:

A prompt to input amount in cents

cents = int(input("Cents: "))

Convert cents to dollars

dollars = int(cents/100)

Convert the remaining cents to quarters

quarters = int((cents - 100*dollars)/25)

Convert the remaining cents to dimes

dimes = int((cents - 100*dollars- 25*quarters)/10)

Convert the remaining cents to nickels

nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)

Convert the remaining cents to pennies

pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels

This checks if dollars is not 0

if not(dollars == 0):

If greater than 1, it prints dollars (plural)

   if dollars > 1:

       print(str(dollars)+" dollars")

Otherwise, prints dollar (singular)

   else:

       print(str(dollars)+" dollar")

This checks if quarters is not 0

if not(quarters == 0):

If greater than 1, it prints quarters (plural)

   if quarters > 1:

       print(str(quarters)+" quarters")

Otherwise, prints quarter (singular)

   else:

       print(str(quarters)+" quarter")

This checks if dimes is not 0

if not(dimes == 0):

If greater than 1, it prints dimes (plural)

   if dimes > 1:

       print(str(dimes)+" dimes")

Otherwise, prints dime (singular)

   else:

       print(str(dimes)+" dime")

This checks if nickels is not 0

if not(nickels == 0):

If greater than 1, it prints nickels (plural)

   if nickels > 1:

       print(str(nickels)+" nickels")

Otherwise, prints nickel (singular)

   else:

       print(str(nickels)+" nickel")

This checks if pennies is not 0

if not(pennies == 0):

If greater than 1, it prints pennies (plural)

   if pennies > 1:

       print(str(pennies)+" pennies")

Otherwise, prints penny (singular)

   else:

       print(str(pennies)+" penny")

   

is English-like, easy to learn and use. uses short descriptive word to represent each of the machine-language instructions. is computer's native language. translates the entire source code into a machine-code file. processes one statement at a time, translates it to the machine code, and executes it. is a program written in a high-level programming language. is a program that translates assembly-language code into machine code.

Answers

Answer:

The appropriate choice is "Assembly Language ".

Explanation:

Such assembly languages were indeed low-level software packages designed for something like a mobile device or indeed any programmable machine. Written primarily throughout assembly languages shall be constructed by the assembler. Each assembler seems to have its programming languages, which would be focused on a particular computational physics.

This function finds the minimum number in a list. What should be replaced with in order for this function to operate as expected?

Answer choices:

A. numList[i] = min;
B. min = numList[i];
C. min = numList;
D. numList = min;

Answers

Answer: a

Explanation:

Just took the test

Write the Number class that can be used to test if the number is odd, even, and perfect. A perfect number is any number that is equal to the sum of its divisors. Write the NumberAnalyzer class that has an ArrayList of Number to determine how many numbers in the list are odd, even, and perfect.

Answers

Answer:

Explanation:

The following code is written in Python. It creates a class that takes in one ArrayList parameter and loops through it and calls two functions that check if the numbers are Perfect, Odd, or Even. Then it goes counting each and printing the final results to the screen.

class NumberAnalyzer:

   def __init__(self, myArray):

       perfect = 0

       odd = 0

       even = 0

       for element in myArray:

           if self.isPerfect(element) == True:

               perfect += 1

           else:

               if self.isEven(element) == True:

                   even += 1

               else:

                   odd += 1

       print("# of Perfect elements: " + str(perfect))

       print("# of Even elements: " + str(even))

       print("# of Odd elements: " + str(odd))

   def isPerfect(self, number):

       sum = 1

       i = 2

       while i * i <= number:

           if number % i == 0:

               sum = sum + i + number / i

           i += 1

       if number == sum:

           return True

       else:

           return False

   def isEven(self, number):

       if (number % 2) == 0:

           return True

       else:

           return False

You plan on using cost based pricing. The cost of your product is 10, and you are planning a 30% mark up. What should the price of your product be?

Answers

Answer:

Selling price= $13

Explanation:

Giving the following information:

The cost of your product is $10, and you are planning a 30% mark-up.

The price of the product is calculated by adding to the manufacturing costs a predetermined percentage.

Selling price= 10*1.3

Selling price= $13

Hope this helps :)

I need help on these three questions I would really appreciate it

Answers

Answer:

True

c

void

Explanation:

I dont know how i know this...

x = 2. x+=15

Int returns number Boolean returns true of false . . . void return none.

Do not use the scanner class or any other user input request. You application should be self-contained and run without user input.

Assignment Objectives

Practice on implementing inheritance in Java

FootballPlayer will extend a new class, Person

Overriding methods

toString( ) (Links to an external site.)Links to an external site. which is a method from the Object class, will be implemented in OffensiveLine, FootballPlayer, Person and Height

Keep working with more complex classes

in the same way that FootballPlayer had a class as an attribute (Height height), OffensiveLine will have FootballPlayer as an attribute

Deliverables

A zipped Java project according to the How to submit Labs and Assignments guide.

O.O. Requirements (these items will be part of your grade)

One class, one file. Don't create multiple classes in the same .java file

Don't use static variables and methods

Encapsulation: make sure you protect your class variables and provide access to them through get and set methods

all the classes are required to have a constructor that receives all the attributes as parameters and update the attributes accordingly

Follow Horstmann's Java Language Coding GuidelinesLinks to an external site.

Organized in packages (MVC - Model - View Controller)

Contents

Person int number app Creates a Model object * String name Height * String position Height height int feet int inches int weight Model . String hometown . String highSchool .String toString( ) Creates three FootballPlayer objects Creates an OffensiveLine object using the three FootballPlayer objects Displays OffensiveLine information Displays OffensiveLine average weight . String toString() extends FootballPlayer * String position . String toString() int number OffensiveLine .FootballPlayer center .FootballPlayer offensiveGuard .FootballPlayer offensiveTackle . String toString()

Create a Netbeans project (or keep developing from your previous lab) with

App.java

Model

Model.java

FootballPlayer.java

Height.java

Person.java

OffensiveLine.java

Functionality

The application App creates a Model object

The Model class

creates 3 FootballPlayer objects

creates an OffensiveLine object using the 3 FootballPlayer objects

displays information about the OffensiveLine object and its 3 players

it is a requirement that this should be done using the toString( ) method in OffensiveLine, which will use toString( ) in FootballPlayer

displays the average weight of the OffensiveLine

this will be done using the averageWeight in the OffensiveLine

The classes

App

it has the main method which is the method that Java looks for and runs to start any application

it creates an object (an instance) of the Model class

Model

this is the class where all the action is going to happen

it creates three football players

it creates an OffensiveLine object using the three players

displays information about the OffensiveLine

this has to be done using the OffensiveLine object

this is really information about its 3 players

the format is free as long as it contains all the information about each of the 3 players

displays the average weight of the OffensiveLine

this has to be done using the OffensiveLine object

this has to call the averageWeight method in OffensiveLine

Personhas the following attributes

String name;

Height height;

int weight;

String hometown;

String highSchool;

and a method

String toString( )

toString( ) overrides the superclass Object toString( ) method

toString( ) returns information about this class attributes as a String

encapsulation

if you want other classes in the same package yo have access to the attributes, you need to make them protected instead of private.

see more here.

FootballPlayerhas the following attributes

int number;

String position;

and a method

String toString( )

toString( ) overrides the superclass Object toString( ) method

toString( ) returns information about this class attributes as a String

Height

it is a class (or type) which is used in Person defining the type of the attribute height

it has two attributes

int feet;

int inches

and a method

String toString( )

toString( ) overrides the superclass Object toString( ) method

toString( ) returns information about this class attributes as a String

it returns a formatted string with feet and inches

for instance: 5'2"

OffensiveLinehas the following attributes

FootballPlayer center;

FootballPlayer offensiveGuard;

FootballPlayer offensiveTackle;

They might also be stored in an ArrayList

and two methodsString toString( )

toString( ) overrides the superclass Object toString( ) method

toString( ) returns information about the 3 players attributes as a String

int averageWeight()

calculates and returns the average weigh of the OffensiveLine.

it is calculated based on the weight of each of its players

Answers

يتريرينييننيخيوويميمسكيك

The return value is a one-dimensional array that contains two elements. These two elements indicate the rows and column indices of the largest element in the two-dimensional array. Write a test program that prompts the user to enter a two-dimensional array and displays the location of the largest element in the array.

Answers

Answer:

In Java:

import java.util.Scanner;  

import java.util.Arrays;  

public class Main  {  

public static void main(String args[])  {  

Scanner input = new Scanner(System.in);

int row, col;  

System.out.print("Rows: ");    row = input.nextInt();

System.out.print("Cols: ");     col = input.nextInt();  

int[][] Array2D = new int[row][col];

System.out.print("Enter array elements: ");

for(int i =0;i<row;i++){    

    for(int j =0;j<col;j++){

        Array2D[i][j] = input.nextInt();  

    }     }

 

int[] maxarray = findmax(Array2D,row,col);

System.out.println("Row: "+(maxarray[0]+1));

System.out.println("Column: "+(maxarray[1]+1));

}  

public static int[] findmax(int[][] Array2D,int row, int col)   {  

int max = Array2D[0][0];

int []maxitem = new int [2];

for(int i =0;i<row;i++){

    for(int j =0;j<col;j++){

        if(Array2D[i][j] > max){  

            maxitem[0] = i;

            maxitem[1] = j; } }    }

 

return maxitem;  

}  

}

Explanation:

The next two lines import the scanner and array libraries

import java.util.Scanner;  

import java.util.Arrays;  

The class of the program

public class Main  {  

The main method begins here

public static void main(String args[])  {  

The scanner function is called in the program

Scanner input = new Scanner(System.in);

This declares the array row and column

int row, col;

This next instructions prompt the user for rows and get the row input  

System.out.print("Rows: ");    row = input.nextInt();

This next instructions prompt the user for columns and get the column input  

System.out.print("Cols: ");     col = input.nextInt();  

This declares the 2D array

int[][] Array2D = new int[row][col];

This prompts the user for array elements

System.out.print("Enter array elements: ");

The following iteration populates the 2D array

for(int i =0;i<row;i++){    

    for(int j =0;j<col;j++){

        Array2D[i][j] = input.nextInt();  

    }     }

This calls the findmax function. The returned array of the function is saved in maxarray  

int[] maxarray = findmax(Array2D,row,col);

This prints the row position

System.out.println("Row: "+(maxarray[0]+1));

This prints the column position

System.out.println("Column: "+(maxarray[1]+1));

The main method ends here

}  

The findmax function begins here

public static int[] findmax(int[][] Array2D,int row, int col)   {  

This initializes the maximum to the first element of the array

int max = Array2D[0][0];

This declares maxitem. The array gets the position of the maximum element

int []maxitem = new int [2];

The following iteration gets the position of the maximum element

for(int i =0;i<row;i++){

    for(int j =0;j<col;j++){

        if(Array2D[i][j] > max){  

            maxitem[0] = i; -- The row position is saved in index 0

            maxitem[1] = j;  -- The column position is saved in index 1} }    }

This returns the 1 d array

return maxitem;  

}  

Segmentation Faults Recall what causes segmentation fault and bus errors from lecture. Common cause is an invalid pointer or address that is being dereferenced by the C program. Use the program average.c from the assignment page for this exercise. The program is intended to find the average of all the numbers inputted by the user. Currently, it has a bus error if the input exceeds one number. Load average.c into gdb with all the appropriate information and run it. Gdb will trap on the segmentation fault and give you back the prompt. First find where the program execution ended by using backtrace (bt as shortcut) which will print out a stack trace. Find the exact line that caused the segmentation fault.
Q13. What line caused the segmentation fault?
Q14. How do you fix the line so it works properly?
You can recompile the code and run the program again. The program now reads all the input values but the average calculated is still incorrect. Use gdb to fix the program by looking at the output of read_values. To do this, either set a breakpoint using the line number or set a breakpoint in the read_values function. Then continue executing to the end of the function and view the values being returned. (To run until the end of the current function, use the finish command).
Q15. What is the bug? How do you fix it?
//average.c
#include
/*
Read a set of values from the user.
Store the sum in the sum variable and return the number of values
read.
*/
int read_values(double sum) {
int values=0,input=0;
sum = 0;
printf("Enter input values (enter 0 to finish):\n");
scanf("%d",&input);
while(input != 0) {
values++;
sum += input;
scanf("%d",input);
}
return values;
}
int main() {
double sum=0;
int values;
values = read_values(sum);
printf("Average: %g\n",sum/values);
return 0;
}

Answers

Answer:

See Explanation

Explanation:

Q13. Line that caused the segmentation fault?

The segmentation fault was caused by line 15 i.e. scanf("%d",input);

Q14. How the line was fixed?

The reason for the segmentation fault is that the instruction to get input from the user into the integer variable "input" was not done correctly.

The correction to this is to modify scanf("d",input) to scanf("%d",input);

Q15. The bug?

The bug is that the method needs to return two value; the sum of the inputted numbers and the count of the inputted numbers.

However. it only returns the count of the inputted number.

So, the average is calculated as: 0/count, which will always be 0

How it was fixed?

First, change the method definition to: void and also include an array as one of its parameters.

void read_values(double sum, double arr []) {

Next:

assign sum to arr[0] and values to arr[1]

In the main method:

Declare an array variable: double arr [2];

Call the read_values function using: read_values(sum,arr);

Get the sum and values using:

sum = arr[0];

values = arr[1];

Lastly, calculate and print average:

printf("Average: %g\n",sum/values);

See attachment for complete modified program

Define the _make method, which takes one iterable argument (and no self argument: the purpose of _make is to make a new object; see how it is called below); it returns a new object whose fields (in the order they were specified) are bound to the values in the interable (in that same order). For example, if we called Point._make((0,1)) the result returned is a new Point object whose x attribute is bound to 0 and whose y attribute is bound to 1.

Answers

This picture will show you the answer and guide the way to victory

We can actually see that the _make method is known to be a function that creates named tuple type.

What is _make method?

_make method is seen in Python programming which is used to create a named tuple type instantly. It can be used for conversion of objects e.gtuple, list, etc. to named tuple.

Thus, we see the definition of _make method.

Learn more about Python on https://brainly.com/question/26497128

#SPJ2

Other Questions
I need help with this please 3. Not all of the founders agreed with Jefferson's view on the separation of church and state. Do you agree with Jefferson or with hisopponents? Explain. please help me im struggling :cccWhich two details from the passage best support the inference in Part A?"A mechanical doll could have done what she did.""It had begun just as all her other days began: bells at dawn, maids running in and out to hurry her into her clothes, and the Assistant Chamberlain barking a schedule""She wouldn't get to do so, of course, but she could hope. She always hoped.""She was decoration, giving people a bit of the royal glamor without ever doing any real work." 1. There are five questions on a multiple-choice test. Each question has four possibleanswers. Savanna did not study for the test, randomly picks the answers, and submitsthe exam. Find the probability that:Savanna answers the first question correctly.b. Savanna answers the first, second, third, fourth, and fifth questions correctly. Which of the following is not true about vitamins?A. Vitamins assist in forming bone and tissue.B. Vitamins are only found in plants.C. Vitamins help your cells function properly.D. Vitamins help the body use proteins, carbohydrates, and fats. Pure acetic acid is often called glacial acetic acid because it is purified by fractional freezing at its melting point of 16.6 C. At 1 atm, a flask containing several moles of acetic acid at 16.6 C is briefly lowered into an infinitely large ice-water bath. When it is removed it is found that exactly 1 mol of acetic acid has frozen. Given: H_fusion,acetic acid = 11.45kJ/mol and H_fusion, H2O= 6.01 kJ/mol.Required:a. What is the change in entropy of the acetic acid? b. What is the change in entropy of the water bath? c. Now consider that the water bath and acetic acid are the same system. What is the entropy change for the combined system? Is the process reversible or irreversible? Why? How can you minimize burn and fire hazards in the kitchen?AWear tight-fitting clothing when working near the stove.BAll of these answer choices are correct.Turn the pan's handle toward the back of the stove.DKeep dish towels and paper towels off of and away from the stove. Which of the following was not an effect of the United States joining the war?A. The war tipped the balance of power in favor of the allies , allowing them to win the war B.The war cost so much money that it plunged the U.S. into the Great Depression . C. The war boosted the United States ' power and prestige making them a world power for the first time. D. The war emboldened President Wilson to suggest a League of Nations to prevent wars like this from happening again . PLEASE HELP QUICKK!!Suppose (-7, -3) is reflected across the x-axis, and then the y-axis. what will be the new coordinates? Can someone help me? PLZ HELP ME I BEG OF YOU!?! Mr. Alvarez was charged in the Central District of California with two counts of falsely representing that he had been awarded the Medal of Honor in violation of the Stolen Valor Act of 2005. Which branch of government would determine if he was guilty or innocent of this crime?Question 3 options:Judicial Executive Legislative John's ordinary step covers 18 inches. How many steps does he take in walking 10 yards? Which of the following is not a goal of a narrative essay?to illustrate a universal themeto make a point about lifeto disguise any obvious point of viewto use traditional storytelling methods to interest readers 14. What is the value of the missing angle? (1 point)1517575-115135O 129O 1530O 16900720 If two boys push a box in the SAME direction, each with a FORCE of 10N, then the total (net) force will be 1.Let's say you could see inside of the nucleus of a Silver atom and inside the nucleus of a Cobalt atom. How would they look different?2.If a substance has no (or almost no) likelihood of undergoing a chemical reaction with another element it is said to be:a.Ionizedb.Malleablec.Reactived.Inerte.An Isotope3. Evaluate this sentence and explain why it is incorrect:Neon came into contact with Iron and the reaction was very explosive.4. Mr. Carney does and experiment. He weighs himself. He weighs 210 lbs. He then runs 15 miles. Then weighs himself. He now weighs 200 lbs.Explain the conservation of mass using this experiment as your example.NEED ANSWERS NOW DUE TODAY in a series connection of bulbs,if one bulb fails.why do all other bulbs go off 1. All of the students in a class are younger than 12 years. Write an inequality thatrepresents the ages a of the students. Amanda and her brother, Brian, are making chocolate milk. Amanda mixes 1 ounce of chocolate syrup and 6 ounces of milk in her cup. Brian mixes 2 ounces of chocolate syrup and 10 ounces of milk in his cup. Whose milk is more chocolaty?