w3resource

Python: Using function attributes display the names of all arguments

Python Class ( Basic ): Exercise-5 with Solution

Define a Python function student(). Using function attributes display the names of all arguments.

Sample Solution:

Python Code:

def student(student_id, student_name, student_class):
    return f'Student ID: {student_id}\nStudent Name: {student_name}\nClass: {student_class}'
print(student('S122', 'Wilson Medina', 'VI'))

Sample Output:

Student ID: S122
Student Name: Wilson Medina
Class: VI

Flowchart:

Flowchart: Using function attributes display the names of all arguments.

Python Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a python program which import the abs() function using the builtins module, display the documentation of abs() function and find the absolute value of -155.
Next: Write a Python function student_data () which will print the id of a student (student_id). If the user passes an argument student_name or student_class the function will print the student name and class.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/python-exercises/class-exercises/python-class-basic-1-exercise-5.php