Anyone want to learn python? Or help me learn?

Status
Not open for further replies.

ShippoFox

Est. Contributor
Messages
3,068
Role
  1. Adult Baby
  2. Diaper Lover
  3. Babyfur
  4. Diaperfur
  5. Little
  6. Other
I've been reading up a bit about it online over the past few weeks and I've made a few minor programs that run from a command prompt. I know learning a programming language can be kinda hard, but does anyone here want to learn? We could help each other out. Or uh... if no one wants to, is there anyone that could help me? I'm doing pretty well, but it would be nice to have someone to talk to about it. It's just easier to learn stuff when not doing so alone. I have one friend that wants to learn, but he seems to be going at a pretty slow pace. So does anyone want to help me? or does anyone actually want to learn together....? :sweatdrop:
 

mizzycub

Est. Contributor
Messages
1,615
Role
  1. Adult Baby
  2. Diaper Lover
  3. Babyfur
I'd be interested in learning with you, though for me it would be pretty much from scratch. I've downloaded it, but I haven't actually done anything with it yet, so I would be starting from behind you. But yeah, I'd be more then willing to learn it with you - just you may need to help me to begin with until I have gotten up to where you are. There is always someone who knows even less than you!
 

recovery

Est. Contributor
Messages
1,234
Role
  1. Other
I'm sure you've seen my very simple Mzk cypher plugin for Xchat.

Tell me what you have learned exactly and I'll see if I can find a suitable challenge that will be possible for you to do. Yet remain a bit of a challenge. right? ~

What variable types have you dealt with? Done for or while loops yet? Learnt how to create functions?

I'd be more than willing to help. Just give us a shout when you got a question.

OK, I made *another* prime number finding script. This time. It took me a couple of minutes rather than a couple of hours on my first PHP script years ago.
PHP:
# This will simply try to find prime numbers

#Initilise
#We'll guess that 2 is a prime already and start testing numbers from 2, our 
# 'subject'. This value will hold our currently tested number to see if it is
# a prime.
primelist = [2]
subject = 2

#for each subject

while 1:
	#Is it prime?
	#Result is a boolean value given to say whether the current subject
	#number is a prime or not
	result = True
	
	#This will put each number in the list primelist into the variable prime.
	# 'for each' number in the primelist. It will run through that code.
	# It's pseudo code!
	for prime in primelist:
		
		#Check if the prime devides by our subject test number or not.
		if subject%prime == 0:
			#It looks like that it devided perfectly with a known prime
			result = False
			# Speed things up a little. Why work out all the other primes when
			# it's not really needed?.
			# It breaks the loop and stops. Exiting the loop and ignoring all
			# other values in the primelist that it has yet to test.
			break

	#If it was a prime, result would stay True.
	if result:
		
		#We append the list to add our newly found prime onto the end of our 
		# prime list!
		primelist.append(subject)
		print subject 
	
	#Make sure our next subject is one bigger! for the next time round in 
	#the loop
	subject +=1
	
	# this just stops the code once I found all primes upto 100,
	# But not including 100. Otherwise we'll be in a infinte loop!
	if subject == 100:
		break

But the extra commenting took awhile longer to do.
 
Last edited by a moderator:

chevre

Est. Contributor
Messages
1,434
Role
  1. Diaper Lover
I personally love Python. I'd be glad to help if you have questions.
 

Squigma

Est. Contributor
Messages
488
Role
  1. Babyfur
I tried learning it a while ago. Well, I started learning C++, but that was a bit to confusing for me so I stopped. After a while I tried again, but it was still a bit complicated so I switched to python and it seemed a lot simpler.

I worked out how to do some stuff, but in the end I just wasn't motivated enough because I couldn't think of anything to do with it, and I'm never sure if I'm doing it right when I'm learning something from the internet. But I think if I was learning with someone else I would actually keep doing it, rather than get bored and give up quickly.

So, to summarize: yeah, I'd love to learn it with you!
 

Hex

Est. Contributor
Messages
1,215
Role
  1. Adult Baby
  2. Diaper Lover
  3. Babyfur
  4. Sissy
[font="Calibri,Arial"]My experience with Python is like this:

Me - "What's it like"
Python Programmer - "It's like C but whitespace affects the program"
Me - "Sensitive to whitespace? meh"
[/font]
 

recovery

Est. Contributor
Messages
1,234
Role
  1. Other
[font="Calibri,Arial"]
Me - "What's it like"
Python Programmer - "It's like C but whitespace affects the program"
Me - "Sensitive to whitespace? meh"
[/font]

Hah! Yeah, typically you encapsule code in {} curly brackets or what you call them. With python, its on the indentation 'whitspace'. And A tab is different to a couple of spacebars. So you have that to consider as well. But you either typically stick to one or the other.
 

chevre

Est. Contributor
Messages
1,434
Role
  1. Diaper Lover
I never understood why people care so much about the whitespace thing. I mean, if you already properly indent your code, then what difference does it make? Plus a good editor (I use emacs) will automatically indent in for you and cycle through different indentation levels when you hit tab.
 

Pojo

Est. Contributor
Messages
5,919
Role
  1. Private
Am I the only one who thought this thread about learning Parseltoungue like in Harry Potter? >.>
 

ShippoFox

Est. Contributor
Messages
3,068
Role
  1. Adult Baby
  2. Diaper Lover
  3. Babyfur
  4. Diaperfur
  5. Little
  6. Other
Wow, I didn't expect so many people would want to take the offer! I thought I'd be lucky to get one person to learn along with me! Maybe I should have auditions! :laugh: Just kidding. We should figure something out though. Maybe we could all help each other? Then we have the more experienced programmers to help us if we really get stuck. Just have to make sure we're all using 3.0. Not everything is converted or written in Python 3.0 yet, but it's the newest version, so it's best to go with it. I don't think it'd be too hard to write old code after learning the new version anyway. Most of the differences are relatively minor, even though backward compatibility is broken.

mzkkbprmt: That comic was pretty amusing! :laugh:

I tried learning it a while ago. Well, I started learning C++, but that was a bit to confusing for me so I stopped. After a while I tried again, but it was still a bit complicated so I switched to python and it seemed a lot simpler.

I worked out how to do some stuff, but in the end I just wasn't motivated enough because I couldn't think of anything to do with it, and I'm never sure if I'm doing it right when I'm learning something from the internet. But I think if I was learning with someone else I would actually keep doing it, rather than get bored and give up quickly.

So, to summarize: yeah, I'd love to learn it with you!

I did the exact same thing with C++. I tried some stuff with it for a while, it got kinda confusing, then I decided to give up on it (for now, not sure if maybe I'll try again someday?) And I'm trying to avoid letting the same thing happen this time. I don't want to give up on Python.

sniper14th said:
My experience with Python is like this:

Me - "What's it like"
Python Programmer - "It's like C but whitespace affects the program"
Me - "Sensitive to whitespace? meh"

Haha! The same thing went through my mind last year! Now that I've actually tried it though, it's not such a bad thing! It forces people to make their code at least slightly more organized. People should probably indent even in C++, but it's not necessary, so not everyone does so. I don't think I did. Anyway, here's something interesting about how the interpretation of whitespace can be somewhat flexible sometimes....
http://www.secnetix.de/~olli/Python/block_indentation.hawk

Unmarth: I know for, while, and if statements. Functions too. I sorta already knew them from C++, though I could use some practice. I know some other stuff as well. I've just started brushing over exceptions. Hmm.... Some stuff I looked up, sorta skipping ahead, because I was curious about it (like randint and isdigit). There's some stuff I understand, but am having a hard time actually applying it in coding (a lot of the data structures are very easy to understand, but difficult to apply so far). I know enough that I could have wrote that prime number script myself if I really tried. Though there's one problem with it in Python 3.0. It would have to be print(subject) because of the changes they made to the language.

Pojo: I guess so. I haven't really followed Harry Potter, though it seems interesting.

Anyway.... where to start....

Get Python 3.0
http://www.python.org/download/releases/3.0/

There is a tutorial here....
Overview — Python v3.0 documentation
Here's another one....
Python en:Table of Contents - Notes

Here's a tip. Any question is a good question. No question is too stupid.
I can give out my IM names, but not out in public on the forum.
 
Last edited:

IncompleteDude

Est. Contributor
Messages
1,083
Role
  1. Private
I dunno why people say C++ is confusing. I mean look at this code of mine. It's so intuitive!
Code:
template<class CounterName, int Iteration, class DoNotUse=void>
struct tBases : public tBases<CounterName, Iteration-1> {};

template<class CounterName, int Iteration>
struct tBases<CounterName, Iteration, typename enable_if_c<Iteration<=1>::type> {};

template<class CounterName, int CallNumber, class DoNotUse=void>
struct tIncrement
{
    template<class DoNotUse>
    friend typename ::tIncrement<CounterName, CallNumber+1, DoNotUse>::tInt Count(tBases<CounterName, CallNumber, DoNotUse>& A)
    {
        return tIncrement<CounterName, CallNumber+1, DoNotUse>::tInt();
    }

    typedef int_<CallNumber-1> tInt;
};

template<class CounterName>
typename tIncrement<CounterName, 2>::tInt Count(tBases<CounterName, 1>& A)
{
    return tIncrement<CounterName, 2>::tInt();
}

template<class CounterName>
typename int_<0> Count(tBases<CounterName, 0>& A)
{
    return int_<0>();
}

//The following is only necessary because MSVC doesn't have typeof
template<tUInt32 Size>
class tHasSizeof
{
    char Array[Size];
};

template<int value>
tHasSizeOf<value> GetValue(int_<value>) { return tHasSizeOf<value>(); };

//Example usage
class myCounter{};
tBases<myCounter, 100> er; //100 being the counter's maximum possible value. In MSVC, I recall 499 being the largest possible number.
templateClass<sizeof(GetValue(Count(er)))> templateClass0;
templateClass<sizeof(GetValue(Count(er)))> templateClass1;
templateClass<sizeof(GetValue(Count(er)))> templateClass2;
//etc...
Note that int_ is just an integer wrapper class from Boost, and enable_if_c is another simple Boost metaprogramming utility. Also, I'm certain this is not standard compliant code, because of the shameless abuse of global function overloading via friend functions to introduce mutability into template programming, but it does work in MSVC 9.0. I also realize that my tHasSizeOf class may not always work as expected because of padding, but it's just a cheap hack.

For those of you that might be interested, this came out of an investigation into the use of template functions instead of template classes for metaprogramming. Although, I never created a template function metaprogramming library, I do think it's definitely possible and has many significant advantages. For example, you get template parameter deduction, you can exploit overloading, and you can write your metafunctions as actual functions. It may also be possible to write basic functions such as "swap" that can operate at both compile and run time. As part of this, I also wrote another utility class called CompileTest, which I used to investigate the order classes and functions are compiled, which was quite illuminating. Basically, it would print the name of the type passed to it via template parameters by declaring a static whose constructor did the printing. In my testing, this preserved the order in which each CompileTest use was encountered. Again, only tested on MSVC 9.0.

But I dunno, it was just an experiment from long ago.

As for Python, I'll learn it eventually...
 
Last edited:

recovery

Est. Contributor
Messages
1,234
Role
  1. Other
Given that python 3 came out only two or so months ago. It's pretty new. And if you want to get the best I would say to stick with the 2.x series. Because thats what I've been taught to use and what I'm expected to use on my course!

Although I should look up the differences one day >_>. It would help in the future when 3 slowly dominates.
 

tbjay

Est. Contributor
Messages
196
Role
  1. Adult Baby
  2. Diaper Lover
  3. Little
Almost. Well, close enough. : P
[/pothole]

Almost again Pojo *bows*

I had some hopes.....


I want to learn C++ but Python is new

ANYTHING related to computers to be passed on to me is good

I need a real skill that'll help me survive...writing and music is apparently for the lame...... *tear*

I'm getting A+ Certifcation next semester though.
 

Squigma

Est. Contributor
Messages
488
Role
  1. Babyfur
I know there's already I built in function to do it, but I just made this function to find the biggest number in a list of numbers. When I discovered functions could call themselves and it would iterate, this was the first way that popped into my head to try it out.

And I figured I'd post it here for two reasons: 1. To demonstrate the extent of what I can do (I know very little other than what I've done here) and 2. Thought it seems to work, I'm sure there's a better way to do it and I was wondering if the more knowledgeable people thought this way was any good at all.


PHP:
def biggestnumber(numbers):
    if len(numbers) == 1:
        return numbers[0]
    if len(numbers) == 2:
        if numbers[0]>numbers[1]:
            return numbers[0]
        else:
            return numbers[1]
    elif biggestnumber(numbers[0:(len(numbers)-1)]) > numbers[len(numbers)-1]:
        del numbers[len(numbers)-1]
        return biggestnumber(numbers)
    else:
        return numbers[len(numbers)-1]
 

ShippoFox

Est. Contributor
Messages
3,068
Role
  1. Adult Baby
  2. Diaper Lover
  3. Babyfur
  4. Diaperfur
  5. Little
  6. Other
Incomplete Dude: I thought you were being sarcastic at first. Anyway, I dunno why C++ seems much more confusing. It just... does.

Given that python 3 came out only two or so months ago. It's pretty new. And if you want to get the best I would say to stick with the 2.x series. Because thats what I've been taught to use and what I'm expected to use on my course!

Although I should look up the differences one day >_>. It would help in the future when 3 slowly dominates.

Here's the page that says what's new...

What’s New In Python 3.0 — Python v3.1a0 documentation

I still think it's probably better to learn the new ways and then adapt to the old ways if/when necessary. The other way around for you because of the class and because you already know how to do stuff the old way. The differences aren't too major anyway.

Jack26: I might try to remake that. I'm not sure, but a for loop might work well there somewhere (maybe).

Well... I found a really easy way to do it...

h=[9,7,22,0,3]
j=h # to avoid losing the old order of the list
h.sort() #sorts list from lowest to highest numbers
h.reverse() #reverses it so that the first number is the largest
print(h[0]) #print the number
h=j # once again, it's not completely necessary

It could be turned into a function. Though I was hoping to figure out a way to use a for loop, or to cut out your first two if statements. And I think maybe what I found is just the built in way you mentioned.
 
Last edited:

IncompleteDude

Est. Contributor
Messages
1,083
Role
  1. Private
I know there's already I built in function to do it, but I just made this function to find the biggest number in a list of numbers. When I discovered functions could call themselves and it would iterate, this was the first way that popped into my head to try it out.
Pretty much any programming language can do that. It's call recursion or recursive functions. However, problems can occur if your recursive calls go too deep, creating a stack overflow error (stack being were local/function variables/parameters are stored). Some languages support what's called tail recursion to avoid this, which basically means the recursive function call does not execute until the calling function finishes. This way no extra stack is used.
 

chevre

Est. Contributor
Messages
1,434
Role
  1. Diaper Lover
The nice thing is that in python, a stack overflow shows up as an Exception, as opposed to a crash. So, they can be handled and dealt with, and the max depth can even be changed dynamically.

As for your biggestnumber function -- python has a built in max() that you can use on iterables :p. So, I'd just use that.
 

mizzycub

Est. Contributor
Messages
1,615
Role
  1. Adult Baby
  2. Diaper Lover
  3. Babyfur
I got bored yesterday so I made this. I intended it to run by clicking it and it opening up, as opposed to with IDLE or anything like that - so that explains the last line. Anyone spot anything I could do to improve it, if so please say!

PHP:
print"This program finds Fibonacci numbers F(n), for any given values for F(1) and F(2), where n is greater then 2\n"           
f1 = input("F(1):")
f2 = input("F(2):")
fcount = 2
fsearch = input("\nn:")
assert fsearch > 2, "n must be greater than two" 
while fcount <= fsearch:
    fcount += 1
    f3 = f2 + f1
    if fcount == fsearch:
        print "F(" + str(fsearch) + ") is " + str(f3)
    f1 = f2
    f2 = f3
input("\nPress a key to end program")

Been as the person running it sets F(1) and F(2) it can't find those. Well the actual reason was I couldn't produce a loop to find those as well and it isn't really necessary. If someone could make a loop for all values of F(n) with n 1 all higher I would be really thankful, but it isn't necessary.

Also: sample photo

fibo.gif
 
Status
Not open for further replies.
Top