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
allochka39001 [22]
3 years ago
9

Define the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor shou

ld by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise.
Define the Artwork class with a constructor to initialize an artwork's information and a print_info() method. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor parameter values.

Ex: If the input is:

Pablo Picasso
1881
1973
Three Musicians
1921
the output is:

Artist: Pablo Picasso (1881-1973)
Title: Three Musicians, 1921
If the input is:

Brice Marden
1938
-1
Distant Muses
2000
the output is:

Artist: Brice Marden, born 1938
Title: Distant Muses, 2000
class Artist:
# TODO: Define constructor with parameters to initialize instance attributes
# (name, birth_year, death_year)

# TODO: Define print_info() method. If death_year is -1, only print birth_year


class Artwork:
# TODO: Define constructor with parameters to initialize instance attributes
# (title, year_created, artist)

# TODO: Define print_info() method


if __name__ == "__main__":
user_artist_name = input()
user_birth_year = int(input())
user_death_year = int(input())
user_title = input()
user_year_created = int(input())

user_artist = Artist(user_artist_name, user_birth_year, user_death_year)

new_artwork = Artwork(user_title, user_year_created, user_artist)

new_artwork.print_info()
Computers and Technology
1 answer:
nika2105 [10]3 years ago
8 0

Answer:

class Artist():

   def __init__(self, artist_name=None, artist_birth_year=0, artist_death_year=0):

       self.artist_name = artist_name

       self.artist_birth_year = artist_birth_year

       self.artist_death_year = artist_death_year

   def display_artist(self):

       if self.artist_death_year == -1:

           print('{}, born {}'.format(self.artist_name, self.artist_birth_year))

       else:

           print('{} ({}-{})'.format(self.artist_name, self.artist_birth_year, self.artist_death_year))

class Artwork():

   def __init__(self, artwork_title=None, artwork_year_created=0, artist=Artist()):

       self.artwork_title = artwork_title

       self.artwork_year_created = artwork_year_created

       self.artist = artist

   def display_artist(self):

       print('artwork_title: {}'.format(self.artwork_title))

       print('Artist: ', end='')

       self.artist.display_artist()

def main():

   user_artist_name = input('Enter the name of artist: ')

   user_birth_year = int(input('Enter birth year: '))

   user_death_year = int(input('Enter death year: '))

   user_title = input('Enter master piece title: ')

   user_year_created = int(input('Enter year created: '))

   user_artist = Artist(user_artist_name, user_birth_year, user_death_year)

   new_artwork = Artwork(user_title, user_year_created, user_artist)

   new_artwork.display_artist()

if __name__ == "__main__":

   main()

Explanation:  

  • Inside the constructor of Artist class, initialize the essential properties.
  • Create the display_artist function that checks whether artist_death_year is equal to -1 and then displays an appropriate message according to the condition.
  • Apply the similar steps as above for the Artwork class.
  • Inside the main method, get the information from user and finally call the display_artist function to print the results on screen.
You might be interested in
What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 0; j < 5; j++) cout <<
sesenic [268]

Answer:

what?

Explanation:

8 0
3 years ago
2. Which of the following fonts is most legible for a block of text? What font size and color would you choose if you were writi
madreJ [45]

Answer:

Color: Black

Font: Times New Roman

Size: 12

Explanation:

4 0
3 years ago
Read 2 more answers
Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number
sineoko [7]

Answer:

// using c++ language

#include "stdafx.h";

#include <iostream>

#include<cmath>

using namespace std;

//start

int main()

{

 //Declaration of variables in the program

 double start_organisms;

 double daily_increase;

 int days;

 double updated_organisms;

 //The user enters the number of organisms as desired

 cout << "Enter the starting number of organisms: ";

 cin >> start_organisms;

 //Validating input data

 while (start_organisms < 2)

 {

     cout << "The starting number of organisms must be at least 2.\n";

     cout << "Enter the starting number of organisms: ";

     cin >> start_organisms;

 }

 //The user enters daily input, here's where we apply the 5.2% given in question

 cout << "Enter the daily population increase: ";

 cin>> daily_increase;

 //Validating the increase

 while (daily_increase < 0)

 {

     cout << "The average daily population increase must be a positive value.\n ";

     cout << "Enter the daily population increase: ";

     cin >> daily_increase;

 }

 //The user enters number of days

 cout << "Enter the number of days: ";

 cin >> days;

 //Validating the number of days

 while (days<1)

 {

     cout << "The number of days must be at least 1.\n";

     cout << "Enter the number of days: ";

     cin >> days;

 }

 

 //Final calculation and display of results based on formulas

 for (int i = 0; i < days; i++)

 {

     updated_organisms = start_organisms + (daily_increase*start_organisms);

     cout << "On day " << i + 1 << " the population size was " << round(updated_organisms)<<"."<<"\n";

     

     start_organisms = updated_organisms;

 }

 system("pause");

  return 0;

//end

}

Explanation:

6 0
3 years ago
Assuming a user enters 25 as input, what is the output of the following code snippet? int i = 0; Scanner in = new Scanner(System
Dmitry_Shevchenko [17]

Answer:

The correct answer for the given question is 24

Explanation:

In the given  question the value of variable i entered by the user is 25 i.e the value of i is 25 control checks the condition of if block which is false .So control moves to the else block and executed the condition inside the else block means it executed i-- decrements the value of i by 1 means i is 24

Following are the program of java :

import java.util.*;// import package

public class Main // main class

{

// main method

public static void main(String[] args)

{

int i = 0;  // variable declaration

Scanner in = new Scanner(System.in); // creating class of scanner class

System.out.print("Enter a number: ");

i = in.nextInt();  //  user input

if (i > 25)  // check if block

{

i++; // increment the value of i

}

else

{

   i--; // decrement the value of i

}

System.out.println(i);  // display i

}

}

Output:

Enter a number:25

24

8 0
3 years ago
After a Hacker has selects her target, performed reconnaissance on the potential target's network, and probed active Internet Ad
Gnoma [55]

After a Hacker has selects her target,  the thing she scan next on the target's network to see if any are open System Ports.

<h3>How do hackers scan ports?</h3>

In port scan, hackers often send a message to all the port, once at a time. The response they tend to receive from each port will help them to known if it's being used and reveals the various weaknesses.

Security techs often conduct port scanning for a lot of network inventory and to show any possible security vulnerabilities.

Learn more about Hacker from

brainly.com/question/23294592

7 0
3 years ago
Other questions:
  • Blood alcohol level is the ratio between the alcohol consumed and the blood in the body
    10·1 answer
  • Which button do you use to put data in a specific order A.Insert
    6·2 answers
  • Windows server 2012 r2 supports two types of folder shares. what are those two types?
    6·1 answer
  • Jim works the parts counter for a busy car dealership. When answering the phone, Jim often has trouble answering the customer's
    6·1 answer
  • A grade of B is worth Grade points<br><br><br> A) 3.0<br> B) 80<br> C)2.0<br> D)4.0
    13·2 answers
  • Which educational qualification would help a candidate get a job as a computer systems engineer? a.certificate
    6·1 answer
  • A 1400 kilogram car is moving at a speed of 25 m/s. How much kinetic energy does the car have?
    15·2 answers
  • In a typical e-mail address the host is
    14·1 answer
  • Most project files will contain:
    9·1 answer
  • Write a c++ program that generates three random numbers. The first number should be between 0-30, the second number should be be
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!