473,394 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Question regarding int

x = input ("Number of Guests: ")
y = input ("Number of beers: ")
print "Full beers per person: " + str(float(y / x))
print "Left over beers: " + str(y % x)
print "Poured into keg and shared: " + str(int(y / x, 3)) +" beer per person"

this is my current python code, i am attempting to get the poured into keg portion to display 3 decimal places but keep getting an error.

Traceback (most recent call last):
File "D:/Charman/GeoProcessing/A2/BeerCalc.py", line 5, in -toplevel-
print "Poured into key and shared: " + str(int(y / x, 3)), +" beer per person"
TypeError: int() can't convert non-string with explicit base

I have been searching and searching for some user friendly advice or tips and I am not too formidable in this language, if anyone can give me some clarification on what im doing wrong I would greatly appreciate it.

thanks
Oct 7 '08 #1
1 2270
bvdet
2,851 Expert Mod 2GB
x = input ("Number of Guests: ")
y = input ("Number of beers: ")
print "Full beers per person: " + str(float(y / x))
print "Left over beers: " + str(y % x)
print "Poured into keg and shared: " + str(int(y / x, 3)) +" beer per person"

this is my current python code, i am attempting to get the poured into keg portion to display 3 decimal places but keep getting an error.

Traceback (most recent call last):
File "D:/Charman/GeoProcessing/A2/BeerCalc.py", line 5, in -toplevel-
print "Poured into key and shared: " + str(int(y / x, 3)), +" beer per person"
TypeError: int() can't convert non-string with explicit base

I have been searching and searching for some user friendly advice or tips and I am not too formidable in this language, if anyone can give me some clarification on what im doing wrong I would greatly appreciate it.

thanks
Please use code tags. See reply guidelines. You can display the calculation to 3 decimal places using string formatting.
Expand|Select|Wrap|Line Numbers
  1. print "Poured into keg and shared: %0.3f beer per person" % (y/float(x))
Oct 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Francis Lavoie | last post by:
Hello I have some questions regarding webframework, I must say that I quite lost and these questions are basicly to help me understand the way it work. I have some knowledge with PHP and JSP....
2
by: Jo_Calico | last post by:
I love the Dynamic Drive cross browser marquee script. I'd like to make the text loop immediately after completion, so the beginning runs right after the end (does that make sense?). Could anyone...
3
by: Samuel | last post by:
I wrote a very simple httpmodule and tried to compile it with no success. This is my code: ============== Imports System Imports System.Web Imports Microsoft.VisualBasic NameSpace...
7
by: Squignibbler | last post by:
Hi all, I have a question regarding the C++ programming language regarding the nature of the relationship between pointers and arrays. If the statement MyArray is functionally identical to...
6
by: rodchar | last post by:
Hey all, I'm trying to understand Master/Detail concepts in VB.NET. If I do a data adapter fill for both customer and orders from Northwind where should that dataset live? What client is...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
14
by: Mr Newbie | last post by:
I am often in the situation where I want to act on the result of a function, but a simple boolean is not enough. For example, I may have a function called isAuthorised ( User, Action ) as ?????...
2
by: Dean R. Henderson | last post by:
For an ASP.NET web application, is there a way for one session (with appropriate security authorization) to set a HttpSessionState variable to point to another session and execute the Abandon...
6
by: Jon | last post by:
All, I'm working in a fairly robust content management system for our company's websites, and have a question regarding the file and directory structure of the site. Currently, I'm populating...
5
by: archana | last post by:
Hi all, I am using timer to do some functionality on user specified time. I am using system.timers.timer class and its timer to do this functionality. What i am doing is i set autoreset to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.