= 'mango'
fruit = 'voila'
name
# printing out
print(name, ' likes ', fruit )
voila likes mango
(=)
.In the examples below, we create varibales name fruit
and name
and we assign them values 'mango'
and 'viola'
respectively
Examples of good variable names
In this section of the tutorial, you will learn the most basic data types in Python
These are two basic types of numbers and they are called: - integer(numbers without decimal places) - floating point numbers(numbers with decimal places)
Strings are simply text. A string must be surrounded by single or double quotes
Use single quotes when your string contains double quotes, or the vice versa.
text = 'shafara VEe'
capitalized_text = text.capitalize()
print('Capitalized:', capitalized_text)
upper_text = text.upper()
print('Upper text', upper_text)
lower_text = text.lower()
print('Lower case text:', lower_text)
corrected_text = text.replace('VEe', 'Viola')
print(corrected_text)
print('shafara' not in text)
Boolean data type can onlyhave on fo these values: True
or False
[]
),
)To check the data type of an object in python, use type(object)
, for example, below we get the data type of the object stored in names
# convert an integer to a string
age = 45
message = 'Peter Griffin is '+ str(age) + ' years old'
# Convert floating point to integer
pi = 3.14159
print(int(pi))
3
A few ads maybe displayed for income as resources are now offered freely. 🤝🤝🤝