DEV Community

lordronjuyal
lordronjuyal

Posted on

day 03

date:- 22 May, 2024.
Errors --> 1) Syntax error - Every programming language has to be written in a specific way. In simple words, it's the grammar of that language. These rules are called syntax. Violating them will result in syntax error.

2) Indentation error - In Python, we use indentation to indicate if a code is a part of a block or not. By block, I mean some function or control flow statements. If not then there shouldn't be any space before the code else it would result in an indentation error.

Built-in functions:-
1) lower --> In this method(function) we pass a string which is then returned by changing all its characters into lowercase. To call it - string_to_convert.lower()
2) count --> This is a method that returns the number of times a character(s) appears in the string passed. To call it - string.count('char')

Comparison operator:- They are used to compare two values.
To check if a is equal to b: a == b
To check if a is greater than b: a > b
To check if a is less than b: a < b
To check if a is less than or equal to b: a <= b
To check if a is greater than or equal to b: a >= b
To check if a is not equal to b: a != b
The comparison operator auto converts the result in boolean values, True or False.

Control flow statements:- Python interpreter executes the code from top to bottom. Control flow is the code statements that change this flow of interpreter based on some conditions defined by us.
1) If-else statement - With the help of it we execute the code which satisfies some condition. Syntax is below:

if-else statement
First condition 1 will be checked, if it comes to be True,
the indented code inside the if-block will get executed. The interpreter will skip the else-block. If it is False, the if-block code is skipped and the else-block code will be executed.
We can use an if statement inside another if/else statement. Also, we can use multiple if statements one after another. But then the interpreter has to check all the conditions. To save this we have an elif statement. It is used when conditions are related, if one occurs others can't.

Program-- I made a leap-year calculator.

leap year calculator


Personal--> Yesterday, due to a loss in the market, I had to revisit my charts and strategy. So have to give a miss to coding. I am sorry for this, and I promise to do at least one coding exercise on such days so that no day go wasted.
I have to use a photo, as in the preview indentation is not shown. I have seen other people's blogs. Those are well formatted. I hope I will improve my blog also. Right now, I won't be able to give time to it. However, I have started English grammar lessons to improve my written skills.

Top comments (0)