Python Basics Programming Fundamentals
BASIC PROGRAMMING FUNDAMENTALS - Complete Go to Guide for Beginners
String:
String is simply sequence of characters.
It contains letters, numbers, symbols all that stuff.
Uses of Strings
1- Representation of Data
2- Data Storage & Manipulation {Manipulation means changing or modify data}
3- Formatting & Display
4- User Interaction
5- Complex Data Structures
6- Inter-Program Communication
Lists:
Lists are used usings square brackets [].
List items are ordered, changeable, and allow duplicate values. List items are indexed, the first item has index [0], the second item has index [1] etc. Allow Duplicates.
Tuples:
Tuples are used to store multiple items in a single variable. A tuple is a collection which is ordered and unchangeable. Tuples are written with round brackets.
To create a tuple with only one item, you have to add a comma in the last, otherwise Python will not recognize it.
Python Sets:
They are used to store multiple items in a single variable. A set is a collection, which is unordered, unchangeable, unindexed. Set items are unchangeable, but you can add or remove items in it.
Duplicates are not allowed in Sets.
Python Dictionaries:
Dictionaries are used to store data values in key: value pairs.
A dictionary is a collection which is unordered, changeable & don't allow duplicates.
String Manipulation in Python:
.lowercase() {converting all words to lowercase}
.uppercase() {converting all words to uppercase}
.len() {checing the length of the words}
.find ()
.replace ()
.slice () {breaking down the sentence into words}
.index() {to check out, where the word is placed}
.count()
.split()
.captialize()
.swapcase() {first letter will be lowercased, other will be uppercased}
.title()
.join() {to add something b/w the words}
.join(reversed()) {reverse the words}
.strip()
.rstrip()
.lstrip()
.isalnum()
.isalpha()
.isdigit()
.istitle()
.isupper()
.islower()
.isspace()
.endswith('')
.startswith('')
.partition()
.format()
.isascii()
.isdecimal()
.isidentifier()
.islower()
.isprintable()
.isspace()
.istitle()
.isupper()
Recommended by LinkedIn
.ljust()
.rjust()
.lstrip()
str.maketrans() {Method to create a translation table}
.translate() {to translate or replace words}
.rfind()
.rindex()
.rpartition()
.zfill()
.casefold()
.centre()
.encode() {used to convert strings into bytes}
.expandtabs() {create spaces b/w words}
To compare two strings, we use '==' operator.
Join Two or More Strings, we use '+' operator e.g. like sum function.
Also check out escape sequences in Python like use of {\n, \t, \b etc.}
\\ (Backslash)
\' (single quote)
\" (Double quote)
\b (ASCII Backspace)
\n (ASCII linefeed)
\r (ASCII carriage return)
\t (ASCII horizontal tab)
\ooo (Character with octal value ooo)
\xHH (Character with hexadecimal value HH)
Python String Formatting (f-Strings)
NLP Pre-processing means converting raw data into suitable formats.
List Functions in Python:
.len()
.max()
.min()
.sorted()
.append() {add something new to list}
.insert()
.extend()
.remove()
.pop()
.index()
.count()
.reverse() {reverse the order}
.clear() {empty the list}
.copy() {copy from one list to another}
.sort {to arrange in ascending order}
.del()
.type()
Tuples:
To create inner tuples, we use tuple constructor.
Creating Tuples
Accessing Elements
Tuple Unpacking
Immutability
Concatenation
Repetition
Methods
Python Sets:
.union()
.intersection()
.difference()
#datascience #artificialintelligence #python #strings #lists #tuples #sets #pythonbasics #hamzanadeem