Answer:
The program in Python is as follows:
#1
for i in range(10):
print("MrRoyal",end=" ")
print()
#2
for i in range(1,50,2):
print(i,end=" ")
print()
#3
for i in range(0,101,5):
print(i,end=" ")
print()
#4
i = 1
while i <=10:
print(i,end =" ")
i+=1
#5
myfile = open("People.txt", "r")
eachLine = myfile.readline()
while eachLine:
print(eachLine)
eachLine = myfile.readline()
myfile.close()
Explanation:
The program in Python is as follows:
Program #1
This iterates from 1 to 10
for i in range(10):
This prints the name for each iteration [modify to your name]
print("MrRoyal",end=" ")
This prints a new line
print()
Program #2
This iterates from 1 to 49 with an increment of 2
for i in range(1,50,2):
This prints the odd numbers in the above range
print(i,end=" ")
This prints a new line
print()
Program #3
This iterates from 0 to 100 with a step of 5
for i in range(0,101,5):
This prints every 5th number
print(i,end=" ")
Print a new line
print()
Program #4
This initializes the number to 1
i = 1
This opens the file in an append mode
f = open("myfile.txt", "a")
This loop is repeated from 1 to 10
while i <=10:
This writes each number to the file
f.write(str(i))
Increment the number by 1
i+=1
Close the file
f.close()
Program #5
This opens the file in a read mode
myfile = open("People.txt", "r")
This reads each line
eachLine = myfile.readline()
This loop is repeated for every line
while eachLine:
Print the content on the line
print(eachLine)
Read another line
eachLine = myfile.readline()
Close the file
myfile.close()