Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Python Exercises
Index -> Programming, Python -> Python Tutorials
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Aziz




PostPosted: Tue May 06, 2008 11:58 am   Post subject: RE:Python Exercises

Python's got a good tutorial on their site for those who are already familiar with programming. Its fast and in-depth.

And while I really liked my own high school CS (much better than most of my college ones), I wish he would have had the interest for it as you do, McKenzie. Do you have any advanced python examples? I've got the attachment, but I'm at work so I can't look at it too much.

(BTW, did you know a Mr. Nehmetellah that taught there (I think)? He was my CommTech teacher a couple years ago at Cardinal Carter)
Sponsor
Sponsor
Sponsor
sponsor
McKenzie




PostPosted: Tue May 06, 2008 7:41 pm   Post subject: RE:Python Exercises

There are a number of good tutorials out there, but I find where most of them lacking is interesting assignments/exercises to challenge the reader and force them to apply what they have just read. It is by doing that you learn.

You will find no advanced examples in the attachment. I have a bunch if you are interested, but I find basic examples are better. They allow you to focus on just one issue at a time.

(aside, I taught with Mr. N. for one year. I didn't know him very will but he seemed cool to me)
taylankaraman




PostPosted: Wed Feb 25, 2009 3:55 am   Post subject: Re: Python Exercises

Thanks McKenzie! The exercises are great.
Greetings from Turkey! Very Happy
Sniper4Life




PostPosted: Sun Apr 12, 2009 4:53 pm   Post subject: Re: Python Exercises

k ive got a little questionn...i wanna know if my answer to the very first question on unit 2.1 is SUFFICIENT

code:
x=123
print x*3.14*2



by your standerds if it is sufficientt
it answers the question...but...still...doesnt seem like enough to me.....
Zeroth




PostPosted: Sun Apr 12, 2009 6:23 pm   Post subject: Re: Python Exercises

Thats it. With Python, sometimes it seems like it makes programming TOO easy.
Sniper4Life




PostPosted: Sun Apr 12, 2009 8:03 pm   Post subject: RE:Python Exercises

thats what makes it perfect for beginners Very Happy
Ex1:
x=123
print x*3.14*2



Ex2:
r = input("Radius: ")

print " "

print"The area of your cirlce is: "

print r*r*3.14


Ex3:
c=input ("How much Canadian dollars you have: ")

print " "
print "You will have ", c*1.6156, " Euros after your money has been converted"





Ex4:

c=raw_input ("First name: ")
r=raw_input ("Last Name: ")

print " "

print r,",", c


McKenzie can you tell me if my answers are OK?
Tony




PostPosted: Sun Apr 12, 2009 9:07 pm   Post subject: RE:Python Exercises

code:

print r,",", c

That is not ok. Whitespace is your friend. So are proper variable names.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sniper4Life




PostPosted: Sun Apr 12, 2009 9:23 pm   Post subject: Re: RE:Python Exercises

Tony @ Sun Apr 12, 2009 8:07 pm wrote:

That is not ok. Whitespace is your friend. So are proper variable names.


its just 4 lines of coding...is there rlly a need for proper variable names?
its not that bad...it doesnt nessesscarily make the code BAD
and whitespace?

btw...this is the question

Gets the user?s first and last name and outputs them in reverse order with a comma between them.

also...what do you think about the OTHER codes?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Apr 12, 2009 9:34 pm   Post subject: RE:Python Exercises

Yes, there really (vowels are your friend as well, use them Wink ) is a need to make your code easy to read and understand.

A 4 line function within a 10,000 line application is arguably still "just 4 lines of code".

If there are some terms that you don't understand, learn how to look them up quickly. I have keyboard shortcuts to Google, Wikipedia, and a Dictionary.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sniper4Life




PostPosted: Sun Apr 12, 2009 9:42 pm   Post subject: Re: Python Exercises

code:
firstpx=input ("First point's x coordinate: ")
firstpy=input ("First point's y coordinate: ")

print " "
secondpx=input ("Second point's x coordinate: ")
secondpy=input ("Second point's y coordinate: ")
print " "

print "First point:  ","(", firstpx,",",firstpy,")"
print "Second point: ","(",secondpx,",",secondpy,")"
print " "

print "Distance: ""(",firstpx-secondpx,",",firstpy-secondpy,")"


there...are the new variables better now Tony?
satisfied? Razz
woops i just realized this is a different code Razz
o well....btw...how would you make it that when the Distance comes up...the numbers only go as far as 2 decimal places....????
Alexmula




PostPosted: Mon Apr 13, 2009 12:14 am   Post subject: RE:Python Exercises

use the round function
Sniper4Life




PostPosted: Mon Apr 13, 2009 9:57 am   Post subject: RE:Python Exercises

ya unluckily i dont know what that is......someone else told me it was %f"x"

but i thought it was like round(something something)
Alexmula




PostPosted: Mon Apr 13, 2009 11:50 am   Post subject: RE:Python Exercises

python.org has an online manual..

you can also try typing "print help()" in IDLE i think it you can also get help there

and yes there is a round function: round(x[n]) Laughing x being the number u want to round and n the number of decimal places i believe
Sniper4Life




PostPosted: Mon Apr 13, 2009 12:17 pm   Post subject: RE:Python Exercises

dont worry im dont that question in the exercises now ^^
i even did introEx6...im in 2.2 questions now Very Happy
unluckily for me...i dont know anything bout these:

- Concatenation (+)
- Multiplication (*)
- Slices
- Escape sequences
- len()
- String Methods
upper
lower
find
replace
count

ya...so its gonna be a bit hard for me...
i feel somewhat proud?Razz
doing grade 11 exercises Very Happy
lol they're easy exercises tho(in the beginning)...i seriously wish they had advanced math and like computer science in middle school...like an option for those things

middle school teaches how to use movie maker Razz
lol
wtd




PostPosted: Mon Apr 13, 2009 5:12 pm   Post subject: Re: Python Exercises

Sniper4Life @ Mon Apr 13, 2009 5:53 am wrote:
k ive got a little questionn...i wanna know if my answer to the very first question on unit 2.1 is SUFFICIENT

code:
x=123
print x*3.14*2



Again, get into the habit of using whitespace.

code:
x = 123
print x * 3.14 * 2

Display posts from previous:   
   Index -> Programming, Python -> Python Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 42 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: