التخطي إلى المحتوى الرئيسي

المشاركات

عرض الرسائل ذات التصنيف Python

Python Introduction:-

Python is a high-level script-based language that contains the only interpreter to execute a python script. Script-based language means the language that will be executed by the  Interpreter. The interpreter will execute  the code line by lin e, Script-based language does not contain any separate compiler to convert the code. the compiler will be in-built under the interpreter. PHP,  PYTHON,  RUBY,  JS,  JQUERY,  ANGULAR,  NODE,  REACT all are script-based languages. Initially, a Python script was developed to create a device driver-based software system for the different operating systems. But now  Python is complete technology or platform which contain multiple library , framework, and support to create application softwar e. using Python script We can create the following application. 1 Desktop Application:-    This type of application will be installed separately on each machine. without using the internet this type ...

Python Installation

Python has an in-built IDLE that is best for python beginners. 1) PYTHON IDLE INSTALLATION Using Python .exe file Python will be installed using two different ways 1) Offline using Python IDLE 2) Online using Jupyter 1)  Offline installation using IDLE:- Step1st:- We can Install Python easily go into www.python.org and click on downloads  and download python.exe file, double click it, and install it. https://www.python.org/downloads for window 7 and before windows 7 o/s:-  Python 2.7 version should be installed. After this version, we can install Python 3: Step2nd:- Open Python IDLE ( Integrated Development Learning Environmen t) By Default IDLE Provide Terminal mode which is for instant script execution for System administrator  step3rd:- Click on File---> New File Option---> Write Python Script print("Welcome in Python Script") print("It is a script-based programming language which was created by GUIDO VAN RASSUM") step4th:- Save this file using the .py ...

History & scope of Python

Python is a script based language which will be executed by the Python interpreter itself. The python script is easy to learn and a light-weight script as compare to other programming languages. A python script was developed by GUIDO VAN ROSSUM to create a device driver-based application initially. but now Python is complete technology that is used to develop System Software, Application Software , Data Science , Machine Learning , Interface Programming , Game Development, Electronic Software Implementation with IoT and Aurdino , Automation Programming for Software Testing. Python Script performance is best as compare to other languages means its performance is much better as compared to C, CPP, Java, PHP, and Another Programming language. Python script only focuses on a set of code .it not use code pattern and code structure. ........................................................................................................................................................

What is Compiler, Interpreter, Linker, Loader, Assembler in a Programming language?

Compiler:-   It is an intermediate machine that is used to convert the complete set of code from one language to another using a data dictionary. A compiler is nothing it is a converter that is used to convert the source code to machine code according to technology. The compiler always will convert the code using a group of lines. C, CPP,  JAVA,  .NET these all use Compiler Interpreter:-   It is used to read the program code line by line and execute then show the result by the operating system. PYTHON,HTML,JS,PHP,RUBY these are languages use Interpretar. Interpreter based language is also called    Script-based language . Linker:-  It is used to link the program code from the same file or different file. all library functions, metadata, and other files also linked by Linker. it will execute before compilation. for example, if we create a method in one file and calling from another file then the linker will link both files then execute it...

What is Program and Programming language?

It is a set of instructions to complete the task. instruction can be mathematical, logical, conditional, and comparison based. PSEUDO CODE of addition program a=10 b=20 c=a+b, display c Programming language:- It is a set of codes to create a program practically and load into a compiler or interpreter . Software is a set of programs and programs will be developed by a set of codes hence programming language is used to develop a software application . Type of Programming languages:- 1 Based on Execution:- 1.1.1 low level:-  It will be executed directly under the operating system with no need to use any intermediate. Binary Code 1.1.2   middle level:-  It will be executed by Single Intermediate means compiler or interpreter to convert program code into machine code. C, CPP, HTML, Assembly code 1.1.3  high level:-  It will be executed by a minimum of Two Intermediate means multiple compiler and interpreter. Java,.NET, Objective-c, Kotlin, C#, VB,, Python, P...

Variable,Constant and Literals Declaration in Python

Variable :-   it is an identifier that is used to contain values in the program. variable value and type can be changed in the program at run time. Python variable datatype will be managed by the assigned value . Python variable type and memory allocation depend on assigned data .we can provide multiple data types for a single variable in the python program. Python variable is a loosely coupled type declaration so that we can change variable datatype in the program. The syntax for Variable Declaration in Python:- identifier=value  #single value  identifier1,identifier2,...= value1,value2,..   #multiple variable, multiple value a=10 a,b,c = 10,20,30 a,b=10,20 print(a+b) Example of variable:- a,b = input("enter first number"),input("enter second number") print(a+b)   #  "10"+"20"  "1020" print(int(a)+int(b))  # 10+20 print(int(a+b))    #  1020  int print(int(a)+float(b))   

Input and Output Operation in Python,How to take input from user's in Python,How to display output in Python

Python provides input() and print() to take input and display output into the program. Python provides a predefined function to take input from the keyboard and display output into the monitor. 1)  input(): -   It is used to take input from the keyboard using a String pattern (a combination of char), we can pass the display message as a parameter into input(). that is used to reduce the extra code as compared to C and CPP programming language. var = input("message")      #var is the variable name which will assign input data into string pattern we can convert input data into other datatype such as int, float using the type conversion method. to convert into an integer then it provides int(), to convert into float it provides float(). input() takes one parameter to display the message in a String format and it also returns data into String form. var = input("message") Example of input() to take input for integer data a = int(input("Enter number")) Exam...

Data Type in Python,What is Data Type in Python

The data type is used to provide a pattern , size, and memory allocation of data using variable, constant, and method. Python uses data type internally in the program, no need to write a data type declaration in the program because python provides flexibility to the identifier to contain multiple types of data using a  single name identifier. a=10 a= "hello" a= True Type of Data type:- Primitive Type:-  it is the primary data type of Python that is common for all programming languages. 1 int :-       a=10 2 float:-     a=12.34 3 String:-   Collection of Char's 1)  String With Double Quote:- It used to declare outer String on Python Script. s= "data"        2)  String With Single Quote:- It is used to declare inner String on Python Script. s= 'data'             3)  String With double quote three times s= """data"""    it support paragraph pattern or multilin...

Operator Tutorials in Python, What is Operator in Python, Type of Operator in Python

Operator Concept in Python It is used to perform an operation using operand. the operand can be variable, constant, or literals . The operator is defined as a predefined function in the python class library and it will be called by the symbol. python has __add__() for addition which will be called + symbol Type of operator 1 Arithmetic Operator:-   This operator is used to perform the mathematical operations in the Python program. +  (addition) and String Concatenation   10+20 (30)  "10"+"20" (1020) 10+20.0 (30.0)  -  (Subtraction) * (Multiplication)  / ( true division )      5/2(2.5)  // (floor division)    5//2 (2 ignore fractional part and provide least integer part)  ** (power)           %  ( remainder)     5%10 (5)   10%3 (1) Example of True Division and Floor Division:- a=10 #b= a/3   # True division b = a//3  # floor Divisio...

Ternary operator in python

It is used to solve a condition-based program using a single-line statement. ternary operator contains an if-else statement using a single line. It is used to solve a condition-based program using a single-line statement. Syntax:- var =   True statement if condition else false statement print(var if condition else var) Example of a ternary operator in Python? Q) WAP to check the greater number using Ternary Operator? Solution First:- a = int(input("enter first number")) b = int(input("enter second number")) res =  "a is greater" if a>b else "b is greater" print(res) Solution Second:- a = int(input("enter first number")) b = int(input("enter second number")) print(a if a>b else b) WAP to check vowel and consonant using a ternary operator? s = input("enter char to check vowel and consonent") o = "Vowel" if s=='a' or s=='e' or s=='i' or s=='o' or s=='u' else ...

Conditional Statement in Python

It is used to solve condition-based problems using if and else block-level statement. it provides a separate block for  if statement, else statement, and elif statement . elif statement is similar to elseif statement of C, C++ and Java languages. Type of Conditional Statement:- 1) Simple if:- We can write a single if statement also in python, it will execute when the condition is true. for example, One real-world problem is here?? we want to display the salary of employees when the salary will be above 10000 otherwise not displayed. Syntax:- if(condition):    statements The solution to the above problem sal = int(input("Enter salary")) if sal>10000:     print("Salary is "+str(sal)) Q)  WAP to increase the salary of employees from 500 if entered salary will be less than 10000 otherwise the same salaries will be displayed. Solution:- x = int(input("enter salary")) if x<10000:     x=x+500 print(x)   Q) WAP to display th...

Loop Tutorials in Python,For,While,For--else,While--else example in Python

It is used to print range-based data using a common repeatable block. It is also called an  iterative statement because it is used to enumerate data of LIS T, Tuple , Dictionary , Set , and Database objects. for example, if we want to print data from 1 to 1000 then we will prefer a loop statement. 1) While Loop Example in Python:-  2) For Loop in Python:- 3) Nested For Loop in Python with Example:- Flow of Loop 1    Forward      i=min      i<=max      i=i+1                  range(min,max) 2    Backward   i=max     i>=min      i=i-1                  range(max,min,-1) 3    Infinite        i=min,max  ,no condition, i=i+1,i=i-1 Type of Loop:- 1)  while loop and while--else loop:- it w...

Break,Continue and Pass Statement in Python

Break, Continue and Pass Statement in Python:- Break:-   It is used to manually terminate the loop based on condition, the break statement always will be defined by the Conditional Statement in Loop. for i in range(1,10):       if i==3:          break;       print(i) output:-  1                 2 Continue:-   It is used to skip the particular data from the loop and continue the process of the loop.  for i in range(1,10):     if i==3:        continue    print(i) output:-  1                2                4                5                6                7               ...

List Operation in Python, List example in python

The list is a collection of items using proper sequence, It is similar to an array of other programming languages but the array contains a collection of similar types of elements but the list contains a collection of similar and dissimilar types of elements both. The list provides an ordered collection of data, and it can store any type of element. LIST provides a mutable object that means we can add, edit, and delete elements dynamically in the list. Syntax of List:- var = [item1,item2,item3,...] x = [12,23] Add element:- x.append(24)   #[12,23,24] Delete an element from LIST:- del  x[0] Modify List element:- x[index]=value LIST Program to implement all operation:- x = ["vegetable","rice","fruit","oil","flour"] #print(x[0],x[1],x[2],x[3],x[4]) for i in range(0,len(x)):     print(x[i]) for value in x:    print(value) #to display a particular range print(x[3:]) print(x[2:4]) print(x[-4:-1]) print(x[-4]) print(x[:3]) print(x[:]) x.appen...