Course Content
What is Python?
Introduction of Python and Its setup
0/2
Control Statement
Control statements are used to control the flow of execution depending upon the specified condition/logic.
0/5
File Handling
File handling is an important component of any application. Python has multiple functions for creating, reading, updating, and deleting files.
0/2
Python

A barebone Python program is the simplest form of a Python script. It contains only the essential elements needed to make a functional program. This is a great starting point for beginners to understand the basic structure of Python code.

 


Why Start with a Barebone Program?

  1. Easy to Understand: Minimal code makes it easier to focus on the basics.
  2. Foundation for Complex Programs: Every advanced program is built on these basics.
  3. Quick Start: You can create and run a program in just a few seconds.

 


Basic Elements of a Python Program

  1. Comments:

    • Used to explain what the code does.
    • Written with #.
    • Not executed by the program.
  2. Print Statement:

    • Displays output to the screen.
    • The simplest way to check if your program is running.
  3. Main Function (Optional):

    • A starting point for the program logic.
    • Helps organize code, especially in larger programs.
  4. if __name__ == "__main__": Block:

    • Ensures the program runs only when executed directly, not when imported as a module.

 


 

Expression:
Expression is evaluated and produces the results.
Ex: (10=2)/2

Statements:
This indicates that we are doing something.
Ex: a=10
print(“Calling in proper sequence”)

Comments:
Comments are readable messages for a programmer but it is overlooked by the python interpreter.
a. Single line comment (#)
b. Multi-line comment (”’ ”’)
Ex: #this is a single-line comment
”’ this is
multiple ”’

Function:
A function is a block of code that only runs when it is called. Ex: getStudentMarks()

Block & Indentation:
A group of statements in block indentation at the same level creates a block. Ex: all the statements that are under the function getStudentMarks()