ᗷIᑎᔕ Gᖇᗩᗰ
Закритий канал
1 419
Підписники
-424 години
+437 днів
+13730 днів
Архів дописів
1 419
❇️ Python Indentation
🌺Indentation refers to the spaces at the beginning of a code line.It is used in Python to denote a block of code.
🌺As a programmer, you decide how many spaces to utilise; the most popular number is four, but there must be at least one.
🌺You have to use the same number of spaces in the same block of code, otherwise Python will give you an error.
🌺If you omit the indentation, Python will throw an error.
🌺Without indentation, Python does not know which statement to execute next or which statement belongs to which block.
✗ @codinginsights ✗
1 419
EXERCIISE TIME
What will be the output? >>> " always be happy".split("a")
1 419
❇️Python's built- in strings
1.<str>.split() - It can be used with line of text to split it in words.
(a) If you don't provide any argument to split then by default it will split the given string considering whitespaces as separator.
E.g. >>> "I Love Myself".split()
output : ["I","Love","Myself"]
(b) If you give a string or character as an argument to split ,then the given string will split up considering the given string/character as separator.
E.g. >>> "I Love Python".split("o")
output : ["I L","ve Pyth","n"]
🌺 Note: Separate character i.e "o" is not included in the split strings.The given string is divide from position containing "o".
2.<str>.replace() - If you want to replace a word with another
E.g. >>> "I Love Myself".replace("Myself","India")
output : [" I Love India"]
✗ @codinginsights ✗
1 419
❇️ Python Comparison Operators
🍁 ==
If the values of two operands are equal, then the condition becomes true.
Ex: a=10
b=20
(a==b) is not true
🍁 !=
If values of two operands are not equal, then condition becomes true.
Ex:(a!=b) is true
🍁 >=
If the value of left operand is greater than or equal to the value of right operand, then condition becomes true
Ex: (a>=b) is not true
🍁 <=
If the value of left operand is less than or equal to the value of right operand, then condition becomes true
Ex: (a<=b)
✗ @codinginsights ✗
1 419
❇️ What is Interactive mode programming in Python?
🍁 Interactive mode provides us with a quick way of running blocks or a single line of Python code. The code executes via the Python shell.
🍁 Interactive mode is very convenient for writing very short lines of code. In python it is also known as REPL which stands for Read Evaluate Print Loop
❇️ How to run python code in Interactive mode?
To run python in command prompt type “python”. Then simply type the Python statement on >>> prompt. As we type and press enter we can see the output in the very next line
✗ @codinginsights ✗
1 419
❇️ Mutable and Immutable
Mutable object : An object whose internal state can be changed is mutable.
Immutable object: Immutable doesn't allow any change in the object once it has been created.
Let's check mutability of List and tuple
L1=["c","o","d","e","n","g"]
L1[3]="i"
print(L1)
Output: ["c","o","d","i","n","g"]
👉 List is mutable
T1=("c","o","d","e","n","g")
T1(3)="i"
print(T1)
⭕️ TypeError: 'tuple' object does not support item assignment
👉 Tuple is immutable
Did you get what is really mean by the word "mutable" and "immutable"?
✗ @codinginsights ✗
1 419
🧑💻Remember in programming.
You will never know everything. Don't be afraid to google something.
✗ @codinginsights ✗1 419
Amongst which of the following is / are the Numeric Types of Data Types?
1 419
❇️ Some Python Interview Question and their Answer👩💼🧑💼
Q. Python an interpreted language. Explain.
A. Interpreted in simple terms means running code line by line. It also means that the instruction is executed without earlier compiling the whole program into machine language
Q. What is the difference between .py and .pyc files?
A. The .py files are the python source code files. While the .pyc files contain the bytecode of the python files.
Q. What is namespace in Python?
A. namespace is a naming system used to make sure that names are unique to avoid naming conflicts.
✗ @codinginsights ✗
1 419
👉 IS CODING REALLY HARD ? 👈
❇️ Learning how to do anything new is typically going to be hard, and thats what makes thiose whoknow how to do that something special.
❇️ No, coding is not hard to learn. However like anything new, it's not easy to start, and how difficult a time one has with learning to code will vary across a number of factors.
❇️ Those who have the time, persistence, and dedication can start gaining coding experience just as they can learn to do something else.
❇️ Point is learning to code and finding the opportunities to do so is going to take a bit of digging.
❇️ Coding is like working out. It's about doing it everyday consistently. You won't see any results in a day.
😎 Hope you guys finds this helpful
✗ @codinginsights ✗
1 419
❇️ Built-in function of tuple
🔴 all( ) :- Returns true if all element are true or if tuple is empty
🟠 any( ) :- Return true if any element of the tuple is true. If tuple is empty, return false.
🟡 len( ) :- Returns length of the tuple or size of the tuple.
🟢 sum( ) :- Sums up the numbers given in the tuple.
🔵 max( ) :- return maximum element of given tuple
🟣 min( ) :- return minimum element of given tuple
😎 Hope you guys liked it
✗ @codinginsights ✗
1 419
❇️ Tuple
A collection of ordered and immutable objects is known as a tuple.The sequence of values stored in a tuple can be of any type
☂️ Creating a tuple
All the objects must be enclosed in parenthesis (), each separated by a comma, to form a tuple.
Note: Creation of Python tuple without the use of parentheses is known as Tuple Packing.
# Creating a empty tuple
T=()
print(T) 👉output: ()
# Creating a tuple having object of different types
T=(1,3.5,"python)
print(T) 👉output: (1,3.5,"python")
😎 Hope you guys liked it
✗ @codinginsights ✗
1 419
Coding depends on:
30% Google
20% Stack overflow
10% Own code
20% starring at the screen
20% starring at the ceiling
✗ @codinginsights ✗
