python is the best programing languAge python complete TUTORIAL WITH SOURCE CODE

Python Tutorial

Python Tutorial Python FeaturesPython HistoryPython ApplicationsPython InstallPython ExamplePython VariablesPython Data TypesPython KeywordsPython LiteralsPython OperatorsPython CommentsPython If elsePython LoopsPython For LoopPython While LoopPython BreakPython ContinuePython PassPython StringsPython ListsPython TuplesPython List Vs TuplePython SetsPython DictionaryPython FunctionsPython Built-in FunctionsPython Lambda FunctionsPython Files I/OPython ModulesPython ExceptionsPython DatePython RegexPython Sending EmailRead CSV FileWrite CSV FileRead Excel FileWrite Excel FilePython AssertPython List ComprehensionPython Collection ModulePython Math ModulePython OS ModulePython Random ModulePython Statistics ModulePython Sys ModulePython IDEsPython ArraysCommand Line ArgumentsPython Magic MethodPython Stack & QueuePySpark MLlibPython DecoratorPython GeneratorsWeb Scraping Using PythonPython JSONPython ItertoolsPython MultiprocessingHow to Calculate Distance between Two Points using GEOPYGmail API in PythonHow to Plot the Google Map using folium package in PythonGrid Search in PythonPython High Order Functionnsetools in PythonPython program to find the nth Fibonacci NumberPython OpenCV object detectionPython SimpleImputer moduleSecond Largest Number in Python

Python OOPs

Python OOPs ConceptsPython Object ClassPython ConstructorsPython InheritanceAbstraction in Python

Python MySQL

Environment SetupDatabase ConnectionCreating New DatabaseCreating TablesInsert OperationRead OperationUpdate OperationJoin OperationPerforming Transactions

Python MongoDB

Python MongoDB

Python SQLite

Python SQLite

Python Questions

How to install Python in WindowsHow to reverse a string in PythonHow to read CSV file in PythonHow to run Python ProgramHow to take input in PythonHow to convert list to string in PythonHow to append element in the listHow to compare two lists in PythonHow to convert int to string in PythonHow to create a dictionary in PythonHow to create a virtual environment in PythonHow to declare a variable in PythonHow to install matplotlib in PythonHow to install OpenCV in PythonHow to print in same line in PythonHow to read JSON file in PythonHow to read a text file in PythonHow to use for loop in PythonIs Python scripting languageHow long does it take to learn PythonHow to concatenate two strings in PythonHow to connect Database in PythonHow to convert list to dictionary in PythonHow to declare a global variable in PythonHow to reverse a number in PythonWhat is an object in PythonWhich is the fastest implementation of PythonHow to clear Python shellHow to create a DataFrames in PythonHow to develop a game in PythonHow to install Tkinter in PythonHow to plot a graph in PythonHow to print pattern in PythonHow to remove an element from a list in PythonHow to Round number in PythonHow to sort a dictionary in PythonStrong Number in PythonHow to Convert Text to Speech in PythonBubble Sort in PythonLogging in PythonInsertion Sort in PythonBinary Search in PythonLinear Search in PythonPython vs ScalaQueue in PythonStack in PythonHeap Sort in PythonPalindrome program in pythonProgram of Cumulative sum in pythonMerge Sort in PythonPython MatrixPython Unit TestingForensics & VirtualizationBest Books to Learn PythonBest Books to Learn DjangoGCD of two number in pythonPython Program to generate a Random StringHow to One Hot Encode Sequence Data in PythonHow to write square root in PythonPointer in PythonPython 2D arrayPython Memory ManagementPython Libraries for Data VisualizationHow to call a function in PythonGit Modules in PythonTop Python Frameworks for GamingPython Audio ModulesWikipedia Module in PythonPython random randrange()Permutation and Combination in PythonGetopt module in PythonMerge two Dictionaries in PythonMultithreading in Python 3Static in PythonHow to get the current date in Pythonargparse in PythonPython tqdm ModuleCaesar Cipher in PythonTokenizer in PythonHow to add two lists in PythonShallow Copy and Deep Copy in PythonAtom PythonContains in PythonLabel Encoding in PythonDjango vs. Node JSPython FrameworksHow to create a vector in Python using NumPyPickle Module of PythonHow to convert Bytes to string in PythonPython Program to Find AnagramHow to convert List to SetPython vs JavaScriptPython Holidays ModuleFuzzyWuzzy Python LibraryDask PythonDask Python (Part 2)Mode in PythonMenu-Driven Programs in PythonPython Array vs. ListWhat is duck typing in PythonPEP 8 in PythonPython User GroupsBasic Commands in PythonF String in PythonHow Brython WorksHow to use Brython in the BrowserArima Model in PythonPython Modulus OperatorMATLAB vs. PythonMethod Resolution Order in PythonMonkey Patching in PythonPython __call__ methodPython heapq modulePython SubstringProject ideas for Python BeginnersPython FakerFizz-Buzz Program in PythonTabula PythonPython Program to Print Prime Factor of Given NumberPython Program to Print Pascal TriangleNamedTuple in PythonOrderedDict in PythonT-Test in PythonPython return statementGetter and Setter in PythonEnum class in PythonDestructors in PythonCurve Fit in PythonConverting CSV to JSON in PythonUnderscore (_) in PythonSet vs List in PythonLocating and Executing ModulesFlatten List in PythonPair Plot in PythonData Hiding in PythonPython Program to Find Intersection of Two ListsHow to Create Requirements.txt File in PythonTic-Tac-Toe in PythonPython Asynchronous Programming – asyncio and awaitPython main() functionstrftime() function in PythonVerbose Flag in Python RegexPython AST ModulePython Requests Module – HTTP RequestShutil Module in PythonPython epoch to DatetimePython del StatementLooping technique in PythonMetaprogramming with Metaclasses in PythonPrecision Handling in PythonPython Join Liststrip() function in PythonGradient Descent AlgorithmPrettytable in PythonSentiment Analysis in PythonConvert Python List to NumPy ArraysTraceback in PythonTime clock() Method in PythonDeque in PythonDictionary Comprehension in PythonPython Data AnalyticsPython seek() MethodTernary Operator in PythonHow to Calculate the Area of the Circle using PythonHow to Write in Text File using PythonPython KeyErrorPython super() Functionmax() function in PythonFraction Module in PythonPopular Python Framework to Build APIHow to Check Python versionPython %s – String FormattingPython seaborn LibraryCountplot in Pythonrange() Vs. Xrange() PythonWordcloud Package in PythonConvert dataframe into listANOVA Test in PythonPython program to find compound interestAnsible in PythonPython Important Tips and TricksPython CoroutinesDouble Underscores in VS re.findall() in Python RegexHow to install statsmodels in PythonCos in Pythonvif in Python__add__ Method in PythonEthical Hacking with PythonClass Variable vs InstancePerfect Number in PythonEOL in PythonPython Program to convert Hexadecimal String to Decimal StringDifferent Methods in Python for Swapping Two Numbers without using third variableHow to Change Plot Size in MatplotlibHow to Get the Zip Code in PythonEel in PythonAssignment Operators in PythonSpeech Recognition pythonYield vs Return in PythonGraphene PythonName Mangling in PythonPython combination without itertoolsPython ComprehensionsInfluxDB in PythonKafka Tutorial in PythonAugmented Assignment Expressions in PythonPython (x,y) SoftwarePython Event-Driven programmingPython SemaphorePython sorted reverseAutomorphic Number in Pythonsizeof in PythonPython Program for accepting the strings which contains all vowelsClass-based views vs Function-Based ViewsHow to handle cookies in Djangoagg() function in PythonAmicable Numbers in PythonContext Manager in PythonCreate BMI Calculator using PythonString to Binary in PythonWhat is script mode in PythonBest Python libraries for Machine LearningPython Program to Display Calendar of Given YearHow to open URL in PythonBroken Pipe Error in PythonCode Template for Creating Objects in PythonPython program to calculate the best time to buy and sell stockTuple to String in PythonKadane’s Algorithm in PythonLoggers in DjangoWeather App in DjangoMissing Data Conundrum: Exploration and Imputation TechniquesDifferent Methods of Array Rotation in PythonWhat is Operator Overloading in PythonDefaultdict in PythonOperator Module in PythonSpinner Widget in the kivy Library of PythonNumber Plate Recognition using PythonObfuscating a Python programConvert string to dictionary in PythonConvert string to JSON in PythonDBSCAN algorithm in PythonHow to Write a Code for Printing the Python Exception/Error HierarchyPrincipal Component Analysis (PCA) with PythonPython Program to Find Number of Days Between Two Given DatesObject Recognition using PythonPython VLC moduleSet to list in PythonString to int in PythonInternet of Things with PythonPython pysftp moduleAmazing hacks of PythonAverage of list in PythonCheck Installed Modules in Pythonchoice() in PythonConvert List to dataframe in PythonConvert String to Float in PythonDecorators with Parameters in PythonDynamic Typing in PythonFabs in PythonHow to Remove Decimal in PythonPython ClosurePython Glob ModuleWriting a Python ModuleModules vs Packages in PythonSNMP module in PythonAverage of list in PythonAppend vs Extend vs Insert in PythonHow to Remove Duplicates from a list in PythonRemove Multiple Characters from a String in PythonShuffle in Pythonfloor() and ceil() Functions in Pythonsqrt(): Math Function of PythonPython yfinance ModuleDifflib module in PythonConvert the Column Type from String to Datetime Format in Pandas DataFramePython wxPython ModuleRandom Uniform PythonRelational Operators in PythonString to List in PythonChatbot in PythonHow to Convert float to int in PythonMultiply All Elements in list of Pythonmodule vs function in PythonReverse a tuple in PythonTuple to Dictionary in Pythondatetime.timedelta() Function of PythonPython Bio ModulePython Dash ModuleHow to Select rows in Pandas DataFrame Based on ConditionsTypecasting in PythonDateutil module in PythonGetpass module in PythonPython Wand libraryGenerate a QR Code using PythonBest Python PDF LibraryPython Cachetools ModulePython Cmdparser ModulePython Dash modulePython Emoji ModulePython Nmap ModulePython PyLab ModuleWorking with PDF files in PythonPDF Handling in PythonManipulating PDF using PythonList All Functions from a Python ModulePython list of DictionariesPython Shelve ModuleCreating Interactive PDF forms using PythonPython Newspaper ModuleHow to Connect Wi-Fi using PythonBest Python Libraries used for Ethical HackingWindows System Administration Management using PythonIndentation Error in PythonPython imaplib ModulePython lxml ModulePython MayaVi ModulePython os.listdir() methodPython Modules for AutomationData Visualization in Python using Bokeh LibraryHow to Plot glyphs over a Google Map by using Bokeh Library in PythonHow to Plot a Pie Chart using Bokeh Library in PythonHow to Read Contents of PDF using OCR in PythonGrammar and Spell Checker in PythonConverting HTML to PDF files using PythonReadlines in PythonHow to Plot Multiple Lines on a Graph Using Bokeh in Pythonbokeh.plotting.figure.circle_x() Function in Pythonbokeh.plotting.figure.diamond_cross() Function in PythonHow to Plot Rays on a Graph using Bokeh in PythonImage Steganography using PythonInconsistent use of tabs and spaces in indentationHow to Plot Multiple Plots using Bokeh in PythonHow to Make an Area Plot in Python using BokehPython ChemPy ModulePython memory-profiler ModulePython Phonenumbers ModulePython Platform ModuleTypeError string indices must be an integerTime Series Forecasting with Prophet in PythonPython Pexpect ModulePython Optparse Moduleint object is not iterable.Python Peewee LibrarySome Cryptocurrency Libraries for PythonBuilding a Blockchain using PythonHuffman Coding using PythonNested Dictionary in PythonCollections.UserString in PythonHow to Customize Legends with MatplotlibMatplotlib legend in subplotMorphological Operations in Image Processing in PythonRole of Python in Artificial IntelligencePython Instagramy ModulePython pprint ModulePython PrimePy ModuleAndroid Development using PythonPython fbchat libraryArtificial Intelligence in Cybersecurity: Pitting Algorithms vs AlgorithmsUnderstanding The Recognition Pattern of Artificial IntelligenceWhen and How to Leverage Lambda Architecture in Big DataWhy Should We Learn Python for Data ScienceHow to Change the “legend” Position in MatplotlibHow to Check if Element Exists in List in PythonHow to Check Spellings of Given Words using Enchant in PythonPython Program to Count the Number of Matching Characters in a Pair of StringPing Pong Game Using Turtle in PythonPython Function to Display CalendarPython Program for Calculating the Sum of Squares of First n Natural NumbersPython Program for How to Check if a Given Number is Fibonacci Number or Notrandint() Function in PythonVisualize Tiff File using Matplotlib and GDAL in Pythonrarfile module in PythonStemming Words using PythonPython Program for Word Guessing GameBlockchain in Healthcare: Innovations & OpportunitiesSnake Game in Python using Turtle ModuleHow to Find Armstrong Numbers between two given IntegersCelery Tutorial Using PythonRSME – Root Mean Square Error in PythonBuilding a Twitter Bot using PythonPython Progressbar ModulePython Pronouncing ModulePython PyAutoGUI ModulePython Pyperclip ModuleHow to Generate UUID in PythonPython Top 10 Libraries to Learn in 2022Reading NetCDF Data using PythonThe reprlib module in PythonHow to take Multiple Input from User in PythonPython zlib LibraryPython Queue ModulePython YAML ParserEffective Root Searching Algorithms in PythonPython Bz2 ModulePython IPaddress ModulePython PyLint ModuleHow to Process XML in PythonBisect Algorithm Functions in PythonCreating and Updating PowerPoint Presentation using PythonHow to change the size of figure drawn with matplotlibKeyboard Module in PythonPython Pyfiglet ModuleCreating an MCQ Quiz Game in PythonStatistic with PythonWhat is GIL in PythonBasic Python for Java DevelopersHow to Download YouTube Videos Using Python ScriptsTraffic Flow Simulation in PythonHow to Merge and Sort Two Lists in PythonMetacharacters in PythonWrite the Python Program to Print All Possible Combination of IntegersModulo String Formatting in PythonCounters in PythonPython pyautogui LibraryHow to Draw the Mandelbrot Set in PythonPython Dbm ModuleWebcam Motion Detector in PythonGraphQL Implementation in DjangoHow to Implement Protobuf in PythonPyQt library in PythonHow to Prettify Data Structures with Pretty Print in PythonEncrypt a Password in Python Using bcryptPyramid Framework in PythonBuilding a Telegram bot using PythonWeb2py Framework in PythonPython os.chdir() MethodBalancing Parentheses in PythonHow to Provide Multiple Constructors in Python ClassesProfiling the Python codeBuild a Dice-Rolling Application with PythonEmail module in PythonEssential Recursion Programs in PythonHow to Design Hashset in PythonHow to Extract YouTube Data in PythonHow to Solve Stock Span Problem Using PythonSelection Sort in Pythoninfo() Function in PythonTwo Sum Problem: Python Solution of Two sum problem of Given ListWrite a Python Program to Check a List Contains Duplicate ElementWrite Python Program to Search an Element in Sorted ArrayPathlib module in PythonCreate a Real Time Voice Translator using PythonHow to Sort Tuple in PythonAdvantages of Python that made it so Popular and its Major ApplicationsLibrary in PythonPackages of Data Visualization in PythonPython pympler librarySnakeViz library in PythonMaterialized View vs ViewNamespace in PythonPython Program to return the Sign of the product of an ArrayFabric Module in PythonTracemalloc module in PythonSplit, Sub, Subn functions of re module in pythonRobot Framework in PythonUnderstanding Robotics with PythonGzip module in Pythonguppy/heapy in PythonMicroservices in PythonFunctools Module in PythonPlotting Google Map using gmplot package in PythonMonitoring Devices using PythonWebbrowser module in PythonBinary Search using Recursion in PythonC vs C++ vs Python vs JavaHow to Check Version of PythonPython List ComprehensionConvert Roman Number to Decimal (Integer) | Write Python Program to Convert Roman to IntegerCreate REST API using Django REST Framework | Django REST Framework TutorialMemoization using Decorators in PythonPython for Network Engineering‘and’ vs ‘&’ in PythonCryptography package in PythonHangman Game in PythonImplementation of Linear Regression using PythonNested Decorators in PythonPython Program to Find Difference between Two StringsPython urllib LibraryFiona module in PythonFirebase module in pythonPython For KidsFloor Division in PythonTop 10 Best Coursera Python CoursesTop Python for Network Engineering LibrariesHow does Tokenizing Text, Sentence, Words WorksHow to Import Datasets using sklearn in PyBrainPart of Speech Tagging using TextBlobPython for Kids: Resources for Python Learning PathXGBoost ML Model in PythonSimple FLAMES game in PythonAlarm Clock with GUI in PythonRock Paper Scissors Game in PythonCheck if a Given Linked List is Circular Linked ListReverse the Linked List in PythonFlatten() vs Ravel() Numpy FunctionsLearning Vector QuantizationLemmatization and Tokenize with TextBlobHow to Round Numbers in PythonPrecedence and Associativity of Operators in PythonPython unofficial libraries12 Best Python Projects for Class 12Desktop Notifier in PythonHow to handle Time zones in PythonPython Secret ModuleMake Notepad using TkinterCamelcase in PythonDifference between Python and ScalaHow to Use Cbind in PythonPython AssertsPython Bitwise OperatorsPython Time asctime() MethodQ-Learning in PythonCombinatoric Iterators in PythonClass Method vs Static Method vs Instance MethodFree Python eBooksEight Amazing Ideas of Python Tkinter ProjectsCreating a Keylogger using PythonQuandl package in Python

Python Tkinter (GUI)

Python TkinterTkinter ButtonTkinter CanvasTkinter CheckbuttonTkinter EntryTkinter FrameTkinter LabelTkinter ListboxTkinter MenubuttonTkinter MenuTkinter MessageTkinter RadiobuttonTkinter ScaleTkinter ScrollbarTkinter TextTkinter ToplevelTkinter SpinboxTkinter PanedWindowTkinter LabelFrameTkinter MessageBox

Python Web Blocker

IntroductionBuilding Python ScriptScript Deployment on LinuxScript Deployment on Windows

Python MCQ

Python MCQPython MCQ Part 2

Related Tutorials

NumPy TutorialDjango TutorialFlask TutorialPandas TutorialPytorch TutorialPygame TutorialMatplotlib TutorialOpenCV TutorialOpenpyxl TutorialPython CGIPython Design Pattern

Python Programs

Python Programs


Next →Python TutorialPython tutorial provides basic and advanced concepts of Python. Our Python tutorial is designed for beginners and professionals.Python is a simple, general purpose, high level, and object-oriented programming language.Python is an interpreted scripting language also. Guido Van Rossum is known as the founder of Python programming.Our Python tutorial includes all topics of Python Programming such as installation, control statements, StringsListsTuplesDictionaryModulesExceptions, Date and Time, File I/O, Programs, etc. There are also given Python interview questions to help you better understand Python Programming. Python ProgrammingWhat is PythonPython is a general purpose, dynamic, high-level, and interpreted programming language. It supports Object Oriented programming approach to develop applications. It is simple and easy to learn and provides lots of high-level data structures.Python is easy to learn yet powerful and versatile scripting language, which makes it attractive for Application Development.Python’s syntax and dynamic typing with its interpreted nature make it an ideal language for scripting and rapid application development.Python supports multiple programming pattern, including object-oriented, imperative, and functional or procedural programming styles.Python is not intended to work in a particular area, such as web programming. That is why it is known as multipurpose programming language because it can be used with web, enterprise, 3D CAD, etc.We don’t need to use data types to declare variable because it is dynamically typed so we can write a=10 to assign an integer value in an integer variable.Python makes the development and debugging fast because there is no compilation step included in Python development, and edit-test-debug cycle is very fast.Python 2 vs. Python 3In most of the programming languages, whenever a new version releases, it supports the features and syntax of the existing version of the language, therefore, it is easier for the projects to switch in the newer version. However, in the case of Python, the two versions Python 2 and Python 3 are very much different from each other.A list of differences between Python 2 and Python 3 are given below:Python 2 uses print as a statement and used as print “something” to print some string on the console. On the other hand, Python 3 uses print as a function and used as print(“something”) to print something on the console.Python 2 uses the function raw_input() to accept the user’s input. It returns the string representing the value, which is typed by the user. To convert it into the integer, we need to use the int() function in Python. On the other hand, Python 3 uses input() function which automatically interpreted the type of input entered by the user. However, we can cast this value to any type by using primitive functions (int(), str(), etc.).In Python 2, the implicit string type is ASCII, whereas, in Python 3, the implicit string type is Unicode.Python 3 doesn’t contain the xrange() function of Python 2. The xrange() is the variant of range() function which returns a xrange object that works similar to Java iterator. The range() returns a list for example the function range(0,3) contains 0, 1, 2.There is also a small change made in Exception handling in Python 3. It defines a keyword as which is necessary to be used. We will discuss it in Exception handling section of Python programming tutorial.Python HistoryPython was invented by Guido van Rossum in 1991 at CWI in Netherland. The idea of Python programming language has taken from the ABC programming language or we can say that ABC is a predecessor of Python language.There is also a fact behind the choosing name Python. Guido van Rossum was a fan of the popular BBC comedy show of that time, “Monty Python’s Flying Circus”. So he decided to pick the name Python for his newly created programming language.Python has the vast community across the world and releases its version within the short period.Why learn Python?Python provides many useful features to the programmer. These features make it most popular and widely used language. We have listed below few-essential feature of Python.Easy to use and LearnExpressive LanguageInterpreted LanguageObject-Oriented LanguageOpen Source LanguageExtensibleLearn Standard LibraryGUI Programming SupportIntegratedEmbeddableDynamic Memory AllocationWide Range of Libraries and FrameworksWhere is Python used?Python is a general-purpose, popular programming language and it is used in almost every technical field. The various areas of Python use are given below.Data ScienceDate MiningDesktop ApplicationsConsole-based ApplicationsMobile ApplicationsSoftware DevelopmentArtificial IntelligenceWeb ApplicationsEnterprise Applications3D CAD ApplicationsMachine LearningComputer Vision or Image Processing Applications.Speech RecognitionsPython Basic SyntaxThere is no use of curly braces or semicolon in Python programming language. It is English-like language. But Python uses the indentation to define a block of code. Indentation is nothing but adding whitespace before the statement when it is needed. For example –def func():         statement 1         statement 2         …………………         …………………           statement N  In the above example, the statements that are same level to right belong to the function. Generally, we can use four whitespaces to define indentation.Python First ProgramUnlike the other programming languages, Python provides the facility to execute the code using few lines. For example – Suppose we want to print the “Hello World” program in Java; it will take three lines to print it.public class HelloWorld {   public static void main(String[] args){  // Prints “Hello, World” to the terminal window.    System.out.println(“Hello World”);   }   }  On the other hand, we can do this using one statement in Python.print(“Hello World”)  Both programs will print the same result, but it takes only one statement without using a semicolon or curly braces in Python.Python Popular Frameworks and LibrariesPython has wide range of libraries and frameworks widely used in various fields such as machine learning, artificial intelligence, web applications, etc. We define some popular frameworks and libraries of Python as follows.Web development (Server-side) – Django Flask, Pyramid, CherryPyGUIs based applications – Tk, PyGTK, PyQt, PyJs, etc.Machine Learning – TensorFlow, PyTorch, Scikit-learn, Matplotlib, Scipy, etc.Mathematics – Numpy, Pandas, etc.Python print() FunctionThe print() function displays the given object to the standard output device (screen) or to the text stream file.Unlike the other programming languages, Python print() function is most unique and versatile function.The syntax of print() function is given below.print(*objects, sep=’ ‘, end=’\n’, file=sys.stdout, flush=False)  Let’s explain its parameters one by one.objects – An object is nothing but a statement that to be printed. The * sign represents that there can be multiple statements.sep – The sep parameter separates the print values. Default values is ‘ ‘.end – The end is printed at last in the statement.file – It must be an object with a write(string) method.flush – The stream or file is forcibly flushed if it is true. By default, its value is false.Let’s understand the following example.Example – 1: Return a valueprint(“Welcome to javaTpoint.”)    a = 10  # Two objects are passed in print() function  print(“a =”, a)    b = a  # Three objects are passed in print function  print(‘a =’, a, ‘= b’)  Output:Welcome to javaTpoint. a = 10 a = 10 = b As we can see in the above output, the multiple objects can be printed in the single print() statement. We just need to use comma (,) to separate with each other.Example – 2: Using sep and end argumenta = 10  print(“a =”, a, sep=’dddd’, end=’\n\n\n’)  print(“a =”, a, sep=’0′, end=’$$$$$’)  Output:a =dddd10 a =010$$$$$ In the first print() statement, we use the sep and end arguments. The given object is printed just after the sep values. The value of end parameter printed at the last of given object. As we can see that, the second print() function printed the result after the three black lines.Taking Input to the UserPython provides the input() function which is used to take input from the user. Let’s understand the following example.Example –name = input(“Enter a name of student:”)  print(“The student name is: “, name)  Output:Enter a name of student: Devansh The student name is: Devansh By default, the input() function takes the string input but what if we want to take other data types as an input.If we want to take input as an integer number, we need to typecast the input() function into an integer.For example –Example –a  = int(input(“Enter first number: “))  b = int(input(“Enter second number: “))    print(a+b)  Output:Enter first number: 50 Enter second number: 100 150 We can take any type of values using input() function.Python OperatorsOperators are the symbols which perform various operations on Python objects. Python operators are the most essential to work with the Python data types. In addition, Python also provides identify membership and bitwise operators. We will learn all these operators with the suitable example in following tutorial.Python OperatorsPython Conditional StatementsConditional statements help us to execute a particular block for a particular condition. In this tutorial, we will learn how to use the conditional expression to execute a different block of statements. Python provides if and else keywords to set up logical conditions. The elif keyword is also used as conditional statement.Python if..else statementPython Loops we may need to alter the flow of the program. The execution of a specific code may need to be repeated several numbers of times. For this purpose, the programming languages provide various types of loops capable of repeating some specific code several times. Consider the following tutorial to understand the statements in detail.Python LoopsPython For LoopPython While LoopPython Data StructuresData structures are referred which can hold some data together or we say that they are used to store the data in organized way. Python provides built-in data structures such as list, tuple, dictionary, and set. We can perform complex tasks using data structures.Python ListPython list holds the ordered collection of items. We can store a sequence of items in a list. Python list is mutable which means it can be modified after its creation. The items of lists are enclosed within the square bracket [] and separated by the comma. Let’s see the example of list.L1 = [“John”, 102, “USA”]      L2 = [1, 2, 3, 4, 5, 6]     If we try to print the type of L1, L2, and L3 using type() function then it will come out to be a list.print(type(L1))    print(type(L2))    Output:<class ‘list’> <class ‘list’> To learn more about list, visit the following tutorial.Python ListPython List FunctionsPython TuplePython Tuple is used to store the sequence of immutable Python objects. The tuple is similar to lists since the value of the items stored in the list can be changed, whereas the tuple is immutable, and the value of the items stored in the tuple cannot be changed.Tuple can be defined as followsExample –tup = (“Apple”, “Mango” , “Orange” , “Banana”)  print(type(tup))  print(tup)  Output:<class ‘tuple’> (‘Apple’, ‘Mango’, ‘Orange’, ‘Banana’) If we try to add new to the tuple, it will throw an error. –tup = (“Apple”, “Mango” , “Orange” , “Banana”)    tup[2] = “Papaya”  print(tup)  Output:Traceback (most recent call last): File “C:/Users/DEVANSH SHARMA/PycharmProjects/Hello/”, line 3, in tup[2] = “Papaya” TypeError: ‘tuple’ object does not support item assignment The above program throws an error because tuples are immutable type. To learn more about tuple, visit the Python Tuples.Python TuplePython StringPython string is a sequence of characters. It is a collection of the characters surrounded by single quotes, double quotes, or triple quotes. It can also define as collection of the Unicode characters. We can create a string as follows.Example –# Creating string using double quotes  str1 = “Hi Python”  print(str1)  # Creating string using single quotes  str1 = ‘Hi Python’  print(str1)  # Creating string using triple quotes  str1 = ”’Hi Python”’  print(str1)  Output:Hi Python Hi Python Hi Python Python doesn’t support the character data-type. A single character written as ‘p’ is treated as a string of length 1.Stings are also immutable. We can’t change after it is declared. To learn more about the string, visit the following tutorial.Python StringsPython String MethodDictionariesPython Dictionary is a most efficient data structure and used to store the large amount of data. It stores the data in the key-value pair format. Each value is stored corresponding to its key.Keys must be a unique and value can be any type such as integer, list, tuple, etc.It is a mutable type; we can reassign after its creation. Below is the example of creating dictionary in Python.Example –employee = {“Name”: “John”, “Age”: 29, “salary”:250000,”Company”:”GOOGLE”}      print(type(employee))      print(“printing Employee data …. “)      print(employee)  Output:<class ‘dict’> Printing Employee data …. {‘Name’: ‘John’, ‘Age’: 29, ‘salary’: 250000, ‘Company’: ‘GOOGLE’} The empty curly braces {} are used to create empty dictionary. To learn more, visit the complete tutorial of the dictionary.Python DictionaryPython Dictionary MethodsPython SetsA Python set is a collection of unordered elements. Each element in set must be unique and immutable. Sets are mutable which means we can modify anytime throughout the program. Let’s understand the example of creating set in Python.Example –# Creating Set  Month = {“January”, “February”, “March”, “April”, “May”, “June”, “July”}  print(Month)  print(type(Month))  Output:{‘March’, ‘July’, ‘April’, ‘May’, ‘June’, ‘February’, ‘January’} <class ‘set’> To get the more information about sets, visit the following resources.Python SetsPython Set MethodsPython Functional ProgrammingThis section of Python tutorial defines some important tools related to functional programming such as lambda and recursive functions. These functions are very efficient in accomplishing the complex tasks. We define a few important functions, such as reduce, map, and filter. Python provides the functools module that includes various functional programming tools. Visit the following tutorial to learn more about functional programming.Python FunctionPython map() FunctionPython filter() FunctionPython reduce() FunctionPython functool ModulePython Lambda FunctionPython File I/OFiles are used to store data in a computer disk. In this tutorial, we explain the built-in file object of Python. We can open a file using Python script and perform various operations such as writing, reading, and appending. There are various ways of opening a file. We are explained with the relevant example. We will also learn to perform read/write operations on binary files.Python File I/OPython ModulesPython modules are the program files that contain a Python code or functions. There are two types of module in the Python – User-define modules and built-in modules. A module that the user defines, or we can say that our Python code saved with .py extension, is treated as a user-define module.Built-in modules are predefined modules of Python. To use the functionality of the modules, we need to import them into our current working program.Python ModulesPython ExceptionsAn exception can be defined as an unusual condition in a program resulting in the interruption in the flow of the program.Whenever an exception occurs, the program stops the execution, and thus the further code is not executed. Therefore, an exception is the run-time errors that are unable to handle to Python script. An exception is a Python object that represents an error.Python ExceptionsPython CSVA csv stands for “comma separated values”, which is defined as a simple file format that uses specific structuring to arrange tabular data. It stores tabular data such as spreadsheet or database in plain text and has a common format for data interchange. A csv file opens into the excel sheet, and the rows and columns data define the standard format. Visit the following tutorial to learn the CSV module in detail.Python Read CSV FilePython Write CSV FilePython Sending MailWe can send or read a mail using the Python script. Python’s standard library modules are useful for handling various protocols such as PoP3 and IMAP. We will learn how to send a mail with the popular email service SMTP from a Python script.Python Sending EmailsPython Magic MethodsPython magic method is defined as the special method which adds “magic” to a class. It starts and ends with double underscores, for example, _init_ or _str_.The built-in classes define many magic methods. The dir() function can be used to see the number of magic methods inherited by a class. It has two prefixes and suffix underscores in the method name.Python Magic MethodsPython Oops ConceptsEverything in Python is treated as an object including integer values, floats, functions, classes, and none. Apart from that, Python supports all oriented concepts. Below is the brief introduction of oops concepts of Python.Classes and Objects – Python classes are the blueprint of the object. An object is a collection of data and method that act on the data.Inheritance – An inheritance is a technique where one class inherits the properties of other classes.Constructor – Python provides a special method __init__() which is known as a constructor. This method is automatically called when an object is instantiated.Data Member – A variable that holds data associated with a class and its objects.To read the oops concept in detail, visit the following resources.Python Oops ConceptsPython Object and classesPython ConstructorPython InheritancePython PolymorphismPython Advance TopicsPython includes many advance and useful concepts that help the programmer to solve the complex tasks. These concepts are given below.Python IteratorAn iterator is simply an object that can be iterated upon. It returns one object at a time. It can be implemented using the two special methods, __iter__() and __next__().To learn more about the iterators visit our Python Iterators tutorial.Python GeneratorsThe Generators are an easiest way of creating Iterators. To learn more about, visit our Python Generators tutorial.Python DecoratorsThese are used to modify the behavior of the function. Decorators provide the flexibility to wrap another function to expand the working of wrapped function, without permanently modifying it.To learn more about, visit the Python Decorators tutorial.Python Database ConnectionsWe can use various databases along with Python. You can learn the full tutorial to visit below resources. Python DBI-API acclaims standard sets of functionality to be included in the database connectivity modules for respective RDBMS products. We explain all important database connectivity using Python DBI-API.Python MySQLEnvironment SetupDatabase ConnectionCreating New DatabaseCreating TablesInsert OperationRead OperationUpdate OperationJoin OperationPerforming TransactionsPython MongoDBPython MongoDBPython SQLitePython SQLitePython CGIPython CGI stands for “Common Gateway Interface”, which is used to define how to exchange information between the webserver and a custom Python scripts. The Common Gateway Interface is a standard for external gateway programs to interface with the server, such as HTTP Servers. To learn more about Python CGI, visit the following tutorial.Python CGIPrerequisiteBefore learning Python, you must have the basic knowledge of programming concepts.AudienceOur Python tutorial is designed to help beginners and professionals.ProblemWe assure that you will not find any problem in this Python tutorial. But if there is any mistake, please post the problem in contact form.Next TopicFeatures of Python

Next →

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share×280&!1&btvi=1&fsb=1&xpc=4sBxnazveK&p=https%3A//

Learn Latest Tutorials

SplunkSPSSSwaggerTransact-SQLTumblrReactJSRegexReinforcement LearningR ProgrammingRxJSReact NativePython Design PatternsPython PillowPython TurtleKeras


AptitudeReasoningVerbal AbilityInterview QuestionsCompany Questions

Trending Technologies

Artificial IntelligenceAWSSeleniumCloud ComputingHadoopReactJSData ScienceAngular 7BlockchainGitMachine LearningDevOps

B.Tech / MCA

DBMSData StructuresDAAOperating SystemComputer NetworkCompiler DesignComputer OrganizationDiscrete MathematicsEthical HackingComputer GraphicsSoftware EngineeringWeb TechnologyCyber SecurityAutomataC ProgrammingC++Java.NetPythonProgramsControl SystemData MiningData Warehouse
Author: [email protected]


Leave a Comment

Your email address will not be published. Required fields are marked *