Variables and Methods
#!/bin/python3Variables and Methods
quotes = "All is fair in love & war."print(quotes) # Prints the original string
print(quotes.upper()) # Converts to uppercase
print(quotes.lower()) # Converts to lowercase
print(quotes.title()) # Capitalizes the first letter of each wordprint(len(quotes)) # Prints the length (number of characters) of the stringWorking with Other Data Types
name = "KT" # A string variable
age = 25 # An integer variable
gpa = 2.8 # A float (decimal) variableprint(int(age)) # Prints the integer value of age (still 25)
print(int(gpa)) # Converts GPA from float to integer (2)Incrementing a Variable


Last updated