Lecture Notes on 23 Aug 2023 * Overview of Python * Write the Hello World program def main(): print ("Hello World!") main() * Characterset: ASCII and Unicode * Variables: - must start with a letter or underscore - can be followed by n number of letters, digits, and underscores - cannot be a reserved word * Types - strongly typed or weakly typed * Statement and expressions * Assignment statement * Operators - Arithmetic: + - * / // % ** - Comparison: < <= > >= == != - Boolean: not, and, or - Bitwise: ~, &, |, ^ - Shift: <<, >> * Conditionals: if-else, if-elif-else * Loops: while, for * Lists: 1D, 2D, nD * Tuples, Sets, Dictionaries * Input / Output * Functions - built-in - math, random, sys - user defined * Class * Principles of Objected-Oriented Programming - Abstraction - Encapsulation - Information Hiding - Inheritance - Polymorphism * Characteristics of Good Software Design - Correctness - Efficiency: time, space - Maintainability: modular and well documented - Aesthetics: elegance in the algorithm and coding - Usability: how easy is it for the user to understand and use the code - Scalability: how easy is it to increase the scope of the program * Solution of Digit Swap on Kattis #! /usr/bin/python3 # file: digitswap.py # date: 23 Aug 2023 import sys def main(): line = sys.stdin.readline () line = line.strip() n = int(line) m = (n % 10) * 10 + (n // 10) print (m) if __name__ == "__main__": main()