University of Delhi Syllabus ยท Unit 1

Introduction to Programming

Problem solving, program structure, syntax and semantics

Learning Outcomes
  • Understand the basics of a programming language
  • Describe problem-solving strategies and algorithms
  • Explain the structure of a Python program
  • Write and execute simple Python programs

Problem-Solving Strategies

Programming begins by understanding the problem, designing a step-by-step algorithm, implementing it in code, then testing and debugging. Algorithms may first be written as pseudocode or drawn as flowcharts before coding in Python.

Structure of a Python Program

A Python program is a sequence of statements where indentation, not braces, defines blocks, and the hash symbol starts a comment. Programs run interactively in the interpreter or as saved .py scripts.

# A simple Python program name = input("Enter your name: ") print("Hello,", name)

Syntax and Semantics

Syntax is the grammatical rules of the language while semantics is the meaning of a well-formed statement. Python emphasises readable syntax, which lowers the barrier for beginners.

x = 5 # assignment print(x * 2) # outputs 10

Summary

This unit introduced problem-solving strategies, the structure of a Python program, the difference between syntax and semantics, and executing simple programs.

Exercises

  • Write a program to find the roots of a quadratic equation.
  • Write a program to convert a temperature from Celsius to Fahrenheit.
  • Draw a flowchart and write a program to find the largest of three numbers.