Question

In: Computer Science

THE CODE MUST BE PYTHON superHeroes = { "MoleculeMan": { "age": 29, "secretIdentity": "Dan Jukes", "superpowers":...

THE CODE MUST BE PYTHON

superHeroes = {
"MoleculeMan": {
"age": 29,
"secretIdentity": "Dan Jukes",
"superpowers": [
"Radiation Immunity",
"Turning tiny",
"Radiation blast"
]
},
"MadameUppercut": {
"age": 39,
"secretIdentity": "Jane Wilson",
"superpowers": [
"Million tonne punch",
"Damage resistance",
"Superhuman reflexes"
]
},
"EternalFlame": {
"age": 1000,
"secretIdentity": "Unknown",
"superpowers": [
"Immortality",
"Heat Immunity",
"Inferno",
"Teleportation",
"Interdimensional travel"
]
},
"Doomguy": {
"age": 27,
"secretIdentity": "Space Trooper",
"superpowers": [
"Immortality",
"Heat Immunity",
"Teleportation",
"Super Speed",
"Superhuman reflexes"
]
},
"Maui":{
"age": 2352,
"secretIdentity": "Unknown",
"superpowers": [
"Immortality",
"Super Speed"
]
},
"Superwoman":{
"age": 1167,
"secretIdentity": "Lois Lane",
"superpowers": [
"Immortality",
"Super Speed",
"Superhuman reflexes"
]
} ,
  
}


# Question 2 (5 points)
# Output a set containing the ages of all the superheroes.
# Output the name and the age of the youngest superhero.
# Sample output is below.

Set of all ages: {39, 1000, 1167, 2352, 27, 29}
Doomguy is 27 years old.

Solutions

Expert Solution

Here I have implemented python3 code which is print the output as per your given format. also, I have attached a screenshot of the output. please let me know in the comment section if you have any queries regarding the below code.


import sys

# Given dictionary
superHeroes = {
"MoleculeMan": {
"age": 29,
"secretIdentity": "Dan Jukes",
"superpowers": [
"Radiation Immunity",
"Turning tiny",
"Radiation blast"
]
},
"MadameUppercut": {
"age": 39,
"secretIdentity": "Jane Wilson",
"superpowers": [
"Million tonne punch",
"Damage resistance",
"Superhuman reflexes"
]
},
"EternalFlame": {
"age": 1000,
"secretIdentity": "Unknown",
"superpowers": [
"Immortality",
"Heat Immunity",
"Inferno",
"Teleportation",
"Interdimensional travel"
]
},
"Doomguy": {
"age": 27,
"secretIdentity": "Space Trooper",
"superpowers": [
"Immortality",
"Heat Immunity",
"Teleportation",
"Super Speed",
"Superhuman reflexes"
]
},
"Maui":{
"age": 2352,
"secretIdentity": "Unknown",
"superpowers": [
"Immortality",
"Super Speed"
]
},
"Superwoman":{
"age": 1167,
"secretIdentity": "Lois Lane",
"superpowers": [
"Immortality",
"Super Speed",
"Superhuman reflexes"
]
} ,
  
}


# initialize with maxvalue
min_age=sys.maxsize

# Name of minimum age superHero
name=''

# set which stores all superHeroes age
age=set()

# loop over the whole dictionary   
for i in superHeroes:
    
    # current index superHero's age
    tmp=superHeroes[i]['age']
    
    # add age into a set of age    
    age.add(tmp)
    
    # find minimum age superHero
    if tmp<min_age:
        min_age=tmp
        name=i

# print output as per given format
print('Set of all ages:',age)
print('{} is {} years old.'.format(name,min_age))

Output:


Related Solutions

It is a strict requirement that this code is implemented in python. The code must be...
It is a strict requirement that this code is implemented in python. The code must be implemented from scratch not using e.g. numpy etc. a. Create a function that takes a matrix X of all sizea as input and gives the transposed matrix as output. Example transposeMatrix([[1,2] ,[3,4] ,[5,6]]) = [[1,3,5] ,[2,4,6]] b. Create a function that multilpies a matrix X1 and X2 of all sizes. Example x1 = [[0,1] ,[1,0] ] x2 = [[1, 0] ,[0,-1] ] matrtixMultl(x1,x2) =...
python: people = { "Molan": { "age": 46, "seIdentity": "Dan Jukes", "supowers": [ "Radiaon Immunity", "Turni...
python: people = { "Molan": { "age": 46, "seIdentity": "Dan Jukes", "supowers": [ "Radiaon Immunity", "Turni tiny", "Radiati blast" ] }, "Etlame": { "age": 1800, "seIdentity": "Unknown", "supowers": [ "Immortality", "Heat Immunity", "Inferno", "Teleportation", "Interdi travel" ] } #output all people ages as set # out old people age from dict with name
#python. Explain code script of each part using comments for the reader. The code script must...
#python. Explain code script of each part using comments for the reader. The code script must work without any errors or bugs. Ball moves in a 2D coordinate system beginning from the original point (0,0). The ball can move upwards, downwards, left and right using x and y coordinates. Code must ask the user for the destination (x2, y2) coordinate point by using the input x2 and y2 and the known current location, code can use the euclidean distance formula...
Dan, age 45, is an independent contractor working in pharmaceutical sales, Cheryl, age 42, is a...
Dan, age 45, is an independent contractor working in pharmaceutical sales, Cheryl, age 42, is a nurse at a local hospital. Dan’s ssn is 400-20-100 and Cheryl’s SSN is 200-40-8000 an they reside at 2033 Palmetto Drive, Atlanta, GA 30304. Dan is paid according to commissions from sales, and he has no income tax or payroll tax withholdings. Dan operates his business from his home office. During 2018 Dan earned total commission in his business of $125,000. Cheryl earned a...
*** Using Python *** Your program must prompt the user for their city or zip code...
*** Using Python *** Your program must prompt the user for their city or zip code and request weather forecast data from openweathermap.org. Your program must display the weather information in an READABLE format to the user. Requirements: Create a Python Application which asks the user for their zip code or city. Use the zip code or city name in order to obtain weather forecast data from: http://openweathermap.org/ Display the weather forecast in a readable format to the user. Use...
I need to implement a code in python to guess a random number. The number must...
I need to implement a code in python to guess a random number. The number must be an integer between 1 and 50 inclusive, using the module random function randint. The user will have four options to guess the number. For each one of the failed attempts, the program it should let the user know whether is with a lower or higher number and how many tries they have left. If the user guess the number, the program must congratulate...
The code that creates this program using Python: Your program must include: You will generate a...
The code that creates this program using Python: Your program must include: You will generate a random number between 1 and 100 You will repeatedly ask the user to guess a number between 1 and 100 until they guess the random number. When their guess is too high – let them know When their guess is too low – let them know If they use more than 5 guesses, tell them they lose, you only get 5 guesses. And stop...
Answer as soon as possible!!! Code must be done with Python Develop a basic File Transfer...
Answer as soon as possible!!! Code must be done with Python Develop a basic File Transfer Protocol (FTP) application that transmits files between a client and a server using Python. Your programs should implement four FTP commands: (1) change directory (cd), (2) list directory content (ls), (3) copy a file from client to a server (put) and (4) copy a file from a server to a client (get). Implement two versions of the program: one that uses stock TCP for...
Using python, produce code that mimics some ATM transactions: a. A welcome message must be displayed...
Using python, produce code that mimics some ATM transactions: a. A welcome message must be displayed initially reflecting the appropriate time of day (for example: Good Night, Welcome to Sussex Bank). b. Assume the user’s account balance is $5375.27. c. Allow the user to enter a pin number that does not have to be validated: def atm_login(): pin_number = input("Please enter your (4 digit) pin number: ") # display welcome message welcome_message() d. The message should be followed by a...
can you please convert this python code into java? Python code is as shown below: #...
can you please convert this python code into java? Python code is as shown below: # recursive function def row_puzzle_rec(row, pos, visited):    # if the element at the current position is 0 we have reached our goal    if row[pos] == 0:        possible = True    else:        # make a copy of the visited array        visited = visited[:]        # if the element at the current position has been already visited then...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT