Random Homebrew: Boggle
You try to make words by letters that are touching each other.

A few questions regarding Python?

Discuss about your favorite (gaming...or not) devices here. The most popular ones will end up getting their own categories
Programming discussions for your favorite Device

A few questions regarding Python?

Postby Tonakai » Tue Dec 25, 2012 6:25 pm

Advertising
Hey guys. I've recently started learning Python from a book, and using the tutorials on this site, but I'm kind of curious about a few things. From the information I've read, I can't quite get a clear answer;

I understand Tuples to be a form of list that isn't modifiable in the same way that a list is (i.e removing or adding items), so what would be the benefit of using them? Surely using a list would be more beneficial most of the time as they can be modified to suit whatever purpose at the time? I also read about turning integers into strings, what would the point of this be when you could easier create a string and keep them separate?

Also, when creating a for loop, would I be correct in assuming that you set the variable during the line of code, so it could be anything at all? for example:

Code: Select all
for variable_possibly in example_list:
    print:(variable_possibly)


Sorry if my questions are ridiculous, but I've only been learning for about a week, so I'm incredibly green. Cheers for your time.

Edit: There may be more questions as I continue learning. :shock:

Edit2: I've done my research and found my answers. Though, I still may ask other questions in future.
PSP 1003; 6.60 ME, PSP GO; 6.20 PRO-C, PSVita; 2.02 Uno. Replacement was updated by friend's sibling to latest firmware, ho hum. :(
PS1; Mod Chip. PS2; FreeMcBoot V1.8, PS3; 3.55 Kmeaw, Wii 4.3e Letterbomb Mod. Xbox; Xecuter 3 & SC Softmod.
User avatar
Tonakai
 
Posts: 588
Joined: Sun Aug 05, 2012 3:00 am
Location: United Kingdom.

Re: A few questions regarding Python?

Postby Acid_Snake » Thu Dec 27, 2012 7:21 pm

Advertising
I know you have found your answers but I'll answer the questions anyways in case someone else reads this

Tonakai wrote:I understand Tuples to be a form of list that isn't modifiable in the same way that a list is (i.e removing or adding items), so what would be the benefit of using them?

mostly to define more than one variable in a line of code:
Code: Select all
x, y, z = "this", "that", "whatever"

or for functions that return more than one thing:
Code: Select all
def any_function():
   return 1, 2, 3

and when calling it:
Code: Select all
x, y, z = any_function()


Tonakai wrote:I also read about turning integers into strings, what would the point of this be when you could easier create a string and keep them separate?

mainly to concatenate an integer into a string, if you do this:
Code: Select all
x = "Hello" + 1

python will throw an error, so the correct way would be to convert that integer into a string:
Code: Select all
x = "Hello" + str(1)


Tonakai wrote:Also, when creating a for loop, would I be correct in assuming that you set the variable during the line of code, so it could be anything at all? for example:

yes, when you use the for loop, variable_possibility is defined right there, no need to define it before (and you shouldn't define it before)
"V2h5IGFyZSB5b3UgcmVhZGluZyBteSBzaWduYXR1cmU/\n".decode("base64")
My forum:
Console Heaven
My Homebrews:
pyMenu 0.3.2, multiBootMenu V3, PSvid 3.0, PSP Tools 0.2
User avatar
Acid_Snake
Moderator
 
Posts: 2131
Joined: Tue May 01, 2012 11:32 am
Location: Behind you!

Re: A few questions regarding Python?

Postby onnz423 » Fri Feb 15, 2013 8:46 am

I really want to practice python but im stuck in HTML :D
Image
If i helped you please give me internet :)
User avatar
onnz423
 
Posts: 162
Joined: Sat Dec 29, 2012 4:25 pm
Location: Finland

Re: A few questions regarding Python?

Postby Xian Nox » Fri Feb 15, 2013 1:10 pm

onnz423 wrote:I really want to practice python but im stuck in HTML :D

This makes no sense.
Spoiler
Disturbed0ne wrote:PS. EVERYONE should like girls. they're just so soft. :oops:
User avatar
Xian Nox
Moderator
 
Posts: 6173
Joined: Fri Nov 05, 2010 5:27 pm
Location: /home/xian/n-field

Re: A few questions regarding Python?

Postby onnz423 » Fri Feb 15, 2013 1:32 pm

Xian Nox wrote:
onnz423 wrote:I really want to practice python but im stuck in HTML :D

This makes no sense.


yea i know im very tired :D
Image
If i helped you please give me internet :)
User avatar
onnz423
 
Posts: 162
Joined: Sat Dec 29, 2012 4:25 pm
Location: Finland


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

Friends

Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita