Python Programming Fundamentals Overview

Aug 9, 2024

Introduction to Python

Chapter 1: Fundamentals of Python

  • Python: A high-level programming language.
  • Script Mode: A method for storing a program as a module.

Chapter 2: Variables and Operators

Variables

  • Variable: A named location that stores a value.
  • Example:
    • x = 10
    • y = 20
  • Rules for Variables:
    • Cannot use spaces.
    • Can only use underscores.
    • The first character of the variable must be an alphabet or an underscore.

Operators

  • Equality Operator: ==
  • Division Operator: /
  • Modulus Operator: %
  • Power Operator: **

Chapter 3: Input and Output

Input

  • Use the input() function to take data from the user.
  • Example: name = input("Enter your name:")
  • input() always returns a string.
  • Use int() or float() to convert the string to a number.

Output

  • Use the print() function to give output.
  • Example: print("Hello World")
  • print() will add a new line if the end argument is not specified.

Features

  • Separator: Join different items in print() with commas.
  • End: Additional space or new line at the end of print.

Chapter 4: Function

  • Function: A group of code given a name.
  • Example:
    • def function_name():
  • To call a function, use its name and brackets.

Chapter 5: Comments

  • Comments are for clarifying the code.
  • For single line: Use #.
  • For multiple lines: Use ''' or """.

Conclusion

  • It is essential to understand the basics of variables, operators, input, and output in Python.
  • Study these concepts in detail in the upcoming chapters.