5 Ways You Can Print() In Python

preview_player
Показать описание
Here are 5 ways you can print() in #Python. #Short
Рекомендации по теме
Комментарии
Автор

“5 different ways you can print in Python”… demonstrates 5 ways to format strings instead

justanothergunguy
Автор

Side Note: fastest (run time) is by using formatted string i.e print(f"{val}")

jugsma
Автор

print(name, age, sep=" : ") works aswell

mastrofducks
Автор

Simple method:
*Create a buffer using a array of hexadecimal values representing the respective unicode characters avaliable for your strings*
Ex:
Buffer: 48656C6C6F20576F726C6421
Display: Hello World!
Then, create a function that will convert these hexadecimal values into string format characters and put they all together into another buffer (in string format), and a FOR loop to join all values of this array into a variable and print it on screen.
String format buffer:
H e l l o W o r l d !
But that is not all, you still don't have a font.
Make an A.I that will hack into the NASA servers and obtain the secret text font that only 0.00001% of the humans have ever seen, then open this font file, and copy the line 69, send it to the russian government to get the exact configurations and encoded word, then send these values to a physical "Enigma" machine from the WWII, go to the decoded coordinates, dig a hole on the marked point, and pick the flash drive, then inside this flash drive you will see a rickroll video, but inside the header sector of this video, you will find the link to download the REAL fontfile for the perfect print method in python.

karmatical
Автор

print("Luigi : 38")

Huh? Didn't know it'll get so much likes, thank you!

IchorDragon
Автор

The Zen of Python:
"There should be one-- and preferably only one --obvious way to do it"
Python itself:

zwatotem
Автор

This is basically 5 different ways to concatenate or format string here's really 5 ways to print in python

import sys
import os

# 1.
print("hello world")
# 2.
sys.stdout.write("hello world\n")
sys.stdout.flush()
# 3.
sys.stdout.writelines(["hello ", "world\n"])
# 4.
os.write(1, b"hello world\n")
# 5.
os.system("echo hello world")

FlinCode
Автор

I enjoy using the formatted f-string in most cases!

WhyNotProgram
Автор

String interpolation is what I originally learned because f-strings weren't a thing when I was in high school.

Also it's basically the same as how you do it in C and the first programs I ever wrote were a couple simple command line tools in C++

QuotePilgrim
Автор

There is also a 6th way, although it takes more lines of code:
print(name, end=" : ")
print(age)

chojhzd
Автор

f strings should be the standard method tbh

badonker
Автор

I use the 3rd one.. not too complicated

Contemelia
Автор

For me, the method in line 6 is the best. As for me, it is the most legible and comfortable.

krystb
Автор

Hey man sometimes the noob way is all you need sometimes hahaha

ssmillion
Автор

I feel like the 3rd one is more clean and easier

Takemikazuchi
Автор

+You can import sys module and write:
sys.stdout.write(f"{name} : {age}")

euglast
Автор

You can also write print(name, age, sep=“, “)

devox
Автор

3 ways to use c# on python with print() xd

lopiratomagico_loco
Автор

I always used the 5th one back in the day

DaveeeOnTop
Автор

Is there a reason to not always use the 3rd one?

adiveler