DEV Community

SyedAsadRazaDevops
SyedAsadRazaDevops

Posted on • Updated on

Learn PYTHON for DevOps ♾️in 3 DAYs.

Prerequisite: PYTHON INSTALLATION WITH VIRTUAL ENVIRONMENTS

install the python latest version
so visit python.org

What is VS code?
it's an editor where you can read and write code, simple :). it's good to download VS code and install it.

How to install it ?
open terminal in VScode and create folder for project
and create virtual environment

pip install virtualenv
Enter fullscreen mode Exit fullscreen mode
virtualenv -p python3.10 <name>
Enter fullscreen mode Exit fullscreen mode

it will create the env folder in your directory or folder
now active this environment

source env/bin/activate
Enter fullscreen mode Exit fullscreen mode
python --version
Enter fullscreen mode Exit fullscreen mode
deactivate
Enter fullscreen mode Exit fullscreen mode

Day-1 : YOUR FIRST CODE

Then you say that, ** i'm not a programer or coder?** it's mean you are unable to transfer your need file <code>.py to the OS compiler to compile and operate your task as you wish/need.

open the interactive terminal of python

python
Enter fullscreen mode Exit fullscreen mode

Variable and constance
V >> a=20
C >> 20

data type in puthon
[int,float,str,bool]
int >> a=20
float >> a=20.01
str >> a="asad"
bool >> coding=true

type(a) && type(coding)
Enter fullscreen mode Exit fullscreen mode

output:

<class 'int'> <class 'bool'>
Enter fullscreen mode Exit fullscreen mode

take input from user
`

num=input("Enter your number")

**take input from user with type casting**

num=int(input("enter your number"))
`
Steps

CODE BLOCK #1

let make a script of python using simple conditional statement.
my_first_code.py

env=input("enter your cloud: ")
if env == "aws" or env =="AWS":
print("you are in AWS environment")
else:
print("you are in an other cloud environment")

you can run this file from VScode terminal or OS terminal by just define the file name with python command.remember : terminal open in the same working path

python *my_first_code*.py
Enter fullscreen mode Exit fullscreen mode

or

python3.10 *my_first_code*.py
Enter fullscreen mode Exit fullscreen mode

let make another calculater script of python using simple conditional statement.
calculater_code.py

num1 = float(input("enter your first number")
num2 = float(input("enter your second number")
opr = input("enter your operator")

if opr == "+":
output=num1+num2
if opr == "-":
output=num1-num2
if opr == "*":
output=num1*num2
if opr == "/":
output=num1/num2
if opr == "%":
output=num1%num2
print("you calculation is equal to ",output)

if num1 < 3:
print("you are in an other cloud environment")

CODE BLOCK #2

let make another script of python using list Function.
my_Second_code.py

names = list([ "syed","johan","nihao","Ramesh"])
//// to get the full list of names.
print(names)
//// to get the list of names by calling them separately.
print(names[0])
print(names[1])
print(names[2])
print(names[3])

READ BLOCK #1

let start reading the most basic and advance concept of Python by just go-throw the linkedin Skill Quiz assessment.

the best thing of this link is an Open-source python repository, So the new changing are Committed and new question is added by the multiple people which is almost an python expert.

Top comments (2)

Collapse
 
decker67 profile image
decker

Big promise not fullfilled.

Collapse
 
syedasadrazadevops profile image
SyedAsadRazaDevops • Edited

don't worry, i will complete it asap.its underwriting, story will done in this september :)