Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Programming Basics

PPS

Uploaded by

shivaganesh9055
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Programming Basics

PPS

Uploaded by

shivaganesh9055
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

When learning a programming language for the first time, you typically start with foundational

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):

age = 24 # 'age' is a variable holding an integer value


name = "John" # 'name' is a variable holding a string value

2. Data Types

Definition:
Data types specify the kind of data a variable can hold, such as numbers, text, or more
complex types.

Common Data Types and Examples:

Integer (int): Whole numbers


age = 24
Float (float): Decimal numbers
temperature = 36.5
String (str): Sequence of characters (text)
name = "Alice"
Boolean (bool): Logical values (True or False)
is_student = True
List (list): Ordered collection of items
fruits = ["apple", "banana", "cherry"]
Dictionary (dict): Key-value pairs
person = {"name": "Bob", "age": 25}

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:

result = (5 + 3) * 2 # Expression evaluates to 16

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.

Types and Examples:


Conditional Statements (if-else):

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)

greet("Alice") # Output: Hello, Alice

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:

name = input("Enter your name: ") # Input


print("Hello, " + name) # Output

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

You might also like