New to Nutbox?

Club100 | Learn Python With Steem - Lesson 2 | datatype, variables, basic syntax and exercise questions - Learn and earn steem

5 comments

vvarishayy
74
2 years agoSteemit3 min read

Hello everyone! It's me again vvarishayy, hope you are well. A few days back I posted a lecture 1 on python this is lesson 2 on python which would be about; datatype, variables, and some basic syntax. And last but not least the exercise questions would help you to practice python. If you solve those questions and show them to me in comments or make a post on it, I will give you some steem in return as a reward for your commitment. Don't forget to share with your friends.

I am making it quite easy, keeping in mind that I am teaching people who don't know any computer language, so if you are new to programming you can also take part. Before reading this post, I advise you to read lecture 1.

Lecture # 1LINK

COMMENTS
Comments are # that we use in python for documentation of the code. It is quite easy for the programmer to understand its code after a while or other programmers can also understand it easily. While the program without comments becomes a bit difficult to understand if you are reading the huge code.

image.png

#my name is warisha. I love steemit <3 is a comment that is not showing me errors on shell

VARIABLE

We can't define the things directly while coding we have to assign the variables that can be any letter but not number or characters. The variable must be understandable for ease.

Note: In python, variables are case-sensitive.

image.png

num is a variable

DATATYPE

datatypedescription
Numericintegers(numbers), float (decimal numbers)
Stringtext
Boolean TypeTrue or False

TYPE FUNCTION

In python there is a built-in function called type function, that tells us the data type of the given data.

image.png

BUILT-IN

Builtin are predefine in python. We must not use them while assigning the variables, in function, or using it explicitly in the code.

image.png

INDENTATION

Indentation is the gap we use in python. At this time you may not know about the things, I am teaching to a complete beginner, and if you know what it is then well and good. I will explain you with the help of the program. You can see below, forget about the logic and the things you are not getting but see whenever I put a : colon, on the next line I gave a space of 4 then wrote something. This 4 letter space is called indentation.

image.png

QUOTATIONS: The words, numbers, and characters in the quotations are string data types.
'/n': Used to continue on the next line.
==: equal to sign
!=: not equal to sign

EXCERCISE

Do the exercises questions and show them to me and I will give you some steem as a reward <3

These questions were given to me by my teacher and I am giving them to you, to solve because coding is a practice game. If you practice it, you will become a pro.

image.png

image.png

image.png

image.png

Note: for question 1, no iteration is needed because I haven't taught that yet, only made that with the help of a print statement. You can leave 1 question in choice. I will give the answers to the questions in my next post.

Thank you for reading future programmers,

With kind regards
Pythonista
vvarishayy

Comments

Sort byBest