Part 9 | Python Programming | Creating, Importing, and Calling from Your own Module (updated)

Опубликовано: 26 Январь 2025
на канале: oOSylarTechOo
179
4

This is part 9 of a series of python coding I am having fun with and want to show others interested or stuck.

Code Example:
#Creating a custom module that you import later
#this helps to save time if use functions, lists, and other information often

#Create a function
def greeting(name):
print("Hello, " + name)

#You can also use lists
person1 = {
"name": "John",
"age": 36,
"country": "Norway"
}

#now save your file as whatever name you want to create your module

Code Example used in the Python Shell:

#import the module that you created
import mymodule as mmd

#Call on a function from within your imported Module
mmd.greeting("oOSylarOo")

#Call on a list from within your Module that pulls specific information

mmd.person1["name"]
mmd.person1["age"]
mmd.person1["country"]

#You can add as much stuff as you want to your module
#Have fun!!


#python #pythonprogramming #pythontutorial #pythonforbeginners #shorts

Music: Paid Subscription with Wondershare Filmora