1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
svet-max [94.6K]
2 years ago
10

Write a loop that displays your name 10 times. 2. Write a loop that displays all the odd numbers from 1 through 49. 3. Write a l

oop that displays every fifth number from 0 through 100. 4. Write a code sample that uses a loop to write the numbers from 1 through 10 to a file. 5. Assume that a file named People.txt contains a list of names. Write a code sample that uses a while loop to
Computers and Technology
1 answer:
irakobra [83]2 years ago
3 0

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()

You might be interested in
Pix blocks półfinały skilled
jasenka [17]

mam  ,,4 6 7 12 15 .18.20.

6 0
3 years ago
What is the location used by users to configure delegate access on their own mailboxes? Backstage view &gt; Account Settings Bac
abruzzese [7]

Answer:

A: Backstage view > Account Settings

Explanation:

7 0
3 years ago
Technician A says that a lead acid battery uses straight Hydrochloric acid for electrolyte. Technician B says that a lead acid b
konstantin123 [22]

Technician B is correct

It is safe to say that Lead acid uses sulfuric acid. When fully charged, the electrolyte consist of 40% concentrated sulfuric acid and the remainder consist of mostly water. However, as it discharges, both the positive and the negative plates turn into lead sulfate with the electrolyte loosing much of its dissolved sulfuric acid and water.

7 0
3 years ago
Read 2 more answers
Therapeutic services pays less than most other careers.<br><br><br> 1) True<br> 2) False
horrorfan [7]

This is false. Therapeutic services are some of the most expensive.

6 0
2 years ago
Read 2 more answers
Hello! I am a new coder, so this is a simple question. But I am trying to create a code where you enter a number, then another n
slavikrds [6]

no longer returns an error but your math seems to have something wrong with it, always returns 0

Console.WriteLine("Enter a percentage here");

   int Percent = int.Parse(Console.ReadLine());

   Console.WriteLine("Enter your number here");

   int Number = int.Parse(Console.ReadLine());

   int result = Percent / 100 * Number;

6 0
2 years ago
Other questions:
  • When computers connect to one another to share information, but are not dependent on each other to work, they are connected thro
    7·1 answer
  • Host A and B are directly connected with a 100 Mbps link. There is one TCP connection between the two hosts, and Host A is sendi
    14·1 answer
  • What education and training is required to be an applications software engineer?
    9·1 answer
  • The function of the file server is to : 1. store data and software programs that can be used by client computers on the network.
    12·1 answer
  • Explain word processing ​
    11·2 answers
  • • Open your Netbeans IDE and answer the following question
    5·1 answer
  • All health information available on the internet is valid. <br> a. true <br> b. false
    6·1 answer
  • A reflexive pronoun is a pronoun
    6·1 answer
  • Which option is typically only used when utilizing self joins?
    8·1 answer
  • In python please:
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!