#python
Python MCQ Questions and answers,
Python MCQ,
'for' loop
iterative statement, Repetition statement,
for statement iterates over the items of any sequence (a list or a string), in the order that they appear in the sequence.
three basic sequence types: lists, tuples, and range objects.
'for' loop knows number of iterations
range (), format specifier,
represents an immutable sequence of numbers.
generates arithmetic progressions by calculating individual items at a time.
range type is used in 'for' loops to loop
specific no. of times .
Python Programming,
NIELIT M3-R5 Course 'O' Level Certification,
#pythontutorial #pythonforbeginners
#pythonloops
#pythondeveloper #pythoncoding #learnpython
#pythonquiz #python3 #pythonskills #codingpython
#pythonbasics #pythonbeginner #pythonprogramming
#datascience #dataanalytics
#codingquiz #quizchallenge #codingcommunity
#freshers #techtalk #top10
#interviewpreparation #interviewhacks #interviewquestions #interviewskills
Ace your Python exams with this MCQ marathon!
Covers various Python concepts, including input/output, data structures, and more.
#PythonMCQs #PythonInterview #CodingQuiz #PythonProgramming #TechSkills
#ssitlecturestamil @ssitlecturestamilதமிழ்
for' loop iterates over
items of a sequence
Syntax:
for tlst in seq:
fcode_blk
else:
ecode_blk
tlst - single or list of variables
seq - string, range, list,...
else clause - optional
range(1,7,2) -- seq 1,3,5
{Refer MCQ 53, 54}
f-string evaluates p*i to '*'*i (seq.
repetition) {MCQ 29, 31, format specifier}
After : is format specifier ^{n}
^ - Centre align, {n} - 7 - Width,
default space used since Fill char is not specified.
So, output is string from p*i is centered ^ within a width of 7.
For every Iteration,
1st: '*'*1 - *:^7. - *
2nd: '*'*3 - **:^7 - **
3rd: '*'*5 - ****:^7 - ****
Why to use {} for n and not for i ?
i is Python expression to be evaluated,
while n is part of the formatting specification.
Информация по комментариям в разработке