Welcome to Mobilarian Forum - Official Symbianize forum.

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

TUTORIAL PYTHON FOR BEGINNERS | PRINTING STUFF

S 0

StrygwyrBs

Abecedarian
Member
Access
Joined
Aug 20, 2022
Messages
61
Reaction score
3
Points
8
Age
25
Location
Philippines
grants
₲264
2 years of service
Thank you
Hello guys, I started a basic tutorial serious on Python . Hear I'm going to explain many theoretical and practical stuff in python programming. I'll explain basic things and also some deep stuff like object oriented programming, Ctypes, Network programming etc.

Printing is an absolutely basic part of a programming language. We learned how we can print a string with PHP and C. So in this tutorial we are going to talk about python printing. Hear I explain you both python 2 and 3. Let's see following program.





Code:
Please, Log in or Register to view codes content!


[size=small] First thing to understand is syntax of printing something. print ('string goes hear') We can use print() function to do this. You want to put the string as the argument for that function. (I'll explain more about functions in a later tutorial). What if you include a quot in your string? It will disturb Python's syntax.
[/size]


[size=small][size=small][size=small]Code:
[/size][/size][/size]
Code:
Please, Log in or Register to view codes content!



In next line I opened a nano editor and corrected the error. After I ran it again and its working fine. So what the magic happened hear when we used a backward slash? Its a escape symbol. That mean when python interpreter see a backward slash it'll ignore next character. Actually this is not a ignoring. It think next character is a specific one and should not printed normally. Also there are some other escape characters . We use those sometimes in our programs. \n - This one is used to indicate a line break. If we use this between a string it will break and go to another line. \t - This acts as a tab space. \\ - We can print a backward slash with this. Why it happen?? Think.! Now you need to do experiments with those. Do it yourself. Next we have another problem. This string also uses a quote inside it. But it's not produce an error. print ("this code's syntax is OK. But why?") This is because hear we have used different quotation marks for indicate the string. If we want to make a comment we use '#' symbol. In a previous tutorial I have explained you why we use comments in our programs. Also we can use triple quotes for a multi line code. This is very helpful when we want to disable a code block for debugging purpose.

Code:


[size=small]Code:
[/size]
Code:
Please, Log in or Register to view codes content!



Finally I have listed another way to print a string. Hear we don't use parentheses. But this way is not correct in python 3.x version.

Code:


[size=small]Code:
[/size]
Code:
Please, Log in or Register to view codes content!


[size=small][size=small]So it's a good programming practice to always use first method for python printing. Because it's important to learn both versions of python.
[/size][/size]
thank you for this
 
B 0

BrightMemory

Transcendent
Member
Access
Joined
Jan 13, 2023
Messages
42
Reaction score
1
Points
8
Age
31
Location
Suyo, Philippines
grants
₲214
2 years of service
Hello guys, I started a basic tutorial serious on Python . Hear I'm going to explain many theoretical and practical stuff in python programming. I'll explain basic things and also some deep stuff like object oriented programming, Ctypes, Network programming etc.

Printing is an absolutely basic part of a programming language. We learned how we can print a string with PHP and C. So in this tutorial we are going to talk about python printing. Hear I explain you both python 2 and 3. Let's see following program.





Code:
Please, Log in or Register to view codes content!


[size=small] First thing to understand is syntax of printing something. print ('string goes hear') We can use print() function to do this. You want to put the string as the argument for that function. (I'll explain more about functions in a later tutorial). What if you include a quot in your string? It will disturb Python's syntax.
[/size]


[size=small][size=small][size=small]Code:
[/size][/size][/size]
Code:
Please, Log in or Register to view codes content!



In next line I opened a nano editor and corrected the error. After I ran it again and its working fine. So what the magic happened hear when we used a backward slash? Its a escape symbol. That mean when python interpreter see a backward slash it'll ignore next character. Actually this is not a ignoring. It think next character is a specific one and should not printed normally. Also there are some other escape characters . We use those sometimes in our programs. \n - This one is used to indicate a line break. If we use this between a string it will break and go to another line. \t - This acts as a tab space. \\ - We can print a backward slash with this. Why it happen?? Think.! Now you need to do experiments with those. Do it yourself. Next we have another problem. This string also uses a quote inside it. But it's not produce an error. print ("this code's syntax is OK. But why?") This is because hear we have used different quotation marks for indicate the string. If we want to make a comment we use '#' symbol. In a previous tutorial I have explained you why we use comments in our programs. Also we can use triple quotes for a multi line code. This is very helpful when we want to disable a code block for debugging purpose.

Code:


[size=small]Code:
[/size]
Code:
Please, Log in or Register to view codes content!



Finally I have listed another way to print a string. Hear we don't use parentheses. But this way is not correct in python 3.x version.

Code:


[size=small]Code:
[/size]
Code:
Please, Log in or Register to view codes content!


[size=small][size=small]So it's a good programming practice to always use first method for python printing. Because it's important to learn both versions of python.
[/size][/size]
Thanks for the tips sir!
 
Y 0

Ylazirus

Transcendent
BANNED
Member
Access
Joined
Mar 8, 2023
Messages
40
Reaction score
3
Points
8
Age
32
Location
Manila
grants
₲168
2 years of service
Hello guys, I started a basic tutorial serious on Python . Hear I'm going to explain many theoretical and practical stuff in python programming. I'll explain basic things and also some deep stuff like object oriented programming, Ctypes, Network programming etc.

Printing is an absolutely basic part of a programming language. We learned how we can print a string with PHP and C. So in this tutorial we are going to talk about python printing. Hear I explain you both python 2 and 3. Let's see following program.





Code:
Please, Log in or Register to view codes content!


[size=small] First thing to understand is syntax of printing something. print ('string goes hear') We can use print() function to do this. You want to put the string as the argument for that function. (I'll explain more about functions in a later tutorial). What if you include a quot in your string? It will disturb Python's syntax.
[/size]


[size=small][size=small][size=small]Code:
[/size][/size][/size]
Code:
Please, Log in or Register to view codes content!



In next line I opened a nano editor and corrected the error. After I ran it again and its working fine. So what the magic happened hear when we used a backward slash? Its a escape symbol. That mean when python interpreter see a backward slash it'll ignore next character. Actually this is not a ignoring. It think next character is a specific one and should not printed normally. Also there are some other escape characters . We use those sometimes in our programs. \n - This one is used to indicate a line break. If we use this between a string it will break and go to another line. \t - This acts as a tab space. \\ - We can print a backward slash with this. Why it happen?? Think.! Now you need to do experiments with those. Do it yourself. Next we have another problem. This string also uses a quote inside it. But it's not produce an error. print ("this code's syntax is OK. But why?") This is because hear we have used different quotation marks for indicate the string. If we want to make a comment we use '#' symbol. In a previous tutorial I have explained you why we use comments in our programs. Also we can use triple quotes for a multi line code. This is very helpful when we want to disable a code block for debugging purpose.

Code:


[size=small]Code:
[/size]
Code:
Please, Log in or Register to view codes content!



Finally I have listed another way to print a string. Hear we don't use parentheses. But this way is not correct in python 3.x version.

Code:


[size=small]Code:
[/size]
Code:
Please, Log in or Register to view codes content!


[size=small][size=small]So it's a good programming practice to always use first method for python printing. Because it's important to learn both versions of python.
[/size][/size]
Thank you! Parang mag shshift na ako to computer sciences
 
Top Bottom