30 Days of Python - Day 7 - Functions & Python Modules - Python TUTORIAL

preview_player
Показать описание
Day 7 - Functions & Python Modules

In 30 Days of Python, I'll teach you the fundamentals of Python. We created this series as an introduction to programming with Python.

Why Python? It's a very popular way to writing computer programs and automations with board applications: SpaceX & NASA use it to launch rockets, Tesla with autonomous driving, Instagram as a web app backend, Intel to pilot drones/UAVs, and many many others.

What you can do with Python is nearly endless:

Run powerful web applications
Fly drones and launch rockets
Run autonomous robots like drones and self-driving cars
Build connected systems with Arduino and Raspberry PI
Automate business intelligences and perform financial analysis
Machine learning including deep learning
And many more ways
That list is fancy but don't let it scare you. Python is just a tool for writing a series of step-by-step automation rules and that's exactly what software is: a collection of rules for a computer to follow.

The right tools in the right hands can impact the world in such amazing ways.

Shakespeare had very few tools for writing plays and yet he continues to influence our entertainment despite being long gone. Creativity mixed with the right tools can transform how we do everything or why we do it.

That's why I want to teach you this tool. The world needs your creatively, your perspective, your project.

Let's do this!

Рекомендации по теме
Комментарии
Автор

For windows if you're having issues:

- Open powershell and type ls or dir to list the folders in the current directory, by default you should probably be in your user directory (C:\users\username).
- Follow the video and navigate to where you saved YOUR python file with visual studio code by using cd followed by the folders name to enter that directory. For example I saved my python file in
- So I would type cd documents
- You are now in the documents folder, you can type dir or ls again to list all the folders in documents if you don't remember. Just keep going until you get into the folder where main.py is saved. So for me I can do: cd python, hit enter, then cd test, hit enter, and I am inside the folder where I saved main.py
- Once you cd into the folder where main.py is located for you, that's when you open up the python file.

IF you are using python 3.8 or higher (and possibly 3.7, I don't remember) do not type PYTHON -i main.py
Instead try py -i main.py and you should see the indicators in powershell change to >>> which means you are running the pyhon file.

Personally I think he chose a very confusing example with formatting and having variable/argument names being so similar, plus using the command line or powershell and jumping between vs code just to demonstrate functions. I'm sure he has his reason but I think it got overly complicated and confusing.

Seraphyx
Автор

For anyone using PowerShell on Windows and is confused, before you call the main.py file you need to be located in the right folder within powershell. Make sure you are out of python, and in powershell either type in "dir" to list the folders of where you are at currently, and then type in "cd" and the name of the folder you want, and then keep doing dir and then cd until you're in the right folder, or you can type in the folder path main.py is saved by using "set-location -path C:\Users\" and the folderpath. If there is any spaces in your folder names be sure to wrap " " around the folderpath

tobynash
Автор

Hi Justin I really like your videos and if you put videos consistently on YouTube you will become the famous youtuber who teaches programming

abdulsalamjamaeazidane
Автор

For Folks using power shell in windows, use the following commands.
Go to powershell
navigate to your directy/folder
type the following
python -i main.py
>>> format_msg


That will work!!!

josephfreysinger
Автор

How am i getting this so late. Best content out here. Thanks

Neil_
Автор

Really great videos Justin, thank you

SinanZen
Автор

hey I'm using a windows and Im getting this error when run it in powershell

>>> my_print("hello world")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'my_print' is not defined

shantanomiller
Автор

Awesome! Thanks for your efforts in making this informative Video!

salarghaffarian
Автор

hi sir I'm new here little bet comfusing, to follow next in day 8 because I cant find exact follow how you do it in day 7, beacuse your using mac laptop.Can you please give me clue to do the same in window..to locate main.py?what exact i need to do ..this method in my window is not responding % ls
% dev
please need help.hope to hear you soon thanks.

illuminateideas
Автор

I'm so loss in this episode @@ please send help

馮瀅湘
Автор

Is there a reason not to use Console in Visual Studio Code? (CTRL+`). It takes you right to the directory you are working in and no need to switch back and forth between (Terminal/Powershell/etc...) and VSC.

zeloguy
Автор

I can’t run what we did in visual studio on power shell because I couldn’t find main.py when I typed dir on my windows laptop.

greenbeanmanz
Автор

Hi, i'm using windows, and i can't open the directory on the powershell. what i mean is that i can't open the directory nor can i 'summon' the function from the VSC. How can i do this? i tried typing ' python -i main.py ' and it printed out ' [error 2] no such file or directory found '

alexlecharpantier
Автор

it show

>>> format_msg()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File 7\main.py", line 11, in format_msg
msg_template.format()
KeyError: 'name'


what have i done wrong?

angstan
Автор

Plz just do this again but on Windows it would really clear confusion. Idk if that’s too much to ask but it would make things easier for people coming into it for the first time. I was using this as a resource in my class but we all have Windows.

nope
Автор

at 17:50 i don't see how
def my_print(txt):
print(txt)


is a positional argument. Your example using
“{} {}”.format(“abc”, 123),

as a positional argument makes total sense.

yadude
Автор

Sorry one small remark: If you set an parameter like my_name equal to something (my_name='Justin') in the definition of a function you do not make it a "named parameter". It is still a positional one. You just give it a default value and therefore it becomes an optional argument in the function call (and then if you leave it out there all following arguments must be named). In a function call you can always use named arguments independent of the fact that there are default values given for each parameter of the function.

sebastianschweiger
Автор

Hello sir. I am not able to find the play button in vscode please help me out. Thanks

suryanshusaxena
Автор

I came here randomly. can you tell me why you used python3 -i filename instead of python3 filename in the terminal?

videet
Автор

I need it in windows to understand the change in directories
I have followed it correctly until now but stuck in day 7
Need help

nirmalaroyal