Programming Demo 2: Python Modules Demonstration 1. To create a module, open a new script, write the codes below, save it as mainmodule.py 1 def greeting (name): 2 print("Hello, " + name) 2. Create another script, write the codes below then insert your name inside the greeting() function. Save as sub1.py and explain the output. 1 import mainmodule 2 mainmodule.greeting(' ') 3. Add the code below in mainmodule.py. >>> person1 = { >>> >>> >>> } "name": "John", "age": 36, "country": "Norway" Page 2 Rewrite the code below for sub1.py and run the script. >>> import mainmodule as mm >>> a = mm. person1["age"] >>>print(a) What is the purpose of the as keyword after importing mainmodule?

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section: Chapter Questions
Problem 9PP
icon
Related questions
Question
Programming Demo 2: Python Modules Demonstration
1. To create a module, open a new script, write the codes below, save it as mainmodule.py
1 def greeting (name):
2
print("Hello,
+ name)
2. Create another script, write the codes below then insert your name inside the greeting() function.
Save as sub1.py and explain the output.
1
import mainmodule
2 mainmodule.greeting(' ')
3. Add the code below in mainmodule.py.
>>>
person1 = {
>>>
"name": "John",
"age": 36,
"country": "Norway"
>>> }
Page 2
Rewrite the code below for sub1.py and run the script.
import mainmodule as mm
>>> a = mm. person1["age"]
>>>print(a)
What is the purpose of the as keyword after importing mainmodule?
Transcribed Image Text:Programming Demo 2: Python Modules Demonstration 1. To create a module, open a new script, write the codes below, save it as mainmodule.py 1 def greeting (name): 2 print("Hello, + name) 2. Create another script, write the codes below then insert your name inside the greeting() function. Save as sub1.py and explain the output. 1 import mainmodule 2 mainmodule.greeting(' ') 3. Add the code below in mainmodule.py. >>> person1 = { >>> "name": "John", "age": 36, "country": "Norway" >>> } Page 2 Rewrite the code below for sub1.py and run the script. import mainmodule as mm >>> a = mm. person1["age"] >>>print(a) What is the purpose of the as keyword after importing mainmodule?
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT