3) b. For Loop Examples (2)




You are in the operation center of the enemy agency. You found a file with the agents that they want to kill, but if you open the file they will know that somebody was there. You have to write a program that reads the file, saves the data and prints out to the console line by line.

test

1
Output:




The Earth is under attack but you managed to hack the enemy’s communications. You have to decode their message.
Write a program that decodes their messages. Iterate through every line of the message then add one to every letter from the line.If the coded character is z, then write an instead.

test

1
Output:




You are on a mission to Mars but your ship got injured and the systems are not working. You have to write a program that iterates through the computer’s logs. Due to saving money the designers build in computers with as small memory as possible,so you can write only one line of code. Complete the system’s code with a line, which iterates through the logs and save them in print the variable to be able to find the error and save the mission and the crew.

test

1
Output:




You are trapped in the basement and you have to find the code of the padlock. There is a computer with a file named
padlock_codes.txt. The file cannot be opened but can be read with a program. Each lone contains a 6 digit code and the padlock’s serial number.Write a program that finds the code for the padlock with the serial number of “W15SA23”.

test

1
Output:




You are in the middle of a zombie outbreak. A list of data about cities was given to you. You have to print every city’s name, where the infected people is more than 10% of the whole population. In the list were provided the name of the city, the number of the infected people and the population number.Write a program that prints the asked cities.

test

1
Output: