Why this technology is relevant and what the scope.
Python is a general-purpose and high-level programming language. You can use Python for developing desktop GUI applications, websites, and web applications. Also, Python, as a high-level programming language, allows you to focus on the core functionality of the application by taking care of common programming tasks
After following this resource what you will learn.
Summary of what learn to get started.
Details about the technology and learning materials.
Python Indentation
Indentation refers to the spaces at the beginning of a code line.
Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.
Python uses indentation to indicate a block of code.
for example:
if 5 > 2:
print("Five is greater than two!")
print("This line will be printed.")
# This line will be printed.
Python is a very simple language and has a very straightforward syntax. The simplest directive in Python is the "print" directive - it simply prints out a line
Variables can store data of different types, and different types can do different things.
Python has the following data types built-in by default, in these categories:
String literals in python are surrounded by either single quotation marks or double quotation marks.
'hello'
is the same as "hello"
.
You can display a string literal with the print()
function:
x = 5
y = "John"
print(x)
print(y)
# 5
# john
A list is a collection which is ordered and changeable. In Python, lists are written with square brackets.
Example:
thislist = ["apple", "banana", "cherry"]
print(thislist)
# ["apple", "banana", "cherry"]
A tuple is a collection which is ordered and unchangeable. In Python, tuples are written with round brackets.
Example:
thistuple = ("apple", "banana", "cherry")
print(thistuple)
# ("apple", "banana", "cherry")
A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets.
thisset = {"apple", "banana", "cherry"}
print(thisset)
# {"apple", "banana", "cherry"}
A dictionary is a collection which is unordered, changeable and indexed. In Python, dictionaries are written with curly brackets, and they have keys and values.
Example:
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)
# {"brand": "Ford", "model": "Mustang", "year": 1964}
if
An "if statement" is written by using the if keyword.
Example:
a = 33
b = 200
if b > a:
print("b is greater than a")
elif
The elif keyword is pythons way of saying "if the previous conditions were not true, then try this condition".
Example:
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else
The else keyword catches anything which isn't caught by the preceding conditions.
Example:
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
Python has two primitive loop commands:
while
loopsfor
loops