Flow of Control Flashcards

1
Q

What is flow of control

A

Controlling flow of code in python

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Input function?

A

Asking user to input value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Syntax of input function?

A

<variable>= <datatype>(input(<enter>))
</enter></datatype></variable>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Type of flow of control?

A

Sequential flow (line after line) Ex:
a= input(“enter:”)
b= “world”
print(a+b)

Conditional flow ( Executed based on condition)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Iterative loops

A

Used to iterate an element in a sequence
s= “hello”
for i in s
print (i)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is Range?

A

Used to **generate sequence of numbers **
in for a loop
for i in range (1,11)
print (i)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Write programme to generate first 10 odd numbers

A

for i in range (1,11)
if i%2==1:
print (i)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

print(len(s))

A

calculates length of characters of elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is while loop?

A

Used to execute a block of code as long as the condition is true

example:
i=0
while i<=20
print(i)
i+=2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what does break do?

A

**Used to exit loop **when given condition is true
example:
for i in range(10)
print (i)
if i==5:
break

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Continue:

A

**skips current iterations **if the condition is true and executes next iterations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly