Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60782

Re: Need help with programming in python for class (beginner level)

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <dualbus@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'operator': 0.03; 'received:198': 0.07; 'subject:help': 0.08; 'string': 0.09; 'converted': 0.09; 'operator,': 0.09; 'cc:addr :python-list': 0.11; 'random': 0.14; '"your': 0.16; 'assignment.': 0.16; 'be:': 0.16; 'concatenate': 0.16; 'dice': 0.16; 'l\xc3\xb3pez': 0.16; 'str()': 0.16; 'subject:beginner': 0.16; 'subject:class': 0.16; 'subject:programming': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'addition,': 0.20; 'seems': 0.21; 'command': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'integer': 0.24; 'string,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'along': 0.30; "i'm": 0.30; 'work.': 0.31; 'lines': 0.31; 'that.': 0.31; 'alan': 0.31; 'directly,': 0.31; 'up.': 0.33; 'fri,': 0.33; 'trouble': 0.34; 'subject: (': 0.35; 'subject:with': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'dies': 0.36; 'like,': 0.36; 'done': 0.36; "didn't": 0.36; 'two': 0.37; 'nov': 0.38; 'either': 0.39; 'called': 0.40; 'from:charset:utf-8': 0.61; 'content-disposition:inline': 0.62; 'email addr:gmail.com': 0.63; 'subject:Need': 0.64; 'school': 0.64; 'total': 0.65; 'to:addr:gmail.com': 0.65; 'eduardo': 0.84; 'or:': 0.84; 'rolls': 0.84; 'do:': 0.91; 'write:': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=fCnZZ8ZOw7ZgjwWWaWvdhh+cY6Et/eycT4PnpVtitq4=; b=0nUeZpEstp69cIf2nGAoaKB0IExeRpb1mTdDA1Ok020LIVJ0//Nsb2wClL2wl/9JsE dp43fEStbtyRvEHHwe/4LmYf9phCZXN9KZoGiJu5EOp8hSFynzGIXxaksb+vcubkp8J5 ay71uJLYjQ4kDJyEfTpfEthwww2fhk3WJyTHGA2NR3lLDpdi7cleUSHpyiYEg82EdvJi ksWfTRfb1ZFp5eTQDDWDQE/w1a2GfdQ1G89ztXmdXKAxXO45woOFP4CAtxKpYMqmqp+N j//moxRoF9XZJIgsKjMyja6ycra3msuqJWLUW+n4lLwbM2OuiXh1r7ZpSMtWSsJ3h2aD KYpQ==
X-Received by 10.66.249.134 with SMTP id yu6mr55304414pac.37.1385772347027; Fri, 29 Nov 2013 16:45:47 -0800 (PST)
Date Fri, 29 Nov 2013 16:45:44 -0800
From Eduardo A. Bustamante López <dualbus@gmail.com>
To farhanken@gmail.com
Subject Re: Need help with programming in python for class (beginner level)
References <e9d18514-1da5-471a-bf39-5f67d3d8fef7@googlegroups.com>
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Disposition inline
Content-Transfer-Encoding 8bit
In-Reply-To <e9d18514-1da5-471a-bf39-5f67d3d8fef7@googlegroups.com>
User-Agent Mutt/1.5.21 (2010-09-15)
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3409.1385772355.18130.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385772355 news.xs4all.nl 15878 [2001:888:2000:d::a6]:51226
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60782

Show key headers only | View raw


On Fri, Nov 29, 2013 at 04:31:21PM -0800, farhanken@gmail.com wrote:
> It's for a school assignment. Basically, I need to roll 5 dies with 6 sides each. So basically, 6 random numbers. That part is easy. Then I need to add it up. Ok, done that. However, I also need to say something along the lines of "your total number was X". That's what I'm having trouble with. I added the dice rolls together and put them into a variable I called "number" but it seems to glitch out that variable is in any command other than "print number". Like, if I try to write:
> 
> print "<p>your total number was:" number "</p>" 
> 
> It just doesn't work. 
That would be: print "<p>your total number was" + str(number) + "</p>"

Notice two differences:

- Used the + operator to concatenate two strings: "foo" + "bar" == "foobar"
- Converted the number from integer to string, you can't do: <int> +
  <str> directly, you have to either int(<str>) + <int> if you want to do
  an integer addition, or: str(<int>) + <str>, if you want string
  concatenation.

You didn't use an operator, and «"string" variable "string"» is not
valid python.

-- 
Eduardo Alan Bustamante López

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Need help with programming in python for class (beginner level) farhanken@gmail.com - 2013-11-29 16:31 -0800
  Re: Need help with programming in python for class (beginner level) Johannes Findeisen <mailman@hanez.org> - 2013-11-30 01:38 +0100
  Re: Need help with programming in python for class (beginner level) Eduardo A. Bustamante López <dualbus@gmail.com> - 2013-11-29 16:45 -0800
  Re: Need help with programming in python for class (beginner level) Johannes Findeisen <mailman@hanez.org> - 2013-11-30 01:49 +0100
  Re: Need help with programming in python for class (beginner level) Tim Chase <python.list@tim.thechases.com> - 2013-11-29 18:53 -0600
  Re: Need help with programming in python for class (beginner level) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-30 00:59 +0000
  Re: Need help with programming in python for class (beginner level) Tim Chase <python.list@tim.thechases.com> - 2013-11-29 19:06 -0600
  Re: Need help with programming in python for class (beginner level) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-30 01:08 +0000
  Re: Need help with programming in python for class (beginner level) Johannes Findeisen <mailman@hanez.org> - 2013-11-30 02:16 +0100
  Re: Need help with programming in python for class (beginner level) Julio Schwarzbeck <julio@techfuel.net> - 2013-12-01 17:01 -0800

csiph-web