Code Point
September 08, 2010, 05:18:40 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Geshi Sintax Hilighting Mod Installed. Tens of languages available.
Home
Help
Search
Login
Register
Code Point
>
Client Side
>
Python
(Moderator:
Alter Lobo
) >
cant figure out whats wrong
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: cant figure out whats wrong (Read 4273 times)
bojak71730
Jr. Member
Karma: 0
Offline
Posts: 10
cant figure out whats wrong
«
on:
February 06, 2007, 12:53:53 AM »
Suppose that you want to compare the cost per megabyte of two Hard Drives and print them. The price for the 80GB model is U$100 and the price for the 120GB model is US$115
Hints: Create the names price and capacity, attribute values to then and print
i was trying to do this and i cant figure it out
Logged
Alter Lobo
Global Moderator
Jr. Member
Karma: 10
Offline
Posts: 65
Re: cant figure out whats wrong
«
Reply #1 on:
February 06, 2007, 11:24:36 AM »
Post what you have tried so far so we can help you.
«
Last Edit: February 06, 2007, 11:29:07 AM by Alter Lobo
»
Logged
bojak71730
Jr. Member
Karma: 0
Offline
Posts: 10
Re: cant figure out whats wrong
«
Reply #2 on:
February 06, 2007, 11:07:59 PM »
hdd1 = 100
hdd2 = 115
print hdd1, -, hdd2, =" "
says its invalid
«
Last Edit: February 06, 2007, 11:14:44 PM by bojak71730
»
Logged
Alter Lobo
Global Moderator
Jr. Member
Karma: 10
Offline
Posts: 65
Re: cant figure out whats wrong
«
Reply #3 on:
February 06, 2007, 11:20:40 PM »
Try this:
Code
hdd1 =
100
hdd2 =
115
print
hdd1,
'-'
, hdd2,
'='
, hdd1 - hdd2
Logged
bojak71730
Jr. Member
Karma: 0
Offline
Posts: 10
Re: cant figure out whats wrong
«
Reply #4 on:
February 06, 2007, 11:26:28 PM »
that made it do - 115 = -15 ur tryin to find the difference which is 15 but im tryin to get it to do the math for me
Logged
jsheedy
Jr. Member
Karma: 1
Offline
Posts: 7
Re: cant figure out whats wrong
«
Reply #5 on:
February 19, 2007, 05:17:03 AM »
I have never done anything with python, but from the short bit of the tutorial I have gone through I am not sure that someone without some type of programming would be able to get it.
for example
>>> capacity = 80
>>> price = 100
>>> print "results: ", capacity/price
result =0
price is an integer I am guessing not a really number, so the result would be 0
only when I changed it to price=100.00, would it work.
Not sure if there is some other way around it, heck I don't even program.
Logged
jsheedy
Alter Lobo
Global Moderator
Jr. Member
Karma: 10
Offline
Posts: 65
Re: cant figure out whats wrong
«
Reply #6 on:
February 20, 2007, 10:24:16 AM »
The precision of the result will be that of the most precise operand. If you want floating point precision then at least one of the operands must be a float.
This page at the beginning of the tutorial touches this matter:
http://programming-crash-course.com/the_calculator
Also take a look at this:
http://programming-crash-course.com/integer_versus_float_division
Logged
jsheedy
Jr. Member
Karma: 1
Offline
Posts: 7
Re: cant figure out whats wrong
«
Reply #7 on:
February 20, 2007, 01:59:40 PM »
Quote from: Alter Lobo on February 20, 2007, 10:24:16 AM
The precision of the result will be that of the most precise operand. If you want floating point precision then at least one of the operands must be a float.
This page at the beginning of the tutorial touches this matter:
http://programming-crash-course.com/the_calculator
Well that makes sense.
Quote from: Alter Lobo on February 20, 2007, 10:24:16 AM
Also take a look at this:
http://programming-crash-course.com/integer_versus_float_division
I will have to do that, thanks
Logged
jsheedy
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Announcements
-----------------------------
=> Announcements
-----------------------------
Client Side
-----------------------------
=> Python
-----------------------------
Server Side
-----------------------------
=> Web Python
=> PHP
-----------------------------
Test
-----------------------------
=> Test
Loading...