Repository navigation
Expand file tree
/
Copy path091-No-Input-With-Argument-Method.py
More file actions
57 lines (45 loc) · 2.01 KB
/
Copy path091-No-Input-With-Argument-Method.py
File metadata and controls
57 lines (45 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
===============================================================================
File Name : 91-No-Input-With-Argument-Method.py
Description : No Input With Argument Method in Python
Author : Shaik Mahaboob Basha
===============================================================================
Definition:
A No Input With Argument Method does not take input from the user. Instead,
values are passed as arguments when the method is called. The method performs
the required operation using those arguments and does not return any value.
Syntax:
def method_name(argument1, argument2):
# Statements
method_name(value1, value2)
Example:
def display_student(name, age):
print(name)
print(age)
display_student("Rahul", 21)
"""
# -----------------------------------------------------------------------------
# Defining a method with arguments.
# -----------------------------------------------------------------------------
def display_student_details(student_name, student_age):
# -------------------------------------------------------------------------
# Displaying the student name.
# -------------------------------------------------------------------------
print("Student Name :", student_name)
# Output:
# Student Name : Rahul
# -------------------------------------------------------------------------
# Displaying the student age.
# -------------------------------------------------------------------------
print("Student Age :", student_age)
# Output:
# Student Age : 21
# -----------------------------------------------------------------------------
# Calling the method by passing arguments.
# -----------------------------------------------------------------------------
display_student_details("Rahul", 21)
print()
# -----------------------------------------------------------------------------
# Calling the method again with different arguments.
# -----------------------------------------------------------------------------
display_student_details("Anjali", 22)