Programming Midterm
Programming Midterm
Here you can see that we used # (hash) for single line commenting.
b = int(input("Balance: "))
l=1
"""Here we must denote l as 1 because it must enter while loop
And code must be executed"""
while l != 0 :
l = int(input("Please enter input : "))
if l == 0:
break
#When we don’t obtain any input then it means month is over
# We must stop loop
#For these reason we use break operation
b=b+l
w = int(input("Please enter withdrawal :"))
b=b-w
print(f"Your monthly balance is {b}")
As you see above, we used """ (triple quotes) or multiple # for multiple –
line commenting.
Answer : Syntax errors occur when the structure of the code violates the
rules of Python’s grammar. These errors prevent the code from being
executed or interpreted. Example : print(“Hello, world !)
Common causes :
Semantic errors occur when the code runs successfully but does not perform
the intended function due to incorrect logic or meaning. Example : x = 10
y = 0 result = x / y It will give us ZeroDivisionError, indicating faculty
semantics
Common causes :
7. 01 Practical question
1234
0234
0134
0124
0123
15. 03 Answer :
s=0
for k in range(5):
for i in range(5):
if i == s:
continue
print(i, end = "")
s=s+1
print()
16. 03 Explain double split pattern content in string with example
21. 04 Add any string data in list and save it txt file
Explain with examples by adding continue statement to for loop operator in Python
26. 05 programming language.
28. 06 Explain while (indefinite iteration) loops in Python programming language with examples
What is a random function? Describe the range of values of the random, randint, uniform,
and randrange functions
31. 06 Write capitalize function with while loop and save output in the data. txt file
34. 07 Explain the list methods used in Python programming language with examples.
35. 07 Explain nested list and give examples