Challenge: Working with Instance and Class Variables
Завдання
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.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 1. Розділ 7
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Чудово!
Completion показник покращився до 3.85
Challenge: Working with Instance and Class Variables
Свайпніть щоб показати меню
Завдання
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.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 1. Розділ 7