What is python?
Python is a versatile, high-level programming language known for its readability and simplicity.
It is widely used in web development, data science, machine learning, and automation due to its clear syntax, extensive standard library, and cross-platform compatibility.
Key features:
Clear and Readable Syntax
Extensive Standard Library
Dynamic Typing
Interpreted Language
Data Types in python
- Integers ('int'):Whole numbers. (x=10)
Float ('float'):Numbers with decimal points.(y=3.14)
Strings ('str'):text sequences.(message="Hello , Python !")
Booleans ('bool'): 'true' or 'False' values. (is_true= true)
Lists ('list') : ordered , immutable sequences. (my _list =[1,2, 'three' , 4.0)
Dictionaries ('dict') :Unordered key-value pairs.(my_dict ={'name' : 'manasa' , 'age' :21 , 'city' : 'banglore'})
sets ('set') : unordered uniquies elements. (my_set =(1,2,3,4)
Tuple ('tuple') : Ordered, immutable sequence of elements.
Data structures
Python provides several built-in data structures that enable you to organize and store data efficiently.
Arrays ('array'):Homogeneous, fixed-size sequences, available through the 'array' module.
from array import array
my_array = array ('i', [1,2,3])
Queues ('queue') :Provides the 'queue' class implementing queues.
from queue import queue
my_queue = Queue ( )
Stacks ('stack'): Can be implemented using lists or the 'collections' module's 'deque'.
from collections import deque
my_stack = deque ( )
Linked Lists : Can be implemented using classes, defining nodes with values and references to the next node.
class Node :
def __init_ (self ,data):
self.data=data
self.next = None
- These data structures serve different purposes and are used based on the specific requirements of a program or algorithm.
- They form the foundation for creating more complex data structures and implementing various algorithms efficiently in Python.
Task - 1
- Create below Dictionary and use Dictionary methods to print my_dict just by using the keys of the Dictionary.
my_dict =
{
1:"Linux",
2:"Git",
3:"Docker",
4:"Kubernetes",
5:"Terraform",
6:"Ansible",
7:"Chef"
}
step 1 : Here I have created the dictionary with the above contents.
step 2 : Only key numbers
step 3 : Only values
step 4 : Particular Tool from dictionary
Task - 2
- Here I have Created a List of cloud service providers\=[ 'AWS' , 'GCP' , 'AZURE' ]
- Here I have added 'Digital ocean'.
- Here I have sorted in alphabetical order.
THANK YOU FOR READING!