if...else implementation in #C #java #Python смотреть онлайн
Hi there!! I'm a programmer. In this video, I will be showing you how to implement if..else statements in three different coding languages ie C, Java, and Python. Watch as I explain the difference between these languages.
Here is our problem statement to calculate the electricity bill based on the units consumed. The pricing is given as follows. Also, the input of 394 units is been given. I will open CodeBlocks to execute my C code.
First, I will save my file as ebill. Codeblocks by default will save the file as ebill.c. Stdio.h is the function used for getting the input from the user and display output result text to the monitor. Then I will declare two int variables u for units and s for sum. I will write the scanf function to read the integer value for units consumed. Now let us implements if..else statements. If and condition, remember to add flower braces when the code inside if-statement is multi-lined. The next part is else if statement. Sum s equal to 100*10+(u-100)*15 (u-100) because we have already charged for the 100 units. Let me just copy this and change the constraints as well as the sum equation. Let us print the output sum by using the printf function. I will build and run the program. I will give the input as 394 and here is our output 6850.
Let's go java is ahead. To write Java code I will be opening the Atoms text editor. I will save the file as ebill.java. Class name ebill because we have saved the file as ebill. Now we will call the public void main function. First, we have to declare a scanner function sc which is found in java.util.Scanner package, so we have to import this package. to use the scanner function to take the input from the user. Now we will declare int u to store input value we use sc.nextInt() function. I also declare int s. Rest if..else statements remain the same as in c language so I will just copy and paste it here. In the last, let me print the sum by using the function System.out.println(). Let's compile this program by opening the command prompt window. To compile, we use javac space the file name ebill.java. Now its compiled. We will run this program by typing java space class name ebill. I will give input as 394 and here is our output 6850.
Its time for Python now. I will write the Python code in the same text editor. I will save the file as ebill.py. The declaration of the type of variables is not essential in python. The input function is used to get input from the user. Whenever the user gives input, it is always in a string type. So we have to convert to integer type by using the int() function. Now we type if respective condition and colon. And in the next line, I will leave these white spaces as are very important in python. We can call this as a substitute to the flower bracket present in C language. Leaving these white spaces is called as Indentation. There is no necessity of semi-colon at the end of the equation. Else..if is written as elif, then respective condition colon. The mathematical logic remains the same. So the logic written in the C and python remains the same.
Now let's print the sum by using the print function.
Let's run this program opening the command prompt window by typing python space file name ebill.py. I will give the input as 394 and the output I get like 6850.
I hope you guys appreciate my efforts, so please like, share with your friends, subscribe to my channel to encourage me.
Keep learning. Goodbye. See you guys in the next video.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «if...else implementation in #C #java #Python» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.