You are on page 1of 6

Review of Python Notes

Python Variables i=int(input(“Enter your number”)


1 if i > 5:
print("I value is greater than Five!")
Else :
print("I value is less than Five!")

Python Variables x=5

2 y = "Hello, World!"

print(x)

print(y)
Comments #print("Hello, World!")

Casting x = str(3)

4 y = int(3)

z = float(3)

print(x)

print(y)

print(z)
Get the Type x = 5.6677

5 y = "John"

z=5

print(type(x))

print(type(y))

print(type(z))
Many Values to Multiple x, y, z = "Orange", "Banana", "Cherry"
Variables

6
print(x)

print(y)

print(z)
One Value to Multiple x = y = z = "Orange"
Variables

7
print(x)

print(y)

print(z)
Output Variables x = "Python"

y = "is"

z = "awesome"

print(x, y, z)

x = "Python "

y = "is "

z = "awesome"

print(x + y + z)

Python Numbers

There are three numeric types in Python:

● int
● float
● complex

x=1

y = 2.8
z = 1j

print(type(x))

print(type(y))

print(type(z))

Int x=1
Int, or integer, is a whole
number, positive or
y = 35656222554887711
negative, without
decimals, of unlimited z = -3255522
length.

print(type(x))

print(type(y))

print(type(z))

Float x = 1.10
Float, or "floating point
number" is a number,
y = 1.0
positive or negative,
containing one or more z = -35.59
decimals.

print(type(x))

print(type(y))

print(type(z))

x = 35e3

y = 12E4

z = -87.7e100
print(type(x))

print(type(y))

print(type(z))

Sort List Alphanumerically thislist = ["orange", "mango",


"kiwi", "pineapple", "banana"]
thislist.sort()
print(thislist)
Sort the list numerically: thislist = [100, 50, 65, 82, 23]
thislist.sort()
print(thislist)
Sort the list descending: thislist = ["orange", "mango",
"kiwi", "pineapple", "banana"]
thislist.sort(reverse = True)
print(thislist)
Sort the list descending: thislist = [100, 50, 65, 82, 23]
thislist.sort(reverse = True)
print(thislist)

x = 5
y = 3

print(x + y)

You might also like