CIT PYTHON COHORT THREE
  • CIT Python Cloud Software Engineering
  • week one
    • What is Python
    • Python Syntax
    • variables
    • Numbers / Integers
  • week Two
    • Control Flow Statements
      • If Statements
      • For Loops
      • While Loops
      • Break and Continue Statements
    • Operators
      • Assignment Operators
      • Arithmetic Operators
      • Comparison Operators
      • Logical Operators
      • Bitwise Operators
      • Identity Operators
      • Membership Operators
    • Data Types
      • Strings
      • Numbers
      • Booleans
      • Lists
      • Dictionaries
      • Tuples
      • Sets
  • Week 3
    • Functions
      • Function Arguments
      • Python Recursion
      • Python Anonymous/Lambda Function
    • Object Oriented Programming
      • Classes
      • Inheritance
      • Polymorphism
      • Abstraction
      • Encapsulation
    • Python Modules
      • Python Packages
      • Python Built-in Modules
      • Python Standard Library
      • Python Third Party Modules
    • Python Exceptions
      • Python Try Except
      • Python Raise
      • Python Assert
      • Python User-defined Exceptions
  • Week 4 - File Handling
  • Week6
    • Data Structures and Algorithms
      • DSA Introduction
      • What is an Algorithm?
      • Data Structures and Types
      • Stack
      • Queue
      • Linked List
      • Bubble Sort Algorithm
      • Selection Sort Algorithm
      • Insertion Sort Algorithm
      • Merge Sort Algorithm
      • Quick Sort Algorithm
  • Week8
    • Cryptography
      • Reverse Cipher
      • Caesar Cipher
      • Hash Functions
        • Applications of Hash Functions
        • Examples of Hash Functions
  • Assignments and Solutions
    • Loops
Powered by GitBook
On this page
  • Python Indentations
  • Comments
  • Docstrings
  • References

Was this helpful?

Edit on GitHub
  1. week one

Python Syntax

Python Syntax compared to other programming languages

  • Python was designed to for readability, and has some similarities to the English language with influence from mathematics.

  • Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses.

  • Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.

Python Indentations

Where in other programming languages the indentation in code is for readability only, in Python the indentation is very important.

Python uses indentation to indicate a block of code.

if 5 > 2:
    print("Five is greater than two!")

Python will give you an error if you skip the indentation.

Comments

Python has commenting capability for the purpose of in-code documentation.

Comments start with a #, and Python will render the rest of the line as a comment:

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

Docstrings

Python also has extended documentation capability, called docstrings.

Docstrings can be one line, or multiline. Docstrings are also comments:

Python uses triple quotes at the beginning and end of the docstring:

"""This is a 
multiline docstring."""
print("Hello, World!")

References

PreviousWhat is PythonNextvariables

Last updated 11 days ago

Was this helpful?

|

w3schools.com
Next
Previous