Showing posts with the label error logic

Featured Post

Python Program: JSON to CSV Conversion

JavaScript object notion is also called JSON file, it's data you can write to a CSV file. Here's a sample python logic for your ready reference.  You can write a simple python program by importing the JSON, and CSV packages. This is your first step. It is helpful to use all the JSON methods in your python logic. That means the required package is JSON. So far, so good. In the next step, I'll show you how to write a Python program. You'll also find each term explained. What is JSON File JSON is key value pair file. The popular use of JSON file is to transmit data between heterogeneous applications. Python supports JSON file. What is CSV File The CSV is comma separated file. It is popularly used to send and receive data. How to Write JSON file data to a CSV file Here the JSON data that has written to CSV file. It's simple method and you can use for CSV file conversion use. import csv, json json_string = '[{"value1": 1, "value2": 2,"value3

Python Function: How to Write Error Logic

Here's an example python user-defined function. Here, you'll know how to write error conditions. The best examples is if and else. I have shared the logic here for your reference. Python is one of the top programming languages. Python does support Functions . While writing functions you also need to consider some errors. Those are called exceptions. I am explaining how to give error logic in a function of Python. Exception-handling means to have logic for error scenarios. Writing exception I will show in a simple Function. In this post I will give you syntax for writing function and exception.  Here is my simple Function that multiplies two numbers. Logic to write Function in Python to Multiply Two Numbers  def product (num1,num2): prod=num1*num2 print( ' The product of the numbers is \t: '+str(prod) Parameters used the Python Function The 'def' means you are defining function with a name of 'product'. In the parameters of 'product', you can s