Let’s create our first Web application in python using pyWebIO library. I am creating a simple calculator that will accept two numbers as inputs and based on the selected operation (i.e., addition, subtraction, multiplication or division), it will display the output. Let’s create a new file, to our existing project. Right click on the projectContinue reading “First WebApp”
Tag Archives: python functions
Create First Project in Visual Studio
Open Visual studio and create a new Project. Search for Python in the templates. Select Python web project and click on “Next“. Then, click “Create“ This creates a new Python project and can be viewed under “Solution Explorer“. Let’s install a python library called Flask. Expand Python Environments, you should be able to see theContinue reading “Create First Project in Visual Studio”
Reduce
Reduce is a functionality that is introduced in Python that will take 2 elements at a time from either list or tuple and the result of that operation is again taken with next element in the list till we arrive at a solid answer and the list or tuple traversing is complete. Let’s understand thisContinue reading “Reduce”
Pickles
Pickles is one of the most important feature of Python. Pickle in Python is a representation of an object as a string of bytes. These bytes can be saved in a database, different file path or altogether into a different computer. Later, these bytes can be reassembled to form the original Python object which isContinue reading “Pickles”
Globbing
At times, whenever we are searching for files in our System or Laptop, we have used wild card patterns like *, ?, etc. For example, if I want to search files that starts with Hepsi, I will use pattern like Hepsi* which will list down all the files that start with Hepsi. Python provides aContinue reading “Globbing”
Exceptions
While we are trying to access files via python, if there are any issue, it will raise an IOError. There are many scenarios where we can get IOError. ❑ If we attempt to open for reading a file that does not exist, it will throw an IOError.❑ If we attempt to create a file inContinue reading “Exceptions”
Files and Directories again
Let’s continue writing to file that was created in the previous post. In the code snippet above, Line number 1: The file path is mentioned in the __file__ variable. Line number 3: This code represents how to open the file and write the file. Line number 5: Writing file with few more data. Line numberContinue reading “Files and Directories again”
Files and Directories
Python provides functions to write / read files and operations like reading contents from the directory. These functions play a trivial role as most of the programs involves reading files or directories. Let’s discuss few functions related to this. File Object – First step to read / write files in Python is using File object.Continue reading “Files and Directories”
Lambda Functions
Lambda functions are small and anonymous functions. Lambda function can take ‘n‘ number of arguments, but will have only one expression. To create a Lambda function in Python, we need use Lambda keyword. Let’s see with an example. If we assign a function to a variable, it becomes an anonymous function and thus a lambdaContinue reading “Lambda Functions”
Functions Again
ArgumentsConsider our previous function that was created that takes two parameters, num1 and num2. So, while calling the function we need to pass the same number of parameters i.e., if the function definition has two parameters, we need to pass two values, if the function definition has three parameters, we need to pass three values.Continue reading “Functions Again”