Day 13/14 : Basic Python

Day 13/14 : Basic Python

A Beginner's Guide to Programming with Python

·

2 min read

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

  1. Integers ('int'):Whole numbers. (x=10)

  1. Float ('float'):Numbers with decimal points.(y=3.14)

  2. Strings ('str'):text sequences.(message="Hello , Python !")

  3. Booleans ('bool'): 'true' or 'False' values. (is_true= true)

  4. Lists ('list') : ordered , immutable sequences. (my _list =[1,2, 'three' , 4.0)

  5. Dictionaries ('dict') :Unordered key-value pairs.(my_dict ={'name' : 'manasa' , 'age' :21 , 'city' : 'banglore'})

  6. sets ('set') : unordered uniquies elements. (my_set =(1,2,3,4)

  7. 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.

  1. Arrays ('array'):Homogeneous, fixed-size sequences, available through the 'array' module.

    from array import array

    my_array = array ('i', [1,2,3])

  2. Queues ('queue') :Provides the 'queue' class implementing queues.

    from queue import queue

    my_queue = Queue ( )

  3. Stacks ('stack'): Can be implemented using lists or the 'collections' module's 'deque'.

    from collections import deque

    my_stack = deque ( )

  4. 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

  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

  1. Here I have Created a List of cloud service providers\=[ 'AWS' , 'GCP' , 'AZURE' ]

  1. Here I have added 'Digital ocean'.

  1. Here I have sorted in alphabetical order.

THANK YOU FOR READING!

Do follow me on LinkedIn for further blogs.

linkedin.com/in/manasa-j-03b633238