Control systems
1. if
2. else statement
3. for
4. break and continue
5. pass
Control statement : if
Notes :
1. No curly braces, instead of that we are giving : (colun) and it also represents a new block is starting.
2. Always maintain indentation , preferable 4 ( means spaces ).
How to identify if the block is closed ?
using indentation for that.
How to end the block ?
if you start the statements ( something like if and else automatically the block ends ).
How to read an input in python ?
for that you can use input function
default nature : Any value, you given to input function, it will take as string.
How to convert the value to integer using input function ?
x = int(input("enter an integer value"));
int is the integer function
input is a input function
Optional : Paranthesis is optional here.
What is a range function ?
For control statements the range function is used.
Example of range,
what is meant by concatenation operator in python and provide me with an example ?
here in this example,
print ("i value is", i);
, represents the concatenation operator in python
what is meant by concatenation operator ?
Concatenation means joining strings together end-to-end to create a new string. To concatenate strings, we use the + operator. Keep in mind that when we work with numbers, + will be an operator for addition, but when used with strings it is a joining operator
How to use for loop for the lists ?
here in this example,
for i in s
in is a function
i is the index variable
list = [10,20,30]
and the meaning of the for i in s is,
for index variable i in the list
Break and continue statement
Break statement
i==3 for this specific iteration, it gets skipped
continue statement
what is the pass statement ?
how this is represented in other languages ?
No comments:
Post a Comment