Skip to content

Latest commit

 

History

History
82 lines (61 loc) · 1.38 KB

python.md

File metadata and controls

82 lines (61 loc) · 1.38 KB

Python

Data Types

  • str: String, text
  • int: Number without decimal point
  • float: Decimal number, decial point are allowed
  • bool: True or False

and more

Function

  • print(): Prints the given object
  • str(): Returns the string version of the given object
  • type(): Returns the type of the object
door_open = True
print(type(door_open))

Multi Line Strings

leaves_of_grass = """
I am a long text on
multiple lines
"""

Input

name = input('Enter your name')

Relational Operators

Relational operators compare two items and return either True or False.

  • ==: Equals
  • !=: Not equals
  • >: Greater than
  • >=: Greater than or equal to
  • <: Less than
  • <=: Less than or equal to

Boolean Operators / Logical Operators

  • and: Returns True if both sides are returns True
  • or: Returns True if one or both side are returns True
  • not: Returns True if the expression is False

If Statement

user_name = "Markus"
if user_name == "Markus":
  print("Hi Markus!")

Else Statements

if weekday:
  print("wake up at 6:30")
else:
  print("sleep in")

Elif Statements

donation = 150
 
if donation >= 200:
  print("gold donor status")
elif donation >= 100:
  print("silver donor status")
else:
  print("bronze donor status")