1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
WINSTONCH [101]
2 years ago
15

Write a function fight(first_pokemon, second_pokemon) that takes the dictionaries for two pokemon and computes the winner of a f

ight. The winner of the fight must be the pokemon with the greatest sum of all stats. You must also write a stats(pokemon) function that takes a pokemon's dictionary and returns an integer representing the sum of that pokemon's stats.
Computers and Technology
1 answer:
igomit [66]2 years ago
4 0

Answer: provided in the explanation section

Explanation:

This is actually quite easy to go,i ask that you follow it carefully.

CODE is meant for python3+

CODE

def stats(pokemon):

   total=0

   #loops over the stats list

   for stat in pokemon["stats"]:

       # adds the stat to the total

       total+=stat["base_stat"]

   return total

def fight(first_pokemon,second_pokemon):

   #prints the first statemetn

   print(first_pokemon["name"],"has",stats(first_pokemon),"combined stats.",second_pokemon["name"],"has",stats(second_pokemon),"combined stats.")

   #checks if the first_pokemon wins

   if(stats(first_pokemon)>stats(second_pokemon)):

       print(first_pokemon["name"],"wins!")

   #checks if the second_pokemon wins

   elif(stats(first_pokemon)<stats(second_pokemon)):

       print(second_pokemon["name"],"wins!")

   # it is a draw

   else:

       print("It is a draw")

cheers i hoped this helped !!!

You might be interested in
What are the advantages and disadvantages of nuclear energy?
Vilka [71]
Advantages: Nuclear energy has the ability to produce electricity without greenhouse gas emissions. It produces electricity without pollution

Disadvantages: The nuclear weapons threats. Some reactors produce plutonium which can be used to make nuclear weapons
7 0
3 years ago
[20 pts] Write the function rectangle(perimeter, area), which takes two positive integers, perimeter and area. It returns an int
MrRissso [65]

Hi, you haven't provided the programing language in which you need the code, I'll explain how to do it using Python, and you can follow the same logic to make a program in the programing language that you need.

Answer:

import math

def rectangle(perimeter, area):

   l1_1 = (perimeter+math.sqrt((perimeter**2)-(16*area)))/4

   l1_2 = (perimeter-math.sqrt((perimeter**2)-(16*area)))/4

   l2_1 = area/l1_1

   l2_2 = area/l1_2

   print(l1_1,l2_1)

   print(l1_2,l2_2)

   if l1_1.is_integer() and l2_1.is_integer() and l1_1>0 and l2_1>0:

       return(int(max(l1_1,l2_1)))

   elif l1_2.is_integer() and l2_2.is_integer() and l1_2>0 and l2_2>0:

       return(int(max(l1_2,l2_2)))

   else:

       return(None)

Explanation:

  • We import math to make basic operations
  • We define the rectangle function that receives perimeter and area
  • We calculate one of the sides (l1_1) of the rectangle using the quadratic equation to solve 2h^2 - ph + 2a = 0
  • We calculate the second root of the quadratic equation for the same side (l1_2)
  • We calculate the second side of the rectangle using the first root on w = a/h
  • We calculate the second side of the rectangle using the second root on w= a/h
  • We verify that each component of the first result (l1_1, l2_1) is an integer (using the build-in method .is_integer) and greater than 0, if True we return the maximum value between them (using the max function) as w
  • If the first pair of sides evaluate to False we check the second root of the equation and if they meet the specification we return the max value
  • if all the if statements evaluate to false we return None to indicate that not positive or integer sides were found

7 0
2 years ago
Which of the following are slide layouts in
hjlf

Answer:

title slide

title and content

blank

picture with caption

Explanation:

Slide layouts contain boxes known as placeholders that bear the contents of a slide. They allow users to format, and position content. Colors and fonts are also available. Text, titles, pictures, video, audio, graphics, etc., can be attached to the placeholders. Layouts are adjustable according to the preferences of the user.

There are also features that the sharing of these layouts with other users. To select a layout to be used, the user goes to Home and chose Layout which then supplies the different options.

5 0
2 years ago
Although it is not a term Excel uses, how do most people think of Excel?
kobusy [5.1K]

They think of it as a spreadsheet

5 0
2 years ago
The laws governing search and seizure in the public sector are much more straightforward than those in the private sector. TRUE
Lapatulllka [165]

Answer:

True

Explanation:

Because of the contract that you have agreed to when joining the work force. Which is different from the private sector.

7 0
3 years ago
Other questions:
  • The manufacturer doesn't need it the buyer doesn't want it the user doesn't know they're using it
    6·1 answer
  • What is the Default path for SYSVOL?
    14·1 answer
  • If you see ________________________ in a cell, it means the column is not wide enough to display the cell content. Select one: a
    15·1 answer
  • opearating system protection refers to a mechanism for controling access by programs, processes, or users to both system and use
    7·1 answer
  • What is the exact number of bytes in system of memory that contains (a) 64K bytes (In Binary)(b) 32M bytes
    9·1 answer
  • 2.
    11·1 answer
  • Released in 1976, the Apple I was Apple Computer's first product.<br><br> O True<br> O False
    6·1 answer
  • You can set the margin using the rular also true or false​
    13·1 answer
  • A security operation center (SOC) analyst investigates the propagation of a memory-resident virus across the network and notices
    15·1 answer
  • As a technical support rep, michael is responding to a customer's question sent to him via e-mail. what should michael's first t
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!