Python

Python – Introduction

Introduction: Types of applications: Standalone apps: Web apps: Download python: Python is used to develop both Standalone and Web applications:

Python – Translators

Translators: Compiler: Note: Java programming language use compilation class Program{            public static void main(String[] args)            {                        int a=10;                        System.out.println(“a val : ” + a);                        int b=20;                        System.out.println(“b val : ” + b);                        System.out.println(“c val : ” + c);            }} Compile: Error @ line – 11 (variable “c” not present) Interpreter: Note: Python programming uses interpretation …

Python – Translators Read More »

Python – Proramming and Scripting

Python(Programming & Scripting): Program: Script: JavaScript: <!doctype html><html>            <head>                        <title> Java Scripting </title>            </head>            <body>                        <script>                                    alert(“Hi I am Java Script Function”);                                    alert(“I can run only from HTML code”);                        </script>            </body></html>

Python – Dynamic Programming Language

Python is Dynamic: Static memory: Dynamic memory: In Python, object location changes every time when we modify the data. >>> a=10>>> print(a)10>>> print(“Address :”,id(a))Address : 1628169120 >>> a=a+15>>> print(a)25>>> print(“Address :”,id(a))Address : 1628169360 >>> a=”python”>>> print(a)python>>> print(“Address :”,id(a))Address : 48576832

Python – Operators – Arithmetic Operators

Operator: Arithmetic operators: print(“Arithmetic operations”)print(“5+2 :”, 5+2)print(“5-2 :”, 5-2)print(“5*2 :”, 5*2)print(“5/2 :”, 5/2)print(“5%2 :”, 5%2)print(“5//2 :”, 5//2)print(“5**2 :”, 5**2) int a=10;                                 a=20;a=30;a=40;a=50;print(a); int a=5;                                       a=a+1;a=a+1;a=a+1;a=a+1;print(a); int a=5;                                       a=a+1;a=a+2;a=a+3;a=a+4;print(a); int a=15;                                       a=a+5;a=a+4;a=a+3;a=a+4;print(a); int a=5, x=1;                                a=a+x;x = x+1;a=a+x;x = x+1;                                       a=a+x;x = x+1;a=a+x;print(a, x); int a=5, b=5;                                a=a+b;b = b-1;a=a+b;b= b-1;                                       a=a+b;b = b-1;a=a+b;print(a, b); int n=2;                        int s=n*n;print(s); int n=2;                      int c=n*n*n;print(c); int n=2;                        int s=n*n;int …

Python – Operators – Arithmetic Operators Read More »

Python – input() function

Reading input from End-user : print(“Enter your name :”)name = input()print(“Hello,”,name) Note: We can give the prompt while reading input name = input(“Enter your name : “)print(“Hello,”,name) Note: Every input value will be returned in String format only. print(“Enter 2 numbers :”)a = input()b = input()c = a+b   # “5” + “6” = “56”print(“Sum :”,c) …

Python – input() function Read More »

Python – Data Conversion Functions

int( ) : >>> int(10)10>>> int(23.45)23>>> int(True)1>>> int(False)0>>> int(“45”)45>>> int(“python”) # Error : Invalid input Adding 2 numbers: print(“Enter 2 numbers :”)a = input()b = input()c = int(a)+int(b)print(“Sum :”,c) We can give the prompt directly while calling input() function. x = int(input(“First Num :”))y = int(input(“Second Num :”))print(“Sum : “,x+y) float() : >>> float(2.3)2.3>>> float(5)5.0>>> …

Python – Data Conversion Functions Read More »

Python – Relational Operators

Relational operators: print(“Relational operations”)print(“5>3 :”, 5>3)print(“5==3 :”, 5==3)print(“5<3 :”, 5<3)print(“5!=3 :”, 5!=3)print(“5>=3 :”, 5>=3)print(“5<=3 :”, 5<=3) Condition to check the number is Positive Condition to check the number is equal to zero Condition to check the 2 numbers equal Condition to check First Num greater than Second Num Square of First Number not equals to …

Python – Relational Operators Read More »

Scroll to Top