0% found this document useful (0 votes)
10 views7 pages

Python Greeting Function Examples

The document contains multiple Python scripts that define a function 'greet' to respond to input containing the word 'hello'. The scripts vary in their output methods, including printing directly, returning values, and concatenating additional strings. Each version demonstrates different ways to handle the greeting functionality.

Uploaded by

yaminahmed710
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views7 pages

Python Greeting Function Examples

The document contains multiple Python scripts that define a function 'greet' to respond to input containing the word 'hello'. The scripts vary in their output methods, including printing directly, returning values, and concatenating additional strings. Each version demonstrates different ways to handle the greeting functionality.

Uploaded by

yaminahmed710
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

greeting0.

py

1 def greet(input):
2 if "hello" in input:
3 print("hello, there")
4 else:
5 print("I'm not sure what you mean")
6
7
8 greet("hello, computer")
[Link]

1 def greet(input):
2 if "hello" in input:
3 return "hello, there"
4 else:
5 return "I'm not sure what you mean"
6
7
8 greet("hello, computer")
[Link]

1 def greet(input):
2 if "hello" in input:
3 return "hello, there"
4 else:
5 return "I'm not sure what you mean"
6
7
8 greeting = greet("hello, computer")
9 print(greeting)
[Link]

1 def greet(input):
2 if "hello" in input:
3 return "hello, there"
4 else:
5 return "I'm not sure what you mean"
6
7
8 print(greet("hello, computer"))
[Link]

1 def greet(input):
2 if "hello" in input:
3 return "hello, there"
4 return "I'm not sure what you mean"
5
6
7 print(greet("hello, computer"))
[Link]

1 def greet(input):
2 if "hello" in input:
3 return "hello, there"
4 return "I'm not sure what you mean"
5
6
7 print("Hm, " + greet("hello, computer"))
[Link]

1 def greet(input):
2 if "hello" in input:
3 return "hello, there"
4 return "I'm not sure what you mean"
5
6
7 greeting = greet("hello, computer")
8 print(greeting + " Carter")
9 print(greeting + " David")
10 print(greeting + " Rongxin")

You might also like