Simple Python Tutorial for printing formatted output #print() #modulo() #fstring #string смотреть онлайн
Simple python example and short video to illustrate the use of print() display formatted message on the console. It shows 4 different methods of using the print() to display output. The difference between using comma (,) and using string concatenation. It also shows how to use modulo (%) to display string in required number of decimal places. There is also an example to use fstring method to display.The examples used are very simple so that it is easy for beginner to understand.
The 4 methods discussed has the following syntax
print( " ... , varInt , ... , varFloat , ... " )
print( " ... + str(varInt) + ... + str(varFloat) + ... " )
print( " ... %d ... %.2f ... " % (var1,var2) )
print( f" ... {varInt} ... {varFloat:.2f} ... " )
The below are the codes used
############
name = "Mary"
age = 18
height = 1.777
print(name + " is " + str(age) + " years old and "+ str(height) +" m tall" )
print(name , "is" , age , "years old and", height ,"m tall" ) #add space between
print("%s is %d years old and %.2f m tall" % (name,age,height) )
print(f"{name} is {age} years old and {height:.2f} m tall")
############
Beginner may get confused with the comma and string concatenation method.
To print with a mixture of numerical (int and float) variables and string variables, we need to use str() for the string concatenation (+) method.
Note that the string concatenation (+), Modulo (%) and fstring method are just few ways to format a string.
You can also use them in input() as well to display a string on the screen to prompt user for input.
You can use the link below to see video on how to use input()
Apart from watching the video, you can also show more info to read on the explanation.
https://youtu.be/nRK8Qj8iZ3A
Please like the video if it helps you :)
Hope these inputs are helpful for you.
0:00 - print() using string concatenation (+) and comma (,)
05:14 - print() using modulo (%) operator method
06:45 - print() using fstring method
Keywords:
#python
#string
#fstring
#print()
#str()
#concatenation
#comma
#modulo
#tutorial
#short
#easy
#+
#percent
#%
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Simple Python Tutorial for printing formatted output #print() #modulo() #fstring #string» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.