Unit 6 - Lesson 7

63.1.1. Importing a module

# using import statement, import CheckNegative
import CheckNegative
# take an interger as input from the user
i = int(input("x: "))
# Call the method from checkNegative module
CheckNegative.CheckNegativeNumber(i)

63.1.2. Writing a program using import

# write your code here
import Module_Imp2
a = int(input("a: "))
b = int(input("b: "))
Module_Imp2.arithoperations(a,b)

63.1.3. import using 'as' keyword

# Importing Module_Imp2 as 'mi' (using 'as' keyword)
import Module_Imp2 as mi

# take two user inputs
a = int(input("a: "))
b = int(input("b: "))
# Call the 'arithoperations' function from imported module 'mi'
mi.arithoperations(a,b)

63.1.4. Writing a program using 'as' in import.

# write your code here
import Module_Imp1 as mi1
import Module_Imp2 as mi2

num1 = int(input("num1: "))
num2 = int(input("num2: "))
mi1.checkNegativeNumber(num1)
mi1.checkNegativeNumber(num2)
mi2.arithoperations(num1,num2)

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.