Our First Python Program | Python Tutorial - Day #4

CodeWithHarry
1 Dec 202207:24

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

00:00

📝 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.

05:04

🔢 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

A Python program is a sequence of instructions written in the Python programming language, which is interpreted and executed by a Python interpreter. In the video, the presenter discusses creating a simple Python program from scratch, emphasizing the importance of understanding each line of code. The example program includes basic print statements, which output text to the screen, such as 'Hello World'.

💡Print Function

The 'print' function in Python is used to display output on the screen. It is one of the most commonly used functions in Python and is typically the first function beginners learn. In the video, the presenter explains how to use the 'print' function to display text like 'Hello World' and numbers. The function is also demonstrated with different data types and operations.

💡Syntax Error

A syntax error occurs when the code is not written according to the rules of the programming language, causing the program to fail when executed. The presenter encounters a syntax error by writing 'print(Hello World)' without enclosing the text in quotes, which the Python interpreter doesn't recognize as valid syntax. This error is used as a teaching moment to explain the importance of proper syntax.

💡String

In programming, a string is a sequence of characters enclosed in quotes. Strings are used to represent text in Python. The video explains that when using the 'print' function, text like 'Hello World' must be enclosed in quotes to be recognized as a string by Python. Without the quotes, Python will produce a syntax error, as seen in the example.

💡Script

A script is a file containing a sequence of Python commands that can be executed together. Unlike entering commands one by one in a terminal, a script allows for the automation of tasks by running multiple lines of code in sequence. The presenter introduces the concept of a script through the file 'main.py', where the code is written and executed line by line, producing outputs like 'Hello World', '5', and 'Bye'.

💡REPL

REPL stands for 'Read, Evaluate, Print, Loop' and is an interactive programming environment that takes user inputs, evaluates them, and returns the result. In the video, the presenter explains how Python can be used in a REPL environment, where commands are entered and executed one by one. This interactive environment is useful for testing small snippets of code and understanding how Python works.

💡Function

A function in Python is a block of reusable code that performs a specific task. The video explains that the 'print' function is an example of a built-in Python function used to display output. Functions are invoked by their name followed by parentheses, and they can take arguments to customize their behavior. Understanding functions is crucial as they are fundamental building blocks in programming.

💡Computation

Computation refers to performing mathematical operations using code. The video demonstrates how Python can be used to perform basic arithmetic operations like addition, subtraction, multiplication, and division within the 'print' function. For example, the presenter calculates the total cost of buying okra by multiplying the price per kilogram with the quantity, showing how Python can handle numerical calculations.

💡Consistency

Consistency refers to the importance of regular practice and dedication, especially in learning to code. The presenter emphasizes that the 100 Days Of Code challenge requires participants to code daily, as consistency is key to mastering programming. The message is clear that success in coding comes from steady, sustained effort rather than quick shortcuts.

💡100 Days Of Code

The 100 Days Of Code challenge is a commitment to code every day for 100 days to build and reinforce programming skills. In the video, the presenter is following this challenge, guiding viewers through writing Python code daily. The challenge aims to instill discipline and gradual improvement in coding abilities, with the end goal of gaining substantial programming experience.

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

play00:00

Welcome back to 100 Days Of Code guys

play00:03

In today's video we'll write our Python program

play00:06

I'd rather say our very own first Python program

play00:09

Because this Python program is going to be in which we'll write every line with understanding

play00:13

We'll have full understanding about our Python program

play00:17

And we'll write this code from scratch

play00:19

In upcoming videos we'll write quite mind-blowing Python programs from scratch

play00:23

But this is going to be our first program

play00:25

Let's move to the computer screen. And let's get started.

play00:28

[STARTING THEME]

play00:37

So I've opened my day #4 Repl

play00:40

And today we're going to write our first Python program

play00:42

But pal, we already had written our first python program

play00:45

In fact we wrote a lot of programs

play00:47

But this program is going to be one, which I'll write from scratch character-by-character & word-by-word

play00:53

So there's another feeling writing this

play00:55

So what you first have to do is....

play00:56

You've to write "print"

play00:57

Now let me tell you what does 'Print' in Python means

play01:01

'Print' is a function

play01:02

Now what is function? Function is used to perform any task

play01:06

'Print' is function. And to invoke any function we use parenthesis() like this

play01:13

As you can see I've opened a parenthesis after writing "print"

play01:20

And then I can close it in this manner

play01:22

And whatever I'll write in between will be printed

play01:25

Let's suppose if I write " 7 " here

play01:26

So " 7 " will be printed

play01:28

But do you know what we'll do?

play01:30

We'll write "Hello World"

play01:31

May be you're already familiar with "Hello World"

play01:33

Whenever someone write code in Python or any other programming language

play01:38

So the very first program that we write is "Hello World"

play01:41

Now look as I wrote "print(Hello World)" so a red line has appeared here

play01:45

Now what's this man! "invalid syntax"

play01:47

Now let's try to run this

play01:49

"Man! We started with an error"

play01:51

Yes! we started with an error

play01:53

Because we'll rise when we'll fall

play01:55

So look I've written "print(Hello World)

play01:57

And I got an error

play01:59

Do you know why this occurred?

play02:00

In python when you use 'Print' function so you've to add a valid object

play02:06

"(Hello World)" is not a valid object for Python

play02:09

Pythons says I don't know what "(Hello World)" is

play02:12

Yes! If you enclose this in a Double-quote(" ")

play02:15

So Python programming knows that you're now talking about a 'String'

play02:18

And "("Hello World")" is a string

play02:20

Let's try to run this & we've written our first Python program

play02:23

And we're able to see the "Hello World"

play02:25

Are you all eyes? We are able to see "hello World"

play02:28

Give a big round of applause and write "Congratulations" in comments for you and for me

play02:31

This is the first program we wrote character-by-character

play02:35

Great!

play02:36

So far so good

play02:38

If I write "Print" here and then if I write "5" and then if I run this

play02:42

So at first I'll got "Hello World"

play02:45

And then I'll got "5"

play02:47

We used Python in terminal

play02:49

And we learned that when we write "python3" in terminal

play02:53

And then if...

play02:55

...I write "print("Hello World")" So I've to write manually line-by-line

play03:00

I've to type everything here manually one-by-one

play03:04

Can you see I first typed "Hello World"

play03:06

And then I typed "print("5")"

play03:09

So will I type everything one-by-one?

play03:12

No! There's no need for me to write them one-by-one

play03:14

I can create a script. That's why I created this script "main.py"

play03:18

Script means our code will be executed line-by-line

play03:22

If I've written "Hello World" first so it'll be printed first

play03:24

And then "print("5")" will be executed

play03:27

And as I'll write "print("Bye")" here

play03:32

And then if I run it

play03:34

So I'll first get "Hello World" then "5" and then "Bye"

play03:37

So this script is executing code line by line

play03:40

Now how "print" has been written, we don't need to go to its implementation

play03:43

Now if you want to know for what else "print" is used

play03:47

So look Replit is displaying...

play03:49

As I hovered my cursor here so it is asking for the values

play03:53

It'll be an object

play03:54

You can give multiple values by adding comma(,)

play03:57

As I wrote "Hello World , 7" so "Hello World 7" has been printed"

play04:02

And then the rest of the two statements executed

play04:05

And line-by-line our script will be executed

play04:08

Can we only perform 'Print' function with the help of Python Programming Language?

play04:12

No man! That's not the only thing. We can do a lot of other stuff

play04:15

And this is the quality of this course that it'll tell what will we do

play04:20

Because we are just starting and this is our first Python Program

play04:22

We are just understanding things What are 'Scripts'

play04:24

And when we execute a command line-by-line

play04:29

And when we give any command to Python interpreter in Repl

play04:33

This is called 'Repl' When we write "python3" here

play04:35

"Python3" this is called Repl Read, Evaluate, Print, Loop

play04:39

When I'll command it "8+9" so "17" will appear

play04:43

But then I've to write something again and I'll get it's output

play04:47

I'll get the output as I keep on writing commands

play04:49

Ideally we don't wanna do this

play04:51

Ideally we want Python to process the sequence of instruction

play04:56

We want to tell Python to do anything we want

play04:59

Execute this one first and then this one and then this one

play05:03

And let's suppose I bought Okra for ₹10/Kg

play05:08

Or I bought 5Kg

play05:09

Or let's suppose I bought it ₹17/Kg

play05:13

And I bought 13Kg

play05:14

So I'll tell Python that I bought Okra for ₹17/Kg

play05:17

And I bought 13Kg

play05:21

So what's the total? And it'll tell you

play05:23

So you can do operations like this in print function

play05:26

For multiplication you've to use star(*) don't use (X) even by mistake

play05:29

And for divide you've to use slash(/)

play05:33

And (+) (-) these are simple give them a try

play05:37

But look the total is ₹221 and I've to give it to the seller

play05:42

So Python can also do computations like this

play05:45

In the upcoming videos we're going to learn some more things

play05:47

Just be with me in this course

play05:49

And I want to tell you for whom this course is not suitable

play05:52

If you guys can't stay consistent daily

play05:54

Or you want to do things in a shortcut manner

play05:56

So this course is not for you

play05:58

Because this course requires consistency

play06:00

It demands you to practice things as you keep on watching the videos

play06:04

And invest your precious time to complete this 100 Days Of Code challenge

play06:09

You've to reach the 100th day

play06:11

Mark your attendance in the comment section with "I'm present". I'll keep my eyes on everyone

play06:15

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

play06:21

Because it demands practice

play06:23

There's no elevator for the success you've to take the stairs

play06:27

And these are those stairs

play06:29

And you've to climb these stairs for 100 days with me

play06:32

And trust me it'll be worth it at the end

play06:35

I'll tell you those things from my years of experience which took quite long for me to learn

play06:40

And from the upcoming videos we'll start coding

play06:43

We'll write a lot of codes over the next few videos

play06:46

And in fact over the next a lot of videos

play06:49

Because we are going to follow this challenge for 100 days

play06:51

That's it for today's video guys

play06:53

And if you haven't access the play-list

play06:55

So make sure to access it, bookmark it & save it

play06:58

That's it for today's video guys

play07:00

Thank you so much guys for watching this video :)

play07:02

And I'll see you next time

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
Python ProgrammingCoding Challenge100 DaysBeginner GuideScript WritingHello WorldPrint FunctionRepl TutorialDaily PracticeConsistency
Benötigen Sie eine Zusammenfassung auf Englisch?