This is the first, well third (but the only one that's is usefull?), program.
I am new to programming so I figured I would post this and see if I can get some usefull feedback on how I am to do things better.
Currently I am reading a book called "Starting Out With Python" - Tony Gaddis
Does anyone know of a book that is a little more up to date with the current
version of python?
(just ignore the html tags, (how do I put the code in a box?)
Here it is!
<code>
#This program calculates salary based on pay.
#Import decimal class so rounding may be done at the end.
import decimal
##DEBUG CODE##
##Displays input data
#print("\novertime_pay" , overtime_pay)
#print("pay_rate" , pay_rate)
#print("overtime_mark" , overtime_mark)
#print("overtime_hours" , overtime_hours)
#print("hours" , hours , "\n")
##End input data display area
overtime_hours_disp = overtime_hours
#Check if overtime is more than one hour for "s" in "hours"
if overtime_hours > 1.:
hour_s = "hours"
elif overtime_hours == 0:
hour_s = ""
overtime_hours_disp = "no"
else: hour_s = "hour"
#print out the results
print ("\nYour subtotal is:\n$" + str(sub1) , "\nYou have" , str(overtime_hours_disp)
, hour_s , "overtime for a bonus of:\n+$" + str(overtime_pay)
, "\nYour Debit is:\n-$" + str(debit)
, "\n\n---------------------------------------------"
,"\nYou should get a total of:\n$" , str(total) )
input ("\n\nPress <ENTER> to quit")
</code>
(just ignore the html tags, (how do I put the code in a box?)
Post your code in [code][/code] bbcode tags.
Unfortunately, because indentation is significant in Python, I would rather not review your code until you have posted it in those bbcode tags for the indentation to be retained.
C + C++ Compiler: MinGW port of GCC
Build + Version Control System: SCons + Bazaar
This is the first, well third (but the only one that's is usefull?), program.
I am new to programming so I figured I would post this and see if I can get some usefull feedback on how I am to do things better.
Currently I am reading a book called "Starting Out With Python" - Tony Gaddis
Does anyone know of a book that is a little more up to date with the current
version of python?
(just ignore the html tags, (how do I put the code in a box?)
Here it is!
<code>
#This program calculates salary based on pay.
#Import decimal class so rounding may be done at the end.
import decimal
##DEBUG CODE##
##Displays input data
#print("\novertime_pay" , overtime_pay)
#print("pay_rate" , pay_rate)
#print("overtime_mark" , overtime_mark)
#print("overtime_hours" , overtime_hours)
#print("hours" , hours , "\n")
##End input data display area
overtime_hours_disp = overtime_hours
#Check if overtime is more than one hour for "s" in "hours"
if overtime_hours > 1.:
hour_s = "hours"
elif overtime_hours == 0:
hour_s = ""
overtime_hours_disp = "no"
else: hour_s = "hour"
#print out the results
print ("\nYour subtotal is:\n$" + str(sub1) , "\nYou have" , str(overtime_hours_disp)
, hour_s , "overtime for a bonus of:\n+$" + str(overtime_pay)
, "\nYour Debit is:\n-$" + str(debit)
, "\n\n---------------------------------------------"
,"\nYou should get a total of:\n$" , str(total) )
input ("\n\nPress <ENTER> to quit")
</code>
from twisted.web import server, resource from twisted.internet import reactor class HelloResource(resource.Resource): numberRequests=0 def render_GET(self,request): self.numberRequests+=1 request.setHeader("content-type","text/plain") return "Hello, you have called me "+str(self.numberRequests)+" times\n" reactor.listenTCP(56565,server.Site(HelloResource())) reactor.run()
My first program, mind you that it runs only on python 2.7 or lower, since at present there is no twisted library included in later versions
Issue
C:\> python thefile.py
then run your web browser on the established host with the port number 56565. Refresh it to see the message.
Bookmarks