# 1 - Introduction to Python

# 1 - Introduction to Python

By Ifeanyi Omeata


Topics:


1. Python Version
2. Print statement
3. Python variables
4. Datatypes
5. Type Casting
6. Arithmetic Operators
7. Comments


1. Python Version


>>Return to Menu

python --version
python -V

image.png

image.png


2. Print statement


>>Return to Menu

print('Welcome to Python')

image.png


3. Python variables


>>Return to Menu

first_name = "Ifeanyi"
last_name = "Omeata"
course = "Python"

print('Hello, ' + first_name + ' ' + last_name)
print('Welcome to ' + course)

image.png


4. Datatypes


>>Return to Menu

print(type('hello'))
print(type(1))
print(type(1.64))
print(type(True))

image.png


5. Type Casting


>>Return to Menu

#String to Boolean
my_string = 'hello'
print(type(my_string))
print(bool(my_string))
print(type(bool(my_string)))

#String to Float
my_string_2 = '10.6'
print(type(my_string_2))
print(float(my_string_2))
print(type(float(my_string_2)))

#Integer to String
my_integer = 1
print(type(my_integer))
print(str(my_integer))
print(type(str(my_integer)))

#Float to Integer
my_float = 1.64
print(type(my_float))
print(int(my_float))
print(type(int(my_float)))

#Boolean to Integer
my_boolean = True
print(type(my_boolean))
print(int(my_boolean))
print(type(int(my_boolean)))

image.png


6. Arithmetic Operators


>>Return to Menu

x = 6
y = 4

print('Addition : ', x + y)
print('Subtraction : ', x - y)
print('Multiplication : ', x * y)
print('Division (float) : ', x / y)
print('Division (floor) : ', x // y)
print('Modulus : ', x % y)
print('Exponent : ', x ** y)

image.png


7. Comments


>>Return to Menu
Comments can be used to explain Python code, to make the code more readable, or to prevent execution when testing code. Comments starts with a #, and Python will ignore them.

#This is a comment
print("Hello, World!")

image.png

#End


Hope you enjoyed this! :) Follow me for more contents...


Get in Touch:
ifeanyiomeata.com

Youtube: youtube.com/c/IfeanyiOmeata
Linkedin: linkedin.com/in/omeatai
Twitter: twitter.com/iomeata
Github: github.com/omeatai
Stackoverflow: stackoverflow.com/users/2689166/omeatai
Hashnode: hashnode.com/@omeatai
Medium: medium.com/@omeatai
© 2022