Python: Using function attributes display the names of all arguments
5. Define function student() and show argument names using attributes
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:

For more Practice: Solve these Related Problems:
- Write a Python function that defines several parameters and then prints its __code__.co_varnames to display argument names.
- Write a Python program to create a function with default and keyword arguments and use its __defaults__ attribute to show default values.
- Write a Python program to implement a function that prints out its argument names using the inspect module.
- Write a Python program to define a function with variable arguments and display the complete tuple of argument names from its code object.
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.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics