Python Crash Course
Python Crash Course
Ex:
1. Create variable in both python and C++ programming language
respectively
2. In Two paragraphs, discuss on variables
Rules in naming variable
All though we can name a variable with any name of our choice, it is
preferable to give your variable a meaningful name. below are rules to
follow in naming a variable in python
1. Snake_case
2. Start with lowercase or underscore
3. Letters, numbers, underscore
4. Case sensitive
5. Don’t overwrite keywords
String
• A string is a sequence of characters, it is denoted either with a single or
double quote in most programming language. Example of a string
“we are learning data structure”
‘’’’
• The concept of Concatenation (adding strings together)
Type conversion
In some instances we might be force to convert a data type from initial
state to another
The process of Converting data type from one form to another is called
type conversion
Example:
Formatted strings
• Activity:
Read on formatted strings and its advantages
String Index
• All string are represented with a number called index
• Same index in arrays/list
• Example
Immutability
• The process of not supporting element reassignment
Exercise (type conversion)
Write a python program that will guess a users age base on the birth
year given.
Exercise:
Create a list of numbers traverse through it, find the sum and average
of the numbers