Character
A character is any single key on the keyboard.
Examples of characters:
- Numbers:
0to9 - Small letters:
atoz - Capital letters:
AtoZ - White spaces: space, tab
- Special symbols:
@,#,$,%,&, etc.
Each single symbol is one character.
String
A string is a collection of one or more characters.
Examples of strings:
'5'"5hello""naveen"'909090''hello'
Anything written inside single quotes (' ') or double quotes (" ") is a string.
Variable
A variable is like a container used to store data.
Real-life Example
Think of a glass as a variable.
The same glass can store:
- Juice
- Lassi
- Soft drink
- Water
- Can be used as a small dustbin
Similarly, a variable can store different types of data.
In programming:
- Variables store values
- Values can be numbers, text, or other data
Function
A function is used to perform a specific task.
We call a function when we want that task to be done.
Real-life Example
Think of a juicer as a function.
- Fruits or vegetables → arguments (input)
- Juicer processes them
- Juice → return value (output)
In programming:
- We pass input to a function
- The function processes it
- The function gives output
Simple Summary
- Character → Single keyboard symbol
- String → Group of characters
- Variable → Container to store data
- Function → Performs a specific task