looking for a python-tutorial

Need help with C, C++, perl, python, etc?

looking for a python-tutorial

Postby jalu » 2009-01-27 12:41

hello,
i try to learn python since a few months.
I`m not able to do that much with it:
right now i`m trying to learn def, lambdas, open,close,read, write...
( i haven`t reached the modules yet)

As i`m a bit bored of all those
if a > 7:
while i != 4:
and other things of that kind
i wanted to ask, if there`s an online tutorial
or a book (i`d prefer that)
where you might learn python according to linux?

Or should i move on the way i`m doing it now
(learning the basics by making useless calculations and lists)?

thanks for an advice
jalu
jalu
 
Posts: 1397
Joined: 2008-11-19 23:26

Postby Lavene » 2009-01-27 14:44

I like this one: http://diveintopython.org/
It's aimed at 'experienced programmers' but used together with Google it's quite usable also for beginners. You'll probably still have to do small silly programs to try the stuff out though ;)
Lavene
Site admin
 
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby jalu » 2009-01-27 17:59

thanks Lavene,
i`ll try that one.
i ain`t got a problem doing silly or stupid things now to learn it, but i`m a bit afraid about the future ( in two or three years i would like to do something usefull with it -little scripts- and not just calculation)
thanks again
jalu
jalu
 
Posts: 1397
Joined: 2008-11-19 23:26

Postby pentode » 2009-01-27 19:42

This might provide a little diversion:

http://www.openbookproject.net/py4fun/
pentode
 
Posts: 173
Joined: 2007-05-04 22:48

Re: looking for a python-tutorial

Postby Joel » 2009-01-28 01:07

jalu wrote:As i`m a bit bored of all those
if a > 7:
while i != 4:

Tired of loops and conditional statements? Hehe use them both ;)
Code: Select all
#!/usr/bin/python

# A nice library to use here
import random

# max and min values
valor_min = 1
valor_max = 10

# Generate a random number
magic_number = random.randrange(valor_min, valor_max);

# save user input
u = -1

# loop until user inputs the correct number
while u != magic_number:
   # Print a friendly message :)
   print "I'm a bot, guess my magic number between %i..%i. (note: use zero to end the game)" % (valor_min, valor_max)
   # grab user's value
   u = raw_input('User> ')
   # convert it to integer one
   u = int(u)
   # some tests to do
   if u == magic_number:
      print "You win!"
   elif u == 0:
      print "You aborted the game!"
      break
   else:
      if u < magic_number:
         print "Try again!...Hint: My magic number is bigger than %i." % (u)
      else:
         print "Try again!...Hint: My magic number is smaller than %i." % (u)
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-32b w/ xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: ArchLinux-64b w/ xfce4.
User avatar
Joel
 
Posts: 215
Joined: 2007-11-16 14:29
Location: Tijuana, BC, México

Postby jalu » 2009-01-28 06:03

why do you first let the user do the input as raw_input
and afterwards convert it to an integer?
(i`d spare my fingers 2 lines by:
u = input ("give number:" )
wouldn`t i?)

I was kidding,
i`m not bored by loops and statements,
but by the useless content of them right now right here.

The long-term-goal is to be able to make scripts which are related
to my system
, and not to the users (=i,me) input of numbers-
magic or usual ones.

greetings and thanks
jalu
 
Posts: 1397
Joined: 2008-11-19 23:26

Postby Joel » 2009-01-29 00:08

jalu wrote:why do you first let the user do the input as raw_input
and afterwards convert it to an integer?
(i`d spare my fingers 2 lines by:
u = input ("give number:" )
wouldn`t i?)

Because it's safer.
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-32b w/ xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: ArchLinux-64b w/ xfce4.
User avatar
Joel
 
Posts: 215
Joined: 2007-11-16 14:29
Location: Tijuana, BC, México

Postby Dargor » 2009-01-29 02:13

Dont forget the official documentation, its brilliant.
http://www.python.org/doc/
User avatar
Dargor
 
Posts: 671
Joined: 2006-08-14 08:54
Location: New Zealand, Hamilton

Postby jalu » 2009-01-29 02:56

@Joel:
as i said, i was joking,
i`m aware that i`m not able to decide whats the right and whats the wrong way
in doing things.
But its very good to know, i`ll start doing it that way
(sometimes it seems to be usefull making jokes).

@Dargor:
thanks, i got it in mind.
As i`m a beginner i can`t decide if docus, tutorials etc.
are good or not, so i`m reliant on the info and advices i get.

thanks again,
to all of you
jalu
jalu
 
Posts: 1397
Joined: 2008-11-19 23:26

Postby clungtech01 » 2009-02-07 03:38

thanks Lavene,i`ll try ur link.I have just started out with python and I can say, from what I have seen its a pretty cool language. Always, the tutorial that comes with python leaves me pretty much "huh". So, does anyone know of a good tutorial for learning python? I'm considering buying a book, any ideas on that?
:) :( :o :evil: :twisted:
clungtech01
 
Posts: 1
Joined: 2009-02-07 03:24

Postby didi » 2009-02-07 16:07

A whole list of tutorials can be found here:

http://wiki.python.org/moin/BeginnersGuide/Programmers
Testing (server) + Unstable (workstation) 32-bit on AMD Athlon64 X2
didi
 
Posts: 909
Joined: 2007-12-04 16:26
Location: the Netherlands

Re: looking for a python-tutorial

Postby benjeminfraklin » 2019-04-02 10:28

Hello There,

Joel wrote:
jalu wrote:As i`m a bit bored of all those
if a > 7:
while i != 4:


Tired of loops and conditional statements? Hehe use them both ;)

Code: Select all
#!/usr/bin/python

# A nice library to use here
import random

# max and min values
valor_min = 1
valor_max = 10

# Generate a random number
magic_number = random.randrange(valor_min, valor_max);

# save user input
u = -1

# loop until user inputs the correct number
while u != magic_number:
   # Print a friendly message :)
   print "I'm a bot, guess my magic number between %i..%i. (note: use zero to end the game)" % (valor_min, valor_max)
   # grab user's value
   u = raw_input('User> ')
   # convert it to integer one
   u = int(u)
   # some tests to do
   if u == magic_number:
      print "You win!"
   elif u == 0:
      print "You aborted the game!"
      break
   else:
      if u < magic_number:
         print "Try again!...Hint: My magic number is bigger than %i." % (u)
      else:
         print "Try again!...Hint: My magic number is smaller than %i." % (u)


Thanks for sharing code details but I've asked one question for you can you please tell me this code run which process & second question is that this code run by mac system can you please answer sharing with me & which process to run this code & share details. Otherwise, your any details need you should try Python tutorial & learn all details for python tutorial related otherwise if any question you can ask here.
benjeminfraklin
 
Posts: 1
Joined: 2019-04-02 10:05

Re: looking for a python-tutorial

Postby arochester » 2019-04-02 10:33

@benjeminfraklin

Did you notice that this post is 10 years old?
arochester
 
Posts: 1513
Joined: 2010-12-07 19:55


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable