Course Content

  • Basic Syntax

Course Content

basic syntax of python

Hello guys, welcome to Learnvern.

In the last topic we saw installation & Setup, Python, IDE.

Today we are going to see how Python's Basic Syntaxes work.

Under Basic Syntaxes, I’ll first explain Basic Functions to you.

For instance, the Print function.

If you want to print any value in Python, you will use the Print function.

Suppose you took a variable & you want to print its value, then you can use the Print function.

Now I want to check the type of its variable…

How to check the type? Type function is used to check the type.

Which function? Type function.

Suppose you want input from the user, you have an input function for that.

Which function? Input function.

Now I’ll tell you how to work with basic functions.

But before that, if you want to make your Python’s code a little bit easier to read and you want to represent your coding in a neat way, you have to use comments.

What do you have to use? Comments.

Comments will show about the particular code you’ve written is exactly for what.

So if anyone else is working on your code, they can easily interact with your code.

The comments are represented in Python with a # hash. Okay?

There are 2 types of comments.

1st is Single Line comments. Single Line comments and Multiline comments.

These are the 2 types of comments in Python.

Now the question is, how to use them?

Let’s see with practicals…

I will show you all the basic practical functions, I’ll also show you how to apply comments.

Let’s go to Jupyter. We will make a Python file & name it Basic Syntax.

Now the first & foremost thing, how to use our Basic Functions.

To use our Basic Functions, first of all, we’ll have to use the Print function.

I have to explain that I’ve used the print function so I’ll write a comment.

The comment we write should start with # hash.

With what? # Hash.

I’ll write a comment “using print function”.

How do we use the Print function?

I’ve given Print here. You can see it turned Green.

Green denotes Python’s pre-defined function. What is it?

It is Python’s pre-defined function.

Pre-defined function is used to print your values.

You can print anything you want by using…

So let’s see how we will use the Print function..

Suppose I want to print this Hello World.

All you have to do is simply type Hello World under the Print function.

And when you click on Run, the Print function will print it here below.

So this Print function will basically be used all over in Python.

In most of the videos we are going to see ahead, the Print function will be used.

So this is how you can use the Print function.

I did string right now but even if I input integers here, such as 123..

If I run it, you can see that it printed 123 here.

Inshort, it is not necessary that it will only print strings or only integers.

We will move forward…

The next function I’ll show is Type function.

Which function? Type function. Okay?

What can you do with the Using Type function?

Basically what is Type function’s work?

It will derive your particular variable’s data type.

Now what is Data Type?

Data types are string, flow, double..you must have seen or heard such things, right?

But you don’t need to define anything such here in Python.

Whenever you define any variable, you don’t need to take its datatype.

However, if we want to check the variable’s data type, Python has provided us with the Type function.

Alright...how?

Suppose I have a variable named A to which I have assigned the value 10.

We’ve assigned 10 to A...what is 10? 10 is an integer value.

Now I want to check if 10 is really an Integer value or not.

How will we check it?

By using the Type function.

I will use the Type function under the Print function.

I will pass A here.

You can see that it confirmed that our variable is indeed an integer data type variable.

I’ll take another variable in the same way.

Such as B. I’ll write a string here named Python. Okay…

I wrote a string named Python.

Now I will check the datatype of the variable B.

We have the Type function to check the datatype.

I assigned B here.

It showed us here in print below that our variable is a string type variable.

Let me take another variable again…

Whom I’ll assign Float value.

We know it is float value but we want to know it is float value through Python...

How will we do it? By using the Type function.

I will pass C under Type. It showed us that it is the float value. Okay?

So this is how you can use the Type function under Python.

Now our next function is for User Input.

If we want to take User Input...If we want to take User Input under Python,

we will use the Input function.

By using the Input function...I am not writing down the word function because it is represented by the round brackets.

So I’ve made the brackets afterwards to demonstrate the function under Python.

You can easily understand how to use the comments I’ve written as well. Right?

For instance, I want input from the user for the variable A.

I’ll use the Input function for Input and type a message to the user “Enter the value of A”

Why did I write that message? Because our user should know what value did your machine or code ask for.

Now I’ll print the value of only A.

As soon as I ran it, a text box opened up.

You can write anything...suppose I wrote Python, it printed out A’s value to be Python.

I’ll run it in the same way again.

I wrote 10 then it will print 10.

So this is how the Input function can be used here in Python.

So these were some of the basic syntaxes, basic functions which we saw today.

And when we will move forward to the next topic which is variable, I’ll explain all of these things again.

Now moving forward to see how to use Single line comments & multiline comments.

So this was a single line comment.

Suppose there is a particular program where you’ve written a very lengthy question such as “write a program to print multiple values with variable”

Now see, if you write a single hash, it will be considered as a single line comment.

What is it? A single line comment.

Now here you have 2 lines & you want to comment 2 lines.

How will you do it?

Let’s see.

What will you do? Add another hash here.

Adding 2 hashes will make it a multiline comment.

Suppose you don’t want to do this and want to use a shortcut, you can use a shortcut as well.

You simply have to select both the sentences and press Ctrl + the question mark key.

Doing that will make it multiline comments.

So you can use Multiline comments in this manner as well. Okay?

I’ll make a cell here.

I’ll mark down here that these are Multiline comments which will make it easier for you to understand when I give you the core files.

I’ll note down the shortcut as well...to apply multiline comments, use these shortcut keys.

Which is Ctrl + question mark.

I’ve written this to make it easier for you to understand.

I’ll turn it into a comment as well.

Clear?

So this is how you can use multiline comments here.

Our next topic will be Keywords in Python.

We will meet again in the next video.

FAQs

The Python programming language's syntax is a set of rules that describe how a Python programme is written and understood (by both the runtime system and by human readers). Python shares a lot of similarities with Perl, C, and Java. There are, nevertheless, some clear distinctions between the languages.

Find the Size of Any Object. Chaining of Comparison Operators. List Comprehensions. String Multiplication. Assign Multiple Variables in One Line. Swap Variables In-Place. Create an Enum. Enumerate.

First Python Program. Python Identifiers. Reserved Words. Lines and Indentation. Multi-Line Statements. Quotation in Python. Comments in Python. Using Blank Lines.

Python syntax can be executed by writing directly in the Command Line: >>> print("Hello, World!") Hello, World!

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere