Variables and Data Types

  • Variables: Containers for storing data values. Example: x = 5.
  • Data Types: Different types of values that variables can hold.
    • Integers: Whole numbers (e.g., int)
    • Floats: Decimal numbers (e.g., float)
    • Strings: Text (e.g., str)
    • Booleans: True or False (e.g., bool)

Basic Operators

  • Arithmetic Operators: +,-, *, /, // (floor division), % (modulus), ** (exponentiation)
  • Comparison Operators: ==, !=, >, <, >=, <=
  • Logical Operators: and, or, not

Strings and String Operations

  • Creating Strings: Enclosed in single (’) or double quotes (").
  s = "Hello, World!"
  
  • String Operations:
    • Concatenation: s1 + s2
    • Repetition: s * n
    • Slicing: s[start:end]
    • Methods: .lower(), .upper(), .strip(), .replace(), .find()

Lists and Tuples

  • Lists: Ordered, mutable collections.

      my_list = [1, 2, 3, 4]
      
    • Operations: .append(), .remove(), .pop(), list[start:end]
  • Tuples: Ordered, immutable collections.

      my_tuple = (1, 2, 3, 4)
      
    • Operations: Similar to lists, but cannot be changed.

Dictionaries and Sets

  • Dictionaries: Unordered collections of key-value pairs.

      my_dict = {'name': 'Alice', 'age': 25}
      
    • Operations: .keys(), .values(), .items(), .get()
  • Sets: Unordered collections of unique elements.

      my_set = {1, 2, 3, 4}
      
    • Operations: .add(), .remove(), .union(), .intersection()

Input and Output

  • Input: Reading data from the user.
  name = input("Enter your name: ")
  
  • Output: Displaying data to the user.
  print("Hello, " + name)
  

Let me know if you want more details or examples on any of these topics!