HomePortalFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 Variables in Python

Go down 
AuthorMessage
Compu-Teck Inc.



Posts : 80
Join date : 2010-04-29
Age : 25

PostSubject: Variables in Python   Mon Aug 23, 2010 1:43 pm

Hey, all! It's Compu-Teck back with another Python Tutorial. This tutorial deals with variables (as seen in the title). I have decided to take a leaf out of ESS's book and explain a bit on how the program works. First, this is what it looks like:

Code:
i = 5
print i
i = i + 1
print i

output:

>>>
5
6


What makes this program work is first you are taking the variable "i" and assigning it the value of 5. Then, you are telling Python to print that value. Then, you are taking the variable "i" and adding one, then printing it. I will provide a more in-depth explanation on how this works in a much later tutorial.

You can also assign strings (words) to a variable. For example:

Code:
s = "This is a string!"
print s

Output:

This is a string!


What has happened here is first you are creating a variable simply names "s". Then, you are assigning the string "This is a string!" by putting an =. Don't forget the quotes around the string! Then, you are telling Python to display the value of "s" in the output area. After that, you are done!


Last edited by Compu-Teck Inc. on Thu Aug 26, 2010 8:57 am; edited 1 time in total
Back to top Go down
View user profile
Excimer Sun Software

avatar

Posts : 152
Join date : 2010-05-07
Age : 25
Location : USA

PostSubject: Re: Variables in Python   Tue Aug 24, 2010 10:18 pm

They say mockery is the sincerest form of flattery, and I'm flattered, CTI!Very Happy Good work!Smile
Back to top Go down
View user profile
Compu-Teck Inc.



Posts : 80
Join date : 2010-04-29
Age : 25

PostSubject: Re: Variables in Python   Wed Aug 25, 2010 8:53 am

Glad you approve, ESS!
Back to top Go down
View user profile
gamerboy

avatar

Posts : 37
Join date : 2010-08-27
Age : 33
Location : Germany

PostSubject: Re: Variables in Python   Fri Aug 27, 2010 5:00 pm

Shocked python looks related to another programming language, (yabasic) but its alot more powderful and faster than it (yabasic is for REALLY beginner programmers, but python has some advanced features.)
Back to top Go down
View user profile http://gamerboy8864hacks.freeforums.org
Excimer Sun Software

avatar

Posts : 152
Join date : 2010-05-07
Age : 25
Location : USA

PostSubject: Re: Variables in Python   Sat Aug 28, 2010 9:26 am

Yes. This is part of why I like Python. It has a very gentle learning curve and is very readable, but is also very powerful and flexible language. In fact, a unique thing about Python is that it is a completely Object-Oriented language, but one doesn't have to use OOP in their programs unless they want to.Smile
Back to top Go down
View user profile
Compu-Teck Inc.



Posts : 80
Join date : 2010-04-29
Age : 25

PostSubject: Re: Variables in Python   Mon Aug 30, 2010 9:00 am

gamerboy wrote:
Shocked python looks related to another programming language, (yabasic) but its alot more powderful and faster than it (yabasic is for REALLY beginner programmers, but python has some advanced features.)

This is because Python is considered a mid-level programming language (I think).
Back to top Go down
View user profile
Excimer Sun Software

avatar

Posts : 152
Join date : 2010-05-07
Age : 25
Location : USA

PostSubject: Re: Variables in Python   Wed Sep 01, 2010 1:15 pm

It's a highly advanced programming language if you want it to be and know how to use it that way. Smile That's part of why I like it. It's great for beginners, but also powerful enough for advanced users as well.
Back to top Go down
View user profile
Compu-Teck Inc.



Posts : 80
Join date : 2010-04-29
Age : 25

PostSubject: Re: Variables in Python   Fri Sep 03, 2010 8:54 am

Exactly...
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: Variables in Python   

Back to top Go down
 
Variables in Python
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Compile Crazy :: Programming :: Python :: For Beginners-
Jump to: