Posts

Lesson 6 - Loops (While), Break, Continue

Hi, So today we learn loops. Many times we have some scenario where we need to repeat the steps. Here we come with solution called Loops. Python have "While" & "For" loop. While Loop While loop executed until the condition remains true. In while loop we initiate the variable that controls the counter for loop. Then apply the condition and inside the loop increment the counter by 1 or depends on your requirement. Example i = 1 while i <= 10:     print ("Do some coding")     i++ So first it check the conditions i <= 10 -> 1 <= 10 -> True -> Print -> Do some coding And so on until the condition is true. Above examples shows "Do some coding" 10 times. We can use below keywords inside loop to control the execution. 1. Break 2. Continue Break If our conditioned satisfied and we didn't need to execute the remaining we use break. It stops the execution and get the control out from loop. Continue We use "continue" ke...

Lesson 5 - Conditional Statements

Lesson 5 - Conditional Statements Hi All, I start the lesson with an example You need a drink but based on some condition like color, you ask shop keeper if you have white drink please give me 2 and if you don't have white give me any 1. So, in above example you use conditions. Similarly in programs we use condition to sort out the results. Another example is finding the grade based on your percentage. If percentage is between 90 - 100 your grade is A+ and so on. Syntax: The keyword 'if' is used for condition with conditional operators Example a = 20 b = 10 if a > b:     print("a is greater than b") Now you observe in above example if a is greater than b than it prints "a is greater than b" but if not than it didn't print anything. To handle this use case we use else if a > b:     print("a is greater than b") else:     print("a is not greater than b") For some cases we have multiple conditions to check for example do some ta...

Python Lesson 4

Lesson # 4 Hi All , In lesson 3 we start to learn the collection in python. We finish list. Today we learn more collection types. Tuples A tuple is collection which is ordered and unchangeable. It similar to List but only difference is once you create the tuple you are not able to change the orders, didn’t add more items, unchangeable. But yes, there is ways to add items or modify the values in tuple. If you need to add value in tuple, you need to create another tuple and join both. If you need to modify the tuple value, cast tuple into list, modify the value and again cast list to tuple. Example of tuple MyTuple = (“Banan”, “Apple”) In tuple ( ) brackets are used to declare and initialize the tuple. You can use count() and index() methods to search the values in tuple. Sets Sets is collection with unordered and unindexed data. It means there is no index associated with value. { } brackets are used to declare and initialize the sets...

Python Lesson 3

Lesson # 3 Hi All, String and Multi line String Normally we write string inside single quotes or double quotes MyString = “Line1” or MyString = ‘Line1’ Both are correct syntax. There is no limit of string length or size. Its 1 character or might be 1000 sentences. For the sake of readability python supports multiline string that should inside in three double quotes. Example MyString = “”” Line 1 Line 2 Line 3 Line 4 etc. “”” Operators In Python there is 7 types of operators 1.        Arithmetic 2.        Assignment 3.        Comparison 4.        Logical 5.        Identity 6.        Membership 7.        Bit wise Mostly all operators are commonly used, and you know about them. Example Arithmetic o...

Python Lesson 2

Lesson # 2 Hi All, Comments Comments are very useful and important in any programming language. In python we also use comments to make our code more readable and definable. But remember ‘Code never lies, but comments lies’ – So, make your comments as per code so it exactly defines why we write a comment and what we need to explain at that time. Because programmer works with different languages and on different projects. So, write your comment in that way if you read after 1 year you remember or understand what’s the logic behind and it helps you to figure out why I write this section of code etc. Syntax of comments è In python # symbol used for comment è For multiline you can use # symbol or “”” (three times double quotation) Example # single line comment “”” Comment 1 Comment 2 “”” So, between “”” and “”” is comments in python Variables As I told in lesson 1 that in python no need to put the data type for variables in pyt...

Python Lesson 1

Lesson # 1 Hi All, Today we start to learn python programming. IDE: PyCharm Community Version - Download PyCharm Definition Python is programming language and used for web development as well as machine learning, hardware programming. So, why we learn Python. The answer is very clear. 1. Famous language in 2020 2. Easy to learn 3. Good market 4. More projects 5. Good earning Who Learn Python Any person can learn Python if he has interest in solving the problem pro-grammatically. Pre-Requirement This course is for those who have basic knowledge of programming and have interest in learning new technologies Let’s start ……. My name is Salman and I am professional developer as well as blogger, teacher and learner. History of Python ➔ Developed by Guido Van Rossum ➔ First release in 1991 Current Version ➔ Python 3.8.x Download Python Latest Version Syntax We learn syntax in coming lessons but just need to remember ➔ Python didn’t used brackets such ...