Guest User

charClasses.py

a guest
May 23rd, 2022
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. import random
  2.  
  3. class Character:
  4.    def __init__(self, name, surname, age, gender):
  5.         self.name = name
  6.         self.surname = surname
  7.         self.age = age
  8.         self.gender = gender
  9.  
  10.    def print_char_info(self):
  11.         # Counts the length of the characters of both the name and surname attributes
  12.         lineLength = len(self.surname + self.name)
  13.         # This adds 7 so that it can match the total length with the Name: at the bottom where it is being printed
  14.         lineLengthAdd = lineLength + 7
  15.        
  16.         charInfo = len("Character Info:")
  17.         print("Character Info:")
  18.        
  19.         # Prints - that is of equal length to the charInfo variable
  20.         for i in range(charInfo):
  21.             print("-", end="")
  22.            
  23.         #print()
  24.         #print("Name:")
  25.            
  26.         #for i in range(lineLengthAdd):
  27.         #    print("-", end="")
  28.        
  29.         print()
  30.         print(f"Name: {self.surname} {self.name}")
  31.        
  32.         # Does the same as the previous for loops
  33.         for i in range(lineLengthAdd):
  34.             print("-", end="")
  35.            
  36.         print()
  37.         print(f"Gender: {self.gender}")
  38.        
  39.         for i in range(lineLengthAdd):
  40.             print("-", end="")
  41.            
  42.         print()
  43.         print(f"Age: {self.age}")
Advertisement
Add Comment
Please, Sign In to add comment