Python Basics
Basic Syntax
Setup the environment for python and get started with the basics.
Visit the following resources to learn more:
- W3Schools - Python
- Python for Beginners - Learn Python in 1 Hour
- Python Basics
- Learn X in Y Minutes / Python
Variables
Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.
Visit the following resources to learn more:
- Variables in Python
- W3Schools — Python Variables
- Python Variables - Geeks for Geeks
- Python Data Types
- Basic Data Types in Python
- Python for Beginners: Data Types
Literals
- r prefixed string are raw, it treats
\
as raw character
s = r'c:\path'
Conditionals
Conditional Statements in Python perform different actions depending on whether a specific condition evaluates to true or false. Conditional Statements are handled by IF-ELIF-ELSE statements and MATCH-CASE statements in Python.
Visit the following resources to learn more:
- Python Conditional Statements: IF…Else, ELIF & Switch Case
- Conditional Statements in Python
- How to use a match statement in Python
Typecasting
The process of converting the value of one data type (integer, string, float, etc.) to another data type is called type conversion. Python has two types of type conversion: Implicit and Explicit.
Visit the following resources to learn more:
- Type Conversion and Casting
- Type Casting in Python with Examples
- Python Exceptions: An Introduction
- Errors and Exceptions
- Python Exception Handling
- Python Try Except
Functions
In programming, a function is a reusable block of code that executes a certain functionality when it is called. Functions are integral parts of every programming language because they help make your code more modular and reusable.
In Python, you define a function with the def
keyword, then write the function identifier (name) followed by parentheses and a colon.
Visit the following resources to learn more:
- Python Functions – How to Define and Call a Function
- Python Functions - W3Schools
- Python Functions
- Built-in Functions in Python
Lists, Tuples, Sets, and Dictionaries
Lists: are just like dynamic sized arrays, declared in other languages (vector in C++ and ArrayList in Java). Lists need not be homogeneous always which makes it the most powerful tool in Python.
Tuple: A Tuple is a collection of Python objects separated by commas. In some ways, a tuple is similar to a list in terms of indexing, nested objects, and repetition but a tuple is immutable, unlike lists that are mutable.
Set: A Set is an unordered collection data type that is iterable, mutable, and has no duplicate elements. Python’s set class represents the mathematical notion of a set.
Dictionary: In python, Dictionary is an ordered (since Py 3.7) [unordered (Py 3.6 & prior)] collection of data values, used to store data values like a map, which, unlike other Data Types that hold only a single value as an element, Dictionary holds key:value pair. Key-value is provided in the dictionary to make it more optimized.
Visit the following resources to learn more:
- Difference Between List, Tuple, Set and Dictionary in Python
- Differences and Applications of List, Tuple, Set and Dictionary in Python
- Tuples vs. Lists vs. Sets in Python
- Python for Beginners: Lists
- Python for Beginners: When and How to Use Tuples
String Methods
Python does not have a character data type, a single character is simply a string with a length of 1. Square bracket can be used to access elements of the string. There are methods which can be used on a string to best utilize it's wide range of functionalities. Below Given resources can be utilised to learn more about them.
Visit the following resources to learn more:
- Practical String Methods applications
- Comprehensive Study of String methods
- String Slicing in Python# Python
Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically-typed and garbage-collected.
Visit the following resources to learn more: