Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
142 views
in Python by (120 points)
Create a class called File that can store the name of the movie, the name of the director, the list of actors, the year of the movie, the cost of the movie, the audience score for that movie (between 1 and 5) and the list of awards that the movie won. The class has a method named stars, and by calling that method, the name of the movie and the number of stars given to that movie will be printed in the output.

Please log in or register to answer this question.

1 Answer

0 votes
by (41.7k points)

Here's an example of how you can create the File class in Python:

class File:
    def __init__(self, movie_name, director_name, actors, year, cost, audience_score, awards):
        self.movie_name = movie_name
        self.director_name = director_name
        self.actors = actors
        self.year = year
        self.cost = cost
        self.audience_score = audience_score
        self.awards = awards

    def stars(self):
        print(f"{self.movie_name} - {self.audience_score} stars")

# Creating an instance of the File class
movie_data = File("Interstellar", "Christopher Nolan", ["Matthew McConaughey", "Anne Hathaway"], 2014, 165_000_000, 4, ["Oscar", "BAFTA"])

# Calling the stars method to print movie name and stars
movie_data.stars()

In this example, the File class has an __init__ method to initialize the attributes (name of the movie, director's name, etc.), and a stars method to print the movie name and audience score. You can create instances of the File class and use its methods to work with movie data.

Related questions

+1 vote
1 answer
asked Aug 18, 2023 in Python by MAhmad (120 points)
0 votes
1 answer
asked Aug 18, 2023 in Python by MAhmad (120 points)
0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...