fbpx

Activity 1

Activity: To print the value of pi

1. Open the PyCharm Editor installed on your system. An introductory screen will show up on your system.

2. Click on “Create New Project” for creating your first project and starting to code in Python.

3. Select the location where you wish the project is to be created. You can change the name to something meaningful such as  “NewProject”. Click on “Create”.

4. Next, go to the “File” menu and click on “New”. Click on the option “Python File”.

5. A pop-up window will appear where you can enter the filename.

6. Next, type the program. First, we are going to import the math library,
import math

7. The code would be as follows:

import math
print(math.pi)

8. Next, go to the “Run” menu and select “Run” for running the program. The shortcut for this is Alt+Shift+F10.

9. The output of the program will be displayed at the bottom of the screen. `

Output:
This code will generate the following output:
3.141592653589793

The math module is a standard module in Python and is always available. To use mathematical functions under this module, you have to import the module using import math.

Try to explore all the functions in math module.