OOPs

Task 1: Create a class named User. The class should:
  1. .have two methods, get_name and age.
  2. The two methods should contain only a pass statement inside them.
  3. The get_name method should contain a self parameter.
  4. The age method should contain a self and a current_year parameter.
Task 2: Add an __init__ method to the User class. The method should have:
  1. three parameters, self, name, and birthyear.
  2. name and birthyear should also be instance variables.
Task 3: Implement/code the User.age method so the method returns the age of the user given the self.birthyear instance variable and the current_year parameters.
Task 4: Let us suppose the current year is 2023.
  1. Create a User instance for John, whose birth year is 1999.
  2. Call the age method for that instance and print out the output.
    You should get 24 as output.
Task 5: Implement/code the User.get_name method, so the method returns the capitalized version of the user's name (e.g., JOHN). Note that the name is stored in the instance variable. Also, call the method for the instance you created in Task 4.

Files

Task 1:

Essay.txt  ChatGPT, which stands for Chat Generative Pre-trained Transformer, is a large language model–based chatbot developed by OpenAI and launched on November 30, 2022, which enables users to refine and steer a conversation towards a desired length, format, style, level of detail, and language used.

Take a look at the essay.txt file . That file contains some text.

You should create a program that reads the essay.txt file, converts the first letter of each word to uppercase and prints out the converted text

Task 2:

Write a python Program to accept the input from the user as name & age and add the data in the Excel sheet

Event IconCurrent Events
×