Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

looking for a python-tutorial

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
jalu
Posts: 1389
Joined: 2008-11-19 23:26

looking for a python-tutorial

#1 Post by jalu »

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

Lavene
Site admin
Site admin
Posts: 4958
Joined: 2006-01-04 04:26
Location: Oslo, Norway

#2 Post by Lavene »

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 ;)

jalu
Posts: 1389
Joined: 2008-11-19 23:26

#3 Post by jalu »

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

pentode
Posts: 173
Joined: 2007-05-04 22:48

#4 Post by pentode »

This might provide a little diversion:

http://www.openbookproject.net/py4fun/

User avatar
Joel
Posts: 215
Joined: 2007-11-16 14:29
Location: Tijuana, BC, México

Re: looking for a python-tutorial

#5 Post by Joel »

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.

jalu
Posts: 1389
Joined: 2008-11-19 23:26

#6 Post by jalu »

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

User avatar
Joel
Posts: 215
Joined: 2007-11-16 14:29
Location: Tijuana, BC, México

#7 Post by Joel »

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
Dargor
Posts: 653
Joined: 2006-08-14 08:54
Location: New Zealand, Hamilton

#8 Post by Dargor »

Dont forget the official documentation, its brilliant.
http://www.python.org/doc/

jalu
Posts: 1389
Joined: 2008-11-19 23:26

#9 Post by jalu »

@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

clungtech01
Posts: 1
Joined: 2009-02-07 03:24

#10 Post by clungtech01 »

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:

didi
Posts: 901
Joined: 2007-12-04 16:26
Location: the Netherlands

#11 Post by didi »

A whole list of tutorials can be found here:

http://wiki.python.org/moin/BeginnersGuide/Programmers

benjeminfraklin
Posts: 1
Joined: 2019-04-02 10:05

Re: looking for a python-tutorial

#12 Post by benjeminfraklin »

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.

arochester
Emeritus
Emeritus
Posts: 2435
Joined: 2010-12-07 19:55
Has thanked: 14 times
Been thanked: 54 times

Re: looking for a python-tutorial

#13 Post by arochester »

@benjeminfraklin

Did you notice that this post is 10 years old?

Post Reply