[Tutor] Python Question

jargon cowtux250 at gmail.com
Fri Jan 10 10:23:51 CET 2014


On 01/10/2014 02:11 AM, Amy Davidson wrote:
> Hi,
>
> I am a university student who is struggling with writing functions in Python. I’ve been attempting to write a function in Python for over 2 hours with no progress. The function must be called, printID and take a name and student number as parameter and prints them to the screen.
>
> This is my closest guess:
>
> def print_ID(“Amy Davidson”, 111111111)
> Student = “Amy Davidson”
> StudentN = 111111111
> print (“StudentName:”, Student)
> print (“StudentNumber:”, StudentN)
>
> If you could help correct my work and explain, that would be great! 
>
> Thanks,
>
> Amy Davidson
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
Hi Amy

Your function will need function parameters, to which values will be
passed to:

def printID(studentName, studentNumber):
    print "Student Name: %s. Student Number: %d" %(studentName,
studentNumber)

Then you invoke the function like this:

printID("Amy Davidson", 111111111)

Hope this helps

Dayo


More information about the Tutor mailing list