Blog Details

img
Data Science

What are examples of Python

Spoke Right / 17 Nov, 2023

Writing python codes can be done in two ways.

  • Writing Python code in a text editor and saving it with a .py extension. These file can then be executed.
  • Writing Python code in a Python interactive shell. This method is useful for immediate testing of code with no stress of writing and saving the code in a file. This method is suitable only for testing purpose and for small codes.

Example 1: Printing Sum of two numbers in python using a text editor.

//pythonexample.py

a = 2000
b = 4000
print a+b

Output:

Example 2: Printing Sum of two numbers in python using a Python interactive shell.

0 comments

Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so (/usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0