Programming Basics
Programming Basics
concepts like variables, data types, operators, expressions, statements, and control
structures. Here's a breakdown of these concepts with definitions and examples:
1. Variables
Definition:
Variables are named storage locations in memory that hold data which can be changed during
program execution.
Example (Python):
2. Data Types
Definition:
Data types specify the kind of data a variable can hold, such as numbers, text, or more
complex types.
3. Operators
Definition:
Operators are symbols that perform operations on variables and values.
Types of Operators and Examples:
Arithmetic Operators: +, -, *, /, %
sum = 5 + 3 # Addition
product = 4 * 2 # Multiplication
Comparison Operators: ==, !=, >, <, >=, <=
5 > 3 # True
5 == 5 # True
Logical Operators: and, or, not
(5 > 3) and (2 < 4) # True
4. Expressions
Definition:
An expression is any valid combination of variables, constants, and operators that produces a
result.
Example:
5. Statements
Definition:
A statement is an instruction that the program executes. It can perform actions like assignments
or function calls.
Example:
x = 10 # Assignment statement
print(x) # Function call statement
6. Control Structures
Definition:
Control structures control the flow of execution in a program, determining which code gets
executed under certain conditions.
age = 18
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
Loops:
For Loop:
for i in range(5):
print(i) # Prints numbers 0 to 4
While Loop:
count = 0
while count < 5:
print(count)
count += 1
7. Functions
Definition:
Functions are reusable blocks of code designed to perform a specific task.
Example:
def greet(name):
print("Hello, " + name)
8. Comments
Definition:
Comments are non-executable lines in code used to explain the code or leave notes.
Example:
# This is a single-line comment
"""
This is a
multi-line comment
"""
9. Input and Output
Definition:
Mechanisms to take input from users and display output.
Example:
These are the foundational concepts that apply across most programming languages, including
C, C++, and Python. Understanding these basics is crucial for building more complex
programs.
RESOURCES(FREE):-
● Python
○ https://www.geeksforgeeks.org/python-programming-language-tutorial/?ref=ghm
○ https://pynative.com/python-basic-exercise-for-beginners/
○ https://prepinsta.com/python/ (Check DataTypes Section)
○ https://www.w3schools.com/python/python_variables.asp
● C
○ https://www.learn-c.org/ (Interactive website with content, exercises, and
tutorials)
○ https://www.sanfoundry.com/c-programming-questions-answers-variable-names-
1/ (MCQs to help learn the basics… all basic almost covered)
● CPP
○ https://www.learncpp.com/ (Free and Interactive website to learn all the concepts
in cpp even includes OOPS at the end….. It has comprehensive set of tutorial,
notes and explanation and quizzes, exercises for all the concepts….. Personally
liked it but ads can be an issue)
● Java
○ https://www.learnjavaonline.org
○ https://www.codecademy.com/learn/learn-java