Completed Exercise 9-3 Users
This commit is contained in:
parent
77433ba852
commit
5c78f9ab76
32
Chapter_09/9-03_users.py
Normal file
32
Chapter_09/9-03_users.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Exercise 9-3 Users
|
||||||
|
# Learning Objective: Create a class with two predefined arguments then others,and two methods; make 3 instances of the class utilizing the methods created.
|
||||||
|
|
||||||
|
class Users:
|
||||||
|
def __init__(self, first_name, last_name, dob, state, hair_color):
|
||||||
|
"""Initialize User Profile variables"""
|
||||||
|
self.first_name = first_name
|
||||||
|
self.last_name = last_name
|
||||||
|
self.dob = dob
|
||||||
|
self.state = state
|
||||||
|
self.hair_color = hair_color
|
||||||
|
|
||||||
|
def describe_user(self):
|
||||||
|
"""Prints descriptions of user based on inputs"""
|
||||||
|
print(f"{self.first_name} {self.last_name} was born on {self.dob}, they live in {self.state} and they have {self.hair_color}")
|
||||||
|
|
||||||
|
def greet_user(self):
|
||||||
|
"""Prints personalized greeting to user specified"""
|
||||||
|
print(f"Welcome to this python program, {self.first_name} {self.last_name}!")
|
||||||
|
|
||||||
|
|
||||||
|
user_1 = Users("Tony", "Redilman", "03/16/56", "Montana", "Black")
|
||||||
|
user_2 = Users("Georgina", "Reynolds", "04/23/76", "Colorado", "Auburn")
|
||||||
|
user_3 = Users("Kenneth", "Librant", "05/05/88", "Arizona", "Blonde")
|
||||||
|
|
||||||
|
user_1.describe_user()
|
||||||
|
user_2.describe_user()
|
||||||
|
user_3.describe_user()
|
||||||
|
|
||||||
|
user_1.greet_user()
|
||||||
|
user_2.greet_user()
|
||||||
|
user_3.greet_user()
|
||||||
Loading…
x
Reference in New Issue
Block a user