<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
On 3/25/2011 12:27 AM, Lea Parker wrote:
<blockquote cite="mid:000001cbeaad$5ce95b30$16bc1190$@bigpond.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><b><span style="color: rgb(75, 172, 198);">Hello<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="color: rgb(75, 172, 198);"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span style="color: rgb(75, 172, 198);">Just
wondering if you have some time to cast your eyes over
another basic program.</span></b></p>
</div>
</blockquote>
<br>
Donald pointed out the first error. (actually there are 3 such
spelling errors).<br>
<br>
When you get "name xxx is not defined" use your editor's find
feature to find where the name is defined. In this case you would
not find it which should lead you to the problem.<br>
<br>
When you fix that you will then get<br>
TypeError: 'str' object is not callable<br>
on the same line of code.<br>
<br>
Do you see why?<br>
<br>
When you fix that you will then get either<br>
ValueError: invalid literal for int() or<br>
ValueError: int() base must be >= 2 and <= 36<br>
<br>
Before returning with "why" attempt to apply the error message to
the code to see what the problems are.<br>
Look up int() in the Python documentation <br>
<blockquote cite="mid:000001cbeaad$5ce95b30$16bc1190$@bigpond.com"
type="cite">
<div class="WordSection1">
<p class="MsoNormal"><b><span style="color: rgb(75, 172, 198);"><o:p></o:p></span></b></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"># Prompt user for data<o:p></o:p></p>
<p class="MsoNormal">def main():<o:p></o:p></p>
<p class="MsoNormal"> print 'This program is to calculate
your ticket sales to the softball game'<o:p></o:p></p>
<p class="MsoNormal"> print
#blank line<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> # Value of each level of seat<o:p></o:p></p>
<p class="MsoNormal"> a_seat = 15.00<o:p></o:p></p>
<p class="MsoNormal"> b_seat = 12.00<o:p></o:p></p>
<p class="MsoNormal"> c_seat = 9.00<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> # Obtain data<o:p></o:p></p>
<p class="MsoNormal"> sales_a = int (raw_input('Enter the
number of class A tickets sold '))<o:p></o:p></p>
<p class="MsoNormal"> sales_b = int (raw_input('Enter the
number of class B tickets sold '))<o:p></o:p></p>
<p class="MsoNormal"> sales_c = int (raw_input('Enter the
number of class C tickets sold ')) <o:p></o:p></p>
<p class="MsoNormal"> income_generated(a_seat, b_seat,
c_seat, sales_a, sales_b, sales_c)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"># Obtain data to determine income generated
from sales<o:p></o:p></p>
<p class="MsoNormal">def income_generated(a_seat, b_seat,
c_seat, sales_a, sales_b, sales_c):<o:p></o:p></p>
<p class="MsoNormal"> total_sales = """times the seat value
by the number of seats sold for each seat<o:p></o:p></p>
<p class="MsoNormal"> and add totals togeter"""(sale_a *
a_seat) + (sale_b * b_seat) + (sale_c * c_seat)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> #Display result to user<o:p></o:p></p>
<p class="MsoNormal"> print int ('Your total sales for the
softball game are: $ ', total_sales)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"># Call the main function<o:p></o:p></p>
<p class="MsoNormal">main()<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><span style="color: rgb(75, 172, 198);">I
get the following errors:<o:p></o:p></span></b></p>
<p class="MsoNormal">>>>
================================ RESTART
================================<o:p></o:p></p>
<p class="MsoNormal">>>> <o:p></o:p></p>
<p class="MsoNormal">This program is to calculate your ticket
sales to the softball game<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Enter the number of class A tickets sold 5<o:p></o:p></p>
<p class="MsoNormal">Enter the number of class B tickets sold 5<o:p></o:p></p>
<p class="MsoNormal">Enter the number of class C tickets sold 10<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Traceback (most recent call last):<o:p></o:p></p>
<p class="MsoNormal"> File "F:/Backups/MY
Documents26.2.11/Documents/Lea University/CSU/ITC10 -
Programming Principles/2011/Assessment Tasks/Assessment 1b and
1c/Stadium_Seating.py", line 29, in <module><o:p></o:p></p>
<p class="MsoNormal"> main()<o:p></o:p></p>
<p class="MsoNormal"> File "F:/Backups/MY
Documents26.2.11/Documents/Lea University/CSU/ITC10 -
Programming Principles/2011/Assessment Tasks/Assessment 1b and
1c/Stadium_Seating.py", line 18, in main<o:p></o:p></p>
<p class="MsoNormal"> income_generated(a_seat, b_seat,
c_seat, sales_a, sales_b, sales_c)<o:p></o:p></p>
<p class="MsoNormal"> File "F:/Backups/MY
Documents26.2.11/Documents/Lea University/CSU/ITC10 -
Programming Principles/2011/Assessment Tasks/Assessment 1b and
1c/Stadium_Seating.py", line 23, in income_generated<o:p></o:p></p>
<p class="MsoNormal"> and add totals togeter"""(sale_a *
a_seat) + (sale_b * b_seat) + (sale_c * c_seat)<o:p></o:p></p>
<p class="MsoNormal">NameError: global name 'sale_a' is not
defined<o:p></o:p></p>
<p class="MsoNormal">>>><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><span style="color: rgb(75, 172, 198);">My
way of thinking is firstly I need to fix line 29 which is
main(), I tried to do this by adding the brackets around
text output in line 26. This seemed to allow me to type
main against margin rather than it wanting to indent but
didn’t fix the problem. Your suggestions would be
appreciated.<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="color: rgb(75, 172, 198);"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span style="color: rgb(75, 172, 198);">Thank<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="color: rgb(75, 172, 198);">Lea<o:p></o:p></span></b></p>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Tutor maillist - <a class="moz-txt-link-abbreviated" href="mailto:Tutor@python.org">Tutor@python.org</a>
To unsubscribe or change subscription options:
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Bob Gailer
919-636-4239
Chapel Hill NC</pre>
</body>
</html>