CSE Lab - Report 3
CSE Lab - Report 3
Experiment
Experiment Title
No.
2. Description:
{loop body}
1
A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set,
or a string). This is less like the for keyword in other programming languages, and works more
like an iterator method as found in other object-orientated programming languages. Because
the "range" function appears so frequently in for loops, we might mistakenly believe the range
is a component of the syntax of for loop. It isn't: it's a Python built-in method that provides a
series that follows a specified pattern (usually serial integers), fulfilling the criteria of giving a
series for the for expression to run over. There is no necessity to count because for can act
straight on sequences most of the time. On the other side, the if condition is considered the
simplest of the three and makes a decision based on whether the condition is true or not. If the
condition is true, it prints out the indented expression. If the condition is false, it skips printing
the indented expression.
3. Source Code:
For source code, we need to take X as an integer number where any value can be given.
the number of c.
m=X[i]
There I have given the screenshot of the code from the computer.
2
4. Output Screenshot:
The output will come with the largest number. It will calculate all the values that has
been listed.
5. Conclusion:
In Python, the for loop is often used to iterate over iterable objects such as lists, tuples, or
strings. After clicking run, the largest number will be shown. The for loop in Python is very
similar to other programming languages. We can use break and continue statements with for
loop to alter the execution. However, in Python, we can have optional else block in for loop
too. There a coder should incorporate with some challenges like: -
3
It is important to follow some basic rules of coding like using brackets, using inverted
coma (“”) in appropriate place, using numeric and string values perfectly.
The length should not be normally more than 8 characters.
White spaces should be avoided.
While doing the code, I was not able to understand the len(c) code for what it has been
used.
-------------------------------------------------------------------------------------------------------------