Posts

Showing posts from 2019

Python Tutorial|Lambda Expression

* Lambda Expression * What is Lambda Expression? :-    In python we can define function in 2 ways 1. def  Keyword Using :-     This Type of Function De fination we  always Use In Python. This Function  Name We Define  Properly So it is Simple to Understand That.   def double(x): return x * 2 2. Lambda Keyword Using :-      In Python, anonymous function is a   function   that is defined without any name .    While normal functions are defined using the  def  keyword, in Python     anonymous functions are defined using the  lambda   keyword.   Hence, anonymous functions are also called lambda functions .    Syntax of Lambda Function in python lambda arguments: expression Why Lambda Function Is Better Than Instead def Function ? : - Just Because The Lambda Expression provide some benefit below as follow :- 1. We can pass Lambda Function As a argument to another function 2. We can Store function In variable 3. For Small Process Like Muti

python gui development | how to create python gui windows

Image
python gui development Python provides various options for developing graphical user interfaces (GUIs). Most important are listed below. Python GUI Tkinter  : − Tkinter is the Python interface to the Tk GUI toolkit shipped with Python. We would look this option in this chapter. wxpython python 3  : − This is an open-source Python interface for wxWindows . Jython :− Jython is a Python port for Java which gives Python scripts seamless access to Java class libraries on the local machine . There are many other interfaces available, which you can find them on the net. Python GUI Tkinter Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit. Creating a GUI application using Tkinter is an easy task. All you need to do is perform the following steps − Import the Tkinter module. Create the GUI application main wind

exception handling in python

Image
EXCEPTION HANDLING IN PYTHON A Python program terminates as soon as it encounters an error. In Python, an error can be a syntax error or an exception. In this article, you will see what an exception is and how it differs from a syntax error. After that, you will learn about raising exceptions and making assertions. Then, you’ll finish with a demonstration of the try and except block. Exceptions versus Syntax Errors Syntax errors occur when the parser detects an incorrect statement. Observe the following example: >>> print ( 0 / 0 )) File " <stdin> " , line 1 print ( 0 / 0 )) ^ SyntaxError : invalid syntax     The arrow indicates where the parser ran into the syntax error . In this example, there was one bracket too many. Remove it and run your code again: >>> print ( 0 / 0 ) Traceback (most recent call last): File " <stdin> " , line 1 , in <module> ZeroDivisionError : int

file handling in python

  python File handling System File Handling in Python Python too supports file handling and allows users to handle files i.e., to read and write files, along with many other file handling options, to operate on files. Working of open() function We use open () function in Python to open a file in read or write mode. As explained above, open() will return a file object. To return a file object we use open() function along with two arguments, that accepts file name and the mode, whether to read or write. So, the syntax being: open( filename, mode ) . There are three kinds of mode, that Python provides and how files can be opened: “ r “     :-   for reading. “ w “ :- for writing. “ a “    :-   for appending. “ r+ “ :- for both reading and writing One must keep in mind that the mode argument is not mandatory. If not passed, then Python will assume it to be “ r ” by default. Let’s look at this program and try to analyze how the re

ATM programming in python

Image
ATM LOGIN PROGRAMMING IN PYTHON today is a thursday so that i will provide you a code for bank application .... in every  thursday  i will do that . ATM LOGIN here is a code :- bank={" Abhishek123 ":1234," aditya 786":9000," vivek123 ":5678} username= input (" \n please enter the username : ") password= int(input (" \n please enter the pin : ")) if username in bank:     if bank[username]==password:         print("you are authorized")     else:         print (" wrong password enterd ") else:     print (" you are not authorized ")  OUTPUT:- when you enterded proper username and password next output when we enter the correct username but worng password next output when the both username and password is worng entered so this is our validation code for just check either the user is authorized or not. if you want this type