Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Complete the get_hexadecimal_numbers() function that takes a list of strings called string_list as a parameter. The function goes through each string in string_list. If

image text in transcribedPython

Complete the get_hexadecimal_numbers() function that takes a list of strings called string_list as a parameter. The function goes through each string in string_list. If a string represents a valid hexadecimal number, the function formats it and appends it to a list which the function returns once the string_list has been processed. Notes: A hexadecimal number is a base 16 number. Hexadecimal numbers have 1 or more of the following digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. This means that 10AF is a valid hexadecimal number, as is FFF or 777. For the digits A, B, C, D, E, and F, case is not important, so both FFF and fff would be valid hexadecimal numbers. Hexadecimal numbers are typically represented as "x" followed by the number itself. So FFF in hexadecimal would be represented as xFFF. 165 in hexadecimal would be represented as x165. Leading zeroes are not included in a number representation as they do not add to the number's numerical value. So, while 0007AB is a valid hexadecimal number it would be represented as x7AB. The leading zeroes are not included. Based on the notes above, each string that is identified as a representation of a valid hexadecimal number is formatted as follows: The number is preceded by an "x". Leading zeroes are not included. For the sake of consistency, the alphabetical digits in the hexadecimal number system should be formatted so that they are in uppercase. Some examples of the function being used are shown below. Note that implementing helper functions will make this exercise easier. For example: Test Result ['x123', 'xBAO', 'xFFFF'] string_list = ["hello world", "123", "Q0BA0", "", "FFFF"] hex_number_list = get_hexadecimal_numbers(string_list) print(hex_number_list) string_list = ["hello world", "COMPSCI130", "Test", "", "Loops"] [] hex_number_list = get_hexadecimal_numbers(string_list) print (hex_number_list) ['x45006', 'x@', 'xAABBCC', 'xEACD'] string_list = ["045006", "00000", "XYZ", "90a4bBcC", "bacd"] hex_number_list = get_hexadecimal_numbers (string_list) print(hex_number_list)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

How would we like to see ourselves?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago