Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Python-Modules-Coding-Exercises

Part 1: Creating and Using a Module

  • Create a file named mymath.py containing:
  • A function add(a, b) → returns the sum of two numbers.
  • A function sub(a, b) → returns the difference of two numbers.
  • A variable PI = 3.14.

In another file calculator.py:

Write a program called that imports sub as s and add from mymath.py.

It should ask the user to choose an operation (add or sub) and enter two numbers, then print the result.

Choose operation (add/sub): add
Enter first number: 7
Enter second number: 5
Result = 12

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors