Our First Python Program | Python Tutorial - Day #4
Summary
TLDRIn this '100 Days Of Code' video, the host guides viewers through writing their first Python program from scratch, emphasizing understanding every line of code. They start with the classic 'Hello World' example, explaining the 'print' function and its syntax. The host also touches on the use of Python for simple computations and the importance of consistency and practice throughout the 100-day challenge, encouraging viewers to engage and learn through daily coding.
Takeaways
- 📝 The video is part of a '100 Days Of Code' challenge, focusing on writing Python programs with a deep understanding of each line of code.
- 💻 The presenter opens a Repl to demonstrate writing the first Python program from scratch, emphasizing the learning process.
- 🔡 The 'print' function in Python is introduced as a way to output text or values to the console, with an explanation of its syntax and usage.
- 🔴 The video shows an example of a common beginner error with the 'print' function and how to correct it by using double quotes for strings.
- 👋 The traditional 'Hello World' program is written and executed, marking the completion of the first program in the series.
- 🎉 The audience is encouraged to celebrate their first coding achievement and to leave a comment acknowledging their progress.
- 🔢 The 'print' function is further demonstrated with the ability to print multiple values and perform basic arithmetic operations.
- 📑 The concept of a 'script' is explained, showing how a Python file can execute multiple lines of code in sequence.
- 🛠 The video touches on the broader capabilities of Python beyond just printing, such as performing calculations and operations.
- 📚 The course is described as不适合 those who are not willing to commit to daily practice and consistency over the 100-day challenge.
- 🚀 The presenter motivates the audience by emphasizing the importance of climbing the 'stairs' of learning through consistent practice and effort.
Q & A
What is the main purpose of the video?
-The main purpose of the video is to guide viewers through writing their first Python program with a full understanding of each line of code, starting from scratch.
What does the instructor emphasize about writing the first Python program?
-The instructor emphasizes the importance of understanding each line of code and writing the program character-by-character and word-by-word for a deeper comprehension.
What is the first function introduced in the video?
-The first function introduced in the video is the 'print' function, which is used to display output in Python.
Why did the instructor initially get a syntax error when using the 'print' function?
-The instructor initially got a syntax error because 'Hello World' was not enclosed in double quotes, which Python requires for string literals.
What is the significance of 'Hello World' in programming?
-The 'Hello World' program is a traditional first program that programmers write when learning a new language, as it demonstrates the basic syntax and output functionality.
How does the instructor explain the concept of a script in Python?
-The instructor explains that a script in Python is a sequence of instructions that are executed line by line, allowing for the automation of tasks and the execution of multiple commands in order.
What is the purpose of the Replit mentioned in the video?
-Replit is an online integrated development environment (IDE) used by the instructor to demonstrate writing and running Python code, providing real-time feedback and error highlighting.
What does the instructor mean by 'Repl' in the context of Python?
-In the context of Python, 'Repl' stands for 'Read, Evaluate, Print, Loop', which is a type of interactive Python shell where users can input commands and receive immediate results.
How does the instructor demonstrate the capability of Python for basic computations?
-The instructor demonstrates Python's capability for basic computations by showing how to calculate the total cost of buying Okra at a given price per kilogram, using the 'print' function along with arithmetic operators.
What is the commitment required from the viewers according to the instructor?
-The instructor requires viewers to commit to consistency and daily practice throughout the 100 Days Of Code challenge, emphasizing that success in learning Python comes with dedication and time investment.
How does the instructor encourage viewers to engage with the course content?
-The instructor encourages viewers to mark their attendance in the comment section with 'I'm present', to bookmark and save the playlist, and to stay consistent with daily practice and learning.
Outlines
📝 Introduction to the First Python Program
The speaker begins by welcoming viewers back to the '100 Days Of Code' series, expressing excitement for writing the first Python program with full understanding. The video is set to start with writing a program from scratch, character-by-character, and word-by-word. The speaker mentions that they have previously written Python programs but emphasizes the importance of this particular program for its educational value. The script opens with the speaker opening their Repl and discussing the process of writing the program, starting with the 'print' function. The 'print' function is explained as a means to output text or values to the console, with an example of printing 'Hello World'. The speaker humorously points out a common beginner's mistake of not enclosing the string in quotes, which leads to a syntax error. After correcting the error, the program successfully prints 'Hello World', marking the completion of the first program. The speaker encourages viewers to celebrate this achievement and to write 'Congratulations' in the comments.
🔢 Exploring Python's Capabilities Beyond Printing
The second paragraph delves into Python's computational capabilities, using a practical example of calculating the total cost of buying Okra at a certain price per kilogram. The speaker explains how to perform basic arithmetic operations within the 'print' function, emphasizing the correct use of multiplication (*) and division (/) operators. The example provided calculates the total cost of 13Kg of Okra at ₹17 per Kg, resulting in a total of ₹221. The speaker then transitions to discussing the course's requirements, stressing the importance of consistency and daily practice for success in the '100 Days Of Code' challenge. The video concludes with a call to action for viewers to mark their attendance in the comments and to commit to the challenge. The speaker also shares a personal note on the value of the course, offering insights from their own experience and promising to guide viewers through the process of learning Python over the next 100 days.
Mindmap
Keywords
💡Python Program
💡Print Function
💡Syntax Error
💡String
💡Script
💡REPL
💡Function
💡Computation
💡Consistency
💡100 Days Of Code
Highlights
Introduction to writing the first Python program with full understanding.
Explanation of writing code from scratch and the upcoming series of mind-blowing Python programs.
Opening the Repl to begin writing the first Python program.
Clarification of the 'print' function in Python and its usage with parenthesis.
Understanding the concept of a function in programming.
The importance of using double-quotes for strings in Python.
Demonstration of running the first Python program with 'Hello World'.
Encouragement and celebration of writing the first program.
Explanation of how to use the 'print' function with multiple values.
Introduction to creating and executing a Python script.
Description of how scripts execute code line by line.
The concept of Repl (Read, Evaluate, Print, Loop) and its use in Python.
Demonstration of basic arithmetic operations using the 'print' function.
The course's requirement for consistency and daily practice.
Emphasis on the importance of completing the 100 Days Of Code challenge.
The不适合ness of the course for those seeking shortcuts or unable to commit to daily practice.
Invitation to mark attendance in the comment section with 'I'm present'.
Closing remarks and a reminder to access the play-list for the course.
Transcripts
Welcome back to 100 Days Of Code guys
In today's video we'll write our Python program
I'd rather say our very own first Python program
Because this Python program is going to be in which we'll write every line with understanding
We'll have full understanding about our Python program
And we'll write this code from scratch
In upcoming videos we'll write quite mind-blowing Python programs from scratch
But this is going to be our first program
Let's move to the computer screen. And let's get started.
[STARTING THEME]
So I've opened my day #4 Repl
And today we're going to write our first Python program
But pal, we already had written our first python program
In fact we wrote a lot of programs
But this program is going to be one, which I'll write from scratch character-by-character & word-by-word
So there's another feeling writing this
So what you first have to do is....
You've to write "print"
Now let me tell you what does 'Print' in Python means
'Print' is a function
Now what is function? Function is used to perform any task
'Print' is function. And to invoke any function we use parenthesis() like this
As you can see I've opened a parenthesis after writing "print"
And then I can close it in this manner
And whatever I'll write in between will be printed
Let's suppose if I write " 7 " here
So " 7 " will be printed
But do you know what we'll do?
We'll write "Hello World"
May be you're already familiar with "Hello World"
Whenever someone write code in Python or any other programming language
So the very first program that we write is "Hello World"
Now look as I wrote "print(Hello World)" so a red line has appeared here
Now what's this man! "invalid syntax"
Now let's try to run this
"Man! We started with an error"
Yes! we started with an error
Because we'll rise when we'll fall
So look I've written "print(Hello World)
And I got an error
Do you know why this occurred?
In python when you use 'Print' function so you've to add a valid object
"(Hello World)" is not a valid object for Python
Pythons says I don't know what "(Hello World)" is
Yes! If you enclose this in a Double-quote(" ")
So Python programming knows that you're now talking about a 'String'
And "("Hello World")" is a string
Let's try to run this & we've written our first Python program
And we're able to see the "Hello World"
Are you all eyes? We are able to see "hello World"
Give a big round of applause and write "Congratulations" in comments for you and for me
This is the first program we wrote character-by-character
Great!
So far so good
If I write "Print" here and then if I write "5" and then if I run this
So at first I'll got "Hello World"
And then I'll got "5"
We used Python in terminal
And we learned that when we write "python3" in terminal
And then if...
...I write "print("Hello World")" So I've to write manually line-by-line
I've to type everything here manually one-by-one
Can you see I first typed "Hello World"
And then I typed "print("5")"
So will I type everything one-by-one?
No! There's no need for me to write them one-by-one
I can create a script. That's why I created this script "main.py"
Script means our code will be executed line-by-line
If I've written "Hello World" first so it'll be printed first
And then "print("5")" will be executed
And as I'll write "print("Bye")" here
And then if I run it
So I'll first get "Hello World" then "5" and then "Bye"
So this script is executing code line by line
Now how "print" has been written, we don't need to go to its implementation
Now if you want to know for what else "print" is used
So look Replit is displaying...
As I hovered my cursor here so it is asking for the values
It'll be an object
You can give multiple values by adding comma(,)
As I wrote "Hello World , 7" so "Hello World 7" has been printed"
And then the rest of the two statements executed
And line-by-line our script will be executed
Can we only perform 'Print' function with the help of Python Programming Language?
No man! That's not the only thing. We can do a lot of other stuff
And this is the quality of this course that it'll tell what will we do
Because we are just starting and this is our first Python Program
We are just understanding things What are 'Scripts'
And when we execute a command line-by-line
And when we give any command to Python interpreter in Repl
This is called 'Repl' When we write "python3" here
"Python3" this is called Repl Read, Evaluate, Print, Loop
When I'll command it "8+9" so "17" will appear
But then I've to write something again and I'll get it's output
I'll get the output as I keep on writing commands
Ideally we don't wanna do this
Ideally we want Python to process the sequence of instruction
We want to tell Python to do anything we want
Execute this one first and then this one and then this one
And let's suppose I bought Okra for ₹10/Kg
Or I bought 5Kg
Or let's suppose I bought it ₹17/Kg
And I bought 13Kg
So I'll tell Python that I bought Okra for ₹17/Kg
And I bought 13Kg
So what's the total? And it'll tell you
So you can do operations like this in print function
For multiplication you've to use star(*) don't use (X) even by mistake
And for divide you've to use slash(/)
And (+) (-) these are simple give them a try
But look the total is ₹221 and I've to give it to the seller
So Python can also do computations like this
In the upcoming videos we're going to learn some more things
Just be with me in this course
And I want to tell you for whom this course is not suitable
If you guys can't stay consistent daily
Or you want to do things in a shortcut manner
So this course is not for you
Because this course requires consistency
It demands you to practice things as you keep on watching the videos
And invest your precious time to complete this 100 Days Of Code challenge
You've to reach the 100th day
Mark your attendance in the comment section with "I'm present". I'll keep my eyes on everyone
And if you want to learn this course in a short amount of time and without any practice, so this course is not for you
Because it demands practice
There's no elevator for the success you've to take the stairs
And these are those stairs
And you've to climb these stairs for 100 days with me
And trust me it'll be worth it at the end
I'll tell you those things from my years of experience which took quite long for me to learn
And from the upcoming videos we'll start coding
We'll write a lot of codes over the next few videos
And in fact over the next a lot of videos
Because we are going to follow this challenge for 100 days
That's it for today's video guys
And if you haven't access the play-list
So make sure to access it, bookmark it & save it
That's it for today's video guys
Thank you so much guys for watching this video :)
And I'll see you next time
تصفح المزيد من مقاطع الفيديو ذات الصلة
Writing First Python Program | Printing to Console in Python | Python Tutorials for Beginners #lec4
you need to learn Python RIGHT NOW!! // EP 1
Python inner working
How To Install C Programming Software In Laptop | C Installation Tutorial For Beginners |Simplilearn
CS50P - Lecture 3 - Exceptions
Promise me this - 100/day w/ AI vid 2
5.0 / 5 (0 votes)