filmov
tv
#getting the #ascii #value of a #character - #python #coding #challenge - #easy #18

Показать описание
#please #like, #share, #subscribe for #more and #comment any #questions
#try #it #yourself:
#video #elements :
0:00 #introduction
0:30 #define the #function
0:51 #use the 'ord()' #function
1:13 #return the #result
1:23 #test the #function
1:51 expalanation and #summary
#source #code :
# Let's write a function to return ascii value of a character.
# In this tutorial, we will learn how to create a Python function that returns the ASCII value of a character.
# ASCII stands for "American Standard Code for Information Interchange" and represents a standard way
# to encode characters as integers.
# Let's start by defining a function called 'get_ascii_value' that takes one parameter, 'character',
# which is the character you want to find the ASCII value for.
def get_ascii_value(character) :
# Inside the 'get_ascii_value' function, use the built-in 'ord()' function to get the ASCII value of
# the input character.
# The 'ord()' function takes a character as input and returns its ASCII value.
ascii_value = ord(character)
# And then it's time to return the ASCII value as the output of the function.
return ascii_value
# Finally let's test the 'get_ascii_value' function with different characters to see how it works.
print(get_ascii_value('A')) # Output: 65
print(get_ascii_value('B')) # Output: 66
print(get_ascii_value('Z')) # Output: 90
# Summary:
# The 'get_ascii_value' function takes one argument, 'character', which is the character for which
# you want to find the ASCII value.
# Inside the function, it uses the 'ord()' function to get the ASCII value of the input character.
# The function returns the ASCII value as an integer.
# Happy coding! :)
#try #it #yourself:
#video #elements :
0:00 #introduction
0:30 #define the #function
0:51 #use the 'ord()' #function
1:13 #return the #result
1:23 #test the #function
1:51 expalanation and #summary
#source #code :
# Let's write a function to return ascii value of a character.
# In this tutorial, we will learn how to create a Python function that returns the ASCII value of a character.
# ASCII stands for "American Standard Code for Information Interchange" and represents a standard way
# to encode characters as integers.
# Let's start by defining a function called 'get_ascii_value' that takes one parameter, 'character',
# which is the character you want to find the ASCII value for.
def get_ascii_value(character) :
# Inside the 'get_ascii_value' function, use the built-in 'ord()' function to get the ASCII value of
# the input character.
# The 'ord()' function takes a character as input and returns its ASCII value.
ascii_value = ord(character)
# And then it's time to return the ASCII value as the output of the function.
return ascii_value
# Finally let's test the 'get_ascii_value' function with different characters to see how it works.
print(get_ascii_value('A')) # Output: 65
print(get_ascii_value('B')) # Output: 66
print(get_ascii_value('Z')) # Output: 90
# Summary:
# The 'get_ascii_value' function takes one argument, 'character', which is the character for which
# you want to find the ASCII value.
# Inside the function, it uses the 'ord()' function to get the ASCII value of the input character.
# The function returns the ASCII value as an integer.
# Happy coding! :)