
Day 17 of 100
Hi! Today, I learned to make my own classes. I did run into a few problems whilst working on today's project but luckly I managed to figure it out. Resource for generating quizzes - https://opentdb.com/ Notes # Creating Class class User : # Creating Attribute def __init__ ( self , user_id , username ): self . user_id = user_id self . username = username self . followers = 0 self . following = 0 # Creating Method def follow_count ( self ): self . followers += 1 print ( f " Yay! You have { self . followers } followers. " ) def follow ( self , user ): self . following += 1 user . followers += 1 print ( f " Yay! You are following { self . following } user(s). " ) print ( f " Yay! They now have { user . followers } follower(s). " ) user_1 = User ( " 001 " , " Palak " ) print ( user_1 ) user_2 = User ( " 002 " , " Hirave " ) print ( user_2 ) print ( user_1 , user_2 ) user_3 = User ( " 003 " , " Damn " ) # Adding another attribute user_3 . notes = " ~Yay~ " print ( user_3 . notes ) # Having a
Continue reading on Dev.to
Opens in a new tab


