Skip to main content

Core Python Crash Course (Modules)

As I mentioned before those crash courses are not for ultimate beginners. If it is your first time to code I don't support reading this Topic. If you are a programming Fan, you would Like it.

It is a crash course of a course on Udemy. In this topic, we will discuss:

1. Modules:

Modular Programming means breaking a large programming task into separate, smaller modules.
Advantages of Modules: 1) simple: It doesn't focus on the whole problem but a specific part of it. This makes development easier and less error-prone.
2) Maintainability: It focuses on a specific domain and minimizes the interdependency of those modules.
3) Reusability 4) Scoping: For each its namespace.

Functions, modules, and packages are all constructs in Python that promote code modularization.
There are 3 types of Python modules ( Written in Python itself, Written in C and loaded at runtime, built-in modules)

We focus now on The built-in modules:
This is how to call a module.

1. import (module name).
2. s and foo are in the module (private symbols) They are like functions.


The built-in function dir() returns a list of defined names in a namespace. Without arguments, it produces an alphabetically sorted list of names in the current local symbol table

import mod
>>> dir(mod)

Different ways to call a module: 

import (module name)  as (abbreviation)
(abbreviation).(Private symbol) OR  from (module name) import*

Comments

Popular posts from this blog

Miserable

 This one word could describe my life right now. I am writing this because of the last book I read talking about how to re-organize your life. 32 days ago, my dad has gone. In the beginning, I couldn't cry. Now, I can't stop crying about everything. Everything reminds me of him. His favorite stuff became my nightmare. I dream of him every day, too. One week from his death, I took my exams. I didn't remember how I did in them. I knew they were not how I supposed to do, but I am not aware of how I did. I wish I could have cried when he passed. I wanted to cry a lot but I didn't have the ability to face myself with the fact of his death.  He died between my shoulders. I just saw his color turned to yellow like how my grandpa seemed before death. I heard my brother told him some prayers that a person says before death and I just shouted at him to stop. I spent time squeezing his feet to make him shocked. I even talked to him, I said don't go, don't leave me, not now...

Inputs and Outputs in Python 3

Recently, I was training on some libraries in Python 3 and I noticed that the most difficult was not the questions, but the way you are going to take your input and present your output.  So, I'd like to show some ways I've learned and it may help you, too.  1. Lists:  Taking separated input like:  2 3 4 5 6 7 and put them into the list can be done by map function:  a = list (map(int, input().split())) or  a = tuple(map(int, input().split())) same if inputs are float - I will say that you don't need to do the same if the inputs were string! because the string is easily added into a list like:  a = input().split() < it put them directly into a list>  ___________________________ If you'll take 2 separated numbers and you are going to use just one of them, so:  you may use one of those ways:  n, m = list(map(int, input().split()) ) and use them by their names n, m, and so on.  or you can use:  p = input().split() them if yo...

Mirrors! (Short Story)

April 24, 2017, In one of Koma's streets, a bunch of people found a killed man, about 40 years old. The man had silver hair color, with a black suit and a bullet in his head. he had no ID and no one has recognized him. Koma's people called the police to come quickly and start an investigation. The unknown man looks rich.   Date of the murder: April 23, 2017. March 1996. A smart young man is waiting in the hostel/dorm rooms of Cambridge University. The   guy is nervously biting his nails until there is a warning voice calling his name: -Mr. Walter? -Mr. Walter? = Yes, Madam. -Mr. Jacob is waiting for you in the office. = Thank you, Madam. Good afternoon Mr. Jacob I'm Walter Dorn. - Take a seat, Mr. Walter. ( Jacob start to read through Walter's Resume) - Well, you are such the genius ! (Walter smiled at him) -Okay, Mr. Walter. According to your GPA and social awareness which look perfect, we are honored to give you our scholarship to be a ...