00:01
Okay, so in this question we want to practice writing while loops.
00:08
So we want to take a user input and while the user input is less than 14, we want to add it to a string.
00:24
And then we want to multiply the result by 3 until the while the result is less than 14.
00:32
We have, i have no information about which programming language to use in the question so i'm going i'm simply going to use python as it's rather popular and yeah that's it i'm going to write the code in python and if it's not the expected language hopefully you can translate it in the language of your choice as always with programming the logic behind the code you'll always be the same so here i need a user input so it doesn't say that the input will be an integer, but i will write it and an integer as it's, well i don't know, i will leave it as i will trust the use.
01:27
So as for user input in python, you simply call the input function.
01:33
So please, please enter a number.
01:40
I will write backslash and for formatting purpose.
01:43
So if i run this code and i write for example 1, nothing happens, which is normal.
01:51
We're not doing anything will be input yet.
02:00
And then we want a string.
02:03
We're going to call it the output string and it will be empty for now.
02:13
And we do not want to output 14.
02:18
We want to output while the and i'm going to agree.
02:22
Here another variable sorry about that so my new variable will be the current which will be equal to my user input and here i will write why my current count is less than 14 so we that's the first step or the current count is 14 we want string we want to add our string which how did i call it output string we want to add at the end our current count plus an underscore like this and then we want to multiply it not our output string our current count we want it to be equal to current count time three and here i'm simply going to show my output string so if i run this and i enter one okay so here i really need my current count to be of a decimal or integer so i'm going to put an integer like this so here it will make sure my input is converted as an integer and now if i run this and i enter one nothing happened if i print my output string and i enter one there you go, i simply needed to print it.
04:23
So it printed the exact test case that we wanted.
04:29
The 1 underscore 3 underscore 9 underscore and that's it...