Table of Contents
- Different conditional structures
- Practice
- Even vs. odd number
- Check if the input number is divisible by number 2
- Check if the input number is divisible by number 4
- Check if the input number is divisible by either 2 and 4
- Check if the input number is divisible by either 2 or 4
- Celcius to Farenheit conversion and temperature reminder
- Draw different shapes based on input requests
- Practice
-
Indentation
in Python- The Python language design is distinguished by its emphasis on readability, simplicity, and explicitness. Some people go so far as to liken it to "executable pseudocode"
- Python uses whitespace (tabs or spaces) to structure code instead of using braces as in many other languages like R, C++, Java, and Perl. Consider a for loop from a sorting algorithm, such as:
if x >= 5: print(f"x is greater or equal to 5") else: print(f"x is smaller than 5")
- In C++, the same code could be like
if (x >= 5) { std::cout << "x is greater or equal to 5" << std::endl; } else { std::cout << "x is smaller than 5" << std::endl; }
- A colon denotes the start of an indented code block after which all of the code must be indented by the same amount until the end of the block
Indentation
here means - X consecutive spaces- There is no restrictions on the amount of spaces to use as long as you always stick to the same amount. However, 4 consecutive spaces is the general standard people follow
- Many text editors have a setting that will replace tab stops with spaces automatically
- Semicolons can be used, however, to separate multiple statements on a single line:
a = 5; b = 6; c = 7
- Putting multiple statements on one line is generally discouraged in Python as it can make code less readable.
- TBD
- TBD