Challenge: Working with Instance and Class Variables
Compito
Swipe to start coding
Define a class named User with the following requirements:
- Create a class variable
total_usersand initialize it to0. - Implement the
__init__method to:- Take
usernameas an argument. - Store
usernameas an instance variable. - Increment
total_usersby1every time a newUserinstance is created.
- Take
- Implement a method
get_infothat returns a tuple containing:- The user's name (the value of the instance variable for username).
- The current value of
total_users.
Soluzione
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 1. Capitolo 7
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Fantastico!
Completion tasso migliorato a 3.85
Challenge: Working with Instance and Class Variables
Scorri per mostrare il menu
Compito
Swipe to start coding
Define a class named User with the following requirements:
- Create a class variable
total_usersand initialize it to0. - Implement the
__init__method to:- Take
usernameas an argument. - Store
usernameas an instance variable. - Increment
total_usersby1every time a newUserinstance is created.
- Take
- Implement a method
get_infothat returns a tuple containing:- The user's name (the value of the instance variable for username).
- The current value of
total_users.
Soluzione
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 1. Capitolo 7