TRENDING NEWS

POPULAR NEWS

Help With A Python Program

Help with a python program?

I'm no good at figuring out how to add all these together. I can make a program that lists the cubes of all these, but I don't know how to add them. Any help?

Given that n refers to a positive int use a while loop to compute the sum of the cubes of the first n counting numbers, and associate this value with total . Use no variables other than n , k , and total .

Python Program help!!!?

You are to write a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of days worked.

Display a table showing what the salary was for each day, then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies.

Additional Program Requirements:
1. You are to use a function to output the standard header information
2. You are to use a program loop to calculate and print out the amount of pennies, and accumulate a total amount of earnings. (recommend a for loop)
3. You are to use a function to display the final amount of earnings in dollars. This function will be passed the number of days worked, and the accumulated total pennies earned.


This Is What i Have soo Far... But the image that I need does not look the same is my Function.

My Program so far:

base = 2

days = input("Please enter number of days: ")

for day in range (0, days):
totpay = base ** day
print "day %d = %d pennies" % (day+1, totpay)

"""
Please enter number of days: 20
day 1 1 pennies
day 2 = 2 pennies
day 3 = 4 pennies
day 4 = 8 pennies
day 5 = 16 pennies
day 6 = 32 pennies
day 7 = 64 pennies
day 8 = 128 pennies
day 9 = 256 pennies
day 10 = 512 pennies
day 11 = 1024 pennies
day 12 = 2048 pennies
day 13 = 4096 pennies
day 14 = 8192 pennies
day 15 = 16384 pennies
day 16 = 32768 pennies
day 17 = 65536 pennies
day 18 = 131072 pennies
day 19 = 262144 pennies
day 20 = 524288 pennies
"""


Can you guys leave your email address, so if i need more help i can email you. Or can you email me at Taolee10@yahoo.com THANK YOU!!
By the way, I am very new to Programming!

PYTHON Program Help!!!!?

When you have read something about sound in "Console-Mode" Python, that is given that there is not any sound characteristic with Console Python. You need to be taught wxPython or PyGame or might be even Tkinter (I believe helps sound facets)

Python program help.............................

I am supposed to write a program for a class using python to simulate a cashier and take a sale amount calculate the tax, add them together, and give them the total. This is what I have and it looks alright to me but it won't run properly. Can someone point out what I am doing wrong and point me in the right direction? I really apreciate all the help and here is the source code in question:
SaleTotal = float(raw_input("Enter the total sale amount"))
Tax = float(0.8*SaleTotal)
print "\n\nThe sale amount is:" + SaleTotal
print "The sales tax is:", + Tax
print "The total sale is:" + SaleTotal + Tax

raw_input("\nRun complete. Press the Enter key to exit.")
#End

Help with Python programming?

There are two questions.

1)
I am taking the Python tutorial on www.codeacademy.com. I am 99.99999999% sure that I am absolutely right and this piece of crap tutorial is wrong - however it keeps telling me I am not.

The mission is to create a Pig Latin translator. This is the program I've written so far:

pyg = 'ay'

original = raw_input('Enter a word:')

word = original.lower()


if len(original) > 0 and original.isalpha(): # makes sure string isn't empty nor numerical
if word[0] == 'a' or 'e' or 'i' or 'o' or 'u':
new_word = word + pyg
print new_word
else:
next_word = word[1:] + word[0]
new_word = next_word + pyg
print new_word

else:
print 'empty'


###############

When I execute this code, and raw_input a word that begins with a consonant, such as "terds" for example, the output is "terdsay".

This means that even when I input a word that begins with a consonant, it is executing the conditional loop that pertains to words that begin with vowels. I don't know why it is doing this, as I have explicitly stated only to run that condition if word[0] = "vowel".

Somebody please tell me what the hell is wrong.



2) I have the actual Python.exe on my computer and the raw_input function does not seem to exist. When I try to use raw_input on the actual Python program (3.3), it gives me an error message saying "name raw_input not defined). Why does it do this?

Need help with python program.?

molasses2 above has the right idea. But, the solution will not work for the case where the first score is the highest score. The sorting solution works too, but is unnecessarily expensive. I would write it something like this -

....
max = input ("Enter score>>")
nextmax = None # Null in Python

for i in xrange(n-1): # xrange is more efficient than range
x = input("Enter score>>")
if x > max:
# begin indent
nextmax = max
max = x
# end indent
elif nextmax is None:
nextmax = x

.....


Note that the algorithm will now (correctly) print nextmax as None if there was only one score entered.

Need Help With A "Python Programing" Question.?

using python 3 the code looks like this:

square_feet = input("How many square feet of wall space do you need painted? ")
cost_per_gallon = input("Cost per gallon of paint? ")
gallons_needed = float(square_feet)/115.0
hours_of_labor = 8 * gallons_needed
labor_costs = 8 * hours_of_labor
paint_costs = float(cost_per_gallon) * gallons_needed
print("The number of gallons of paint required is %f" % gallons_needed)
print("The number of gallons of hours of labor required are %f" % hours_of_labor)
print("The labor charges are %f" % labor_costs)

print("total labor is: %f" % (labor_costs + paint_costs))


Hope this helps!

What are some active Python forums for beginners?

Here are some great places to get started:Python FAQsAttend a ConferenceDiversity StatementSuccess StoriesMy experience with the Python community has been awesome. I have met some fantastic people through local meetups and gotten great support.@alex_gaynorPython WeeklyPython Weekly is a free weekly email newsletter featuring curated news, articles, new releases, jobs, and more. Curated by Rahul Chaudhary every Thursday.Go to pythonweekly.com to sign up.Internet Relay ChatFreenode IRC hosts several channels. Select an IRC client, register your nickname with FreenodeThere are several Python-related channels on the Freenode IRC network. All channels are available by on Internet Relay Chat server Freenode. Connect to http://irc://irc.freenode.net or use Freenode's webchat.For short questions, you can get immediate help by visiting the #python channel. You will need to first register your nickname with FreeNode, using the nickname setup instructions.German speakers can use the #Willkommen auf Python.de channel.Portuguese speakers can use the #python-ptchannel.Spanish speakers can use the #pyar channel, from the Python Argentina user group.French speakers can join the #python-fr channel.Finnish speakers can join the #Python Suomi ry channel on a different network, *IRCnet*.Turkish speakers can join the #pyistanbul channel.Other Channels#python-dev is for CPython developers, where they can coordinate their work or discuss problems. Bots post updates to the channel based on activity in the CPython source tree and bug tracker.#python-infra is for Python infrastructure discussion.#pydotorg is for Welcome to Python.org discussion.#distutils is for Python packaging discussion.Other SitesIRC clients for many platforms can be found in the Internet Relay Chat (IRC) Help Archive.

How do I make a Python program loop back to the beginning if N is inputed into a variable?

By looping back do you mean rerunning the loop? You could continue running the loop and run code only when variable != n. Like this:# Loop back to the beginning of loop.
# Initialize variables.
n = 0
variable = 0

while (n == variable):
# Get input for variable.
variable = int(input("Enter your value here: "))

# Do something here.

# Continue looping if variable == n; otherwise, run the code.
if not (variable == n):
print("Your code goes here.\n")
You could also define a function and use some recursion.# Recursion example.
def main():

# Initialize variables.
n = 0
variable = 0

# Get the input for your variable.
variable = int(input("Enter your value here: "))

# If the variable == n, use recursion.
if (variable == n):
main()

# Start the function the first time.
main()
You could also read the code itself and run a specific line depending on input.You can do it like this:# Goto workaround.
# Initialize variables.
n = 0
variable = 0

# Read self.
self_path = "./goto.py"
self_file = open(self_path).readlines() # Make sure to read lines.

# Start loop.
while (n == variable):
# Add some action.
#print("Hey, this is line 13.\n")
#print("Greetings, I am the 14th line.\n")
#print("Hi, this is #15.\n")

# Get input.
variable = int(input("Enter your value here: "))

# Run some functions depending on input.
if (variable == 13):
line = list(self_file) # Transform lines into a list.
line = line[12] # Get the 13th element of tha list.
line = line.strip() # Remove whitespace.
line = line[1:] # Uncomment line.
eval(line) # Run the 13th line.
It should be noted, though, that this code is really hard to maintain as a single modification in the upper part of the code would mean updating all the lines. It is more of a proof of concept, and you should not try to use it in production. Well, if you create a system that automatically updates the values, you could have a nice code that runs parts of itself as needed; otherwise, do not use this code for production!Cheers!

TRENDING NEWS