Repository navigation
Expand file tree
/
Copy path090-Input-No-Argument-Method.py
More file actions
60 lines (47 loc) · 2.01 KB
/
Copy path090-Input-No-Argument-Method.py
File metadata and controls
60 lines (47 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
58
59
60
"""
===============================================================================
File Name : 90-Input-No-Argument-Method.py
Description : Input No Argument Method in Python
Author : Shaik Mahaboob Basha
===============================================================================
Definition:
An Input No Argument Method is a method that takes input from the user inside
the method body and does not accept any arguments during the method call.
It also does not return any value.
Syntax:
def method_name():
variable = input("Enter Value: ")
# Statements
method_name()
Example:
def display_name():
name = input("Enter Your Name: ")
print("Name :", name)
display_name()
"""
# -----------------------------------------------------------------------------
# Defining a method that takes input inside the method.
# -----------------------------------------------------------------------------
def display_student_details():
# -------------------------------------------------------------------------
# Taking student name as input from the user.
# -------------------------------------------------------------------------
student_name = input("Enter Student Name : ")
# -------------------------------------------------------------------------
# Taking student age as input from the user.
# -------------------------------------------------------------------------
student_age = input("Enter Student Age : ")
print()
# -------------------------------------------------------------------------
# Displaying the student details.
# -------------------------------------------------------------------------
print("Student Name :", student_name)
# Output:
# Student Name : Rahul
print("Student Age :", student_age)
# Output:
# Student Age : 21
# -----------------------------------------------------------------------------
# Calling the method.
# -----------------------------------------------------------------------------
display_student_details()