Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Learning Goal: I’m working on a python question and need an explanation and answ

by | Apr 29, 2022 | Python | 0 comments

GET HELP WITH YOUR ESSAY

If you need assistance with writing your essay, our professional Essay Writing Service is here to help!

DISCOUNT CODE FIRST25

ORDER THIS OR A SIMILAR PAPER NOW

Learning Goal: I’m working on a python question and need an explanation and answer to help me learn.ExerciseTuples are one of the fundamental types in Python used to store collections of data. A tuple stores a fixed collection of data in a specific order and uses numeric positions to identify the data it holds. These positions, otherwise called “indexes”, are integers starting at 0 and increasing.Tuple collections are primarily used when related data is fixed and has a natural ordering.Open the supplied main.py file.
Make a tuple using the parentheses syntax (( … )) with the following five values, and assign it to the variable passenger:12
True
“Bonnell, Miss. Elizabeth”
“female”
58
Print the value of the passenger variable. Run the script and confirm that the printed tuple displays all five values at once, in that order.
Using square bracket notation ([ … ]) and a positive index, get the third element of the tuple stored in the passenger variable and assign it to the variable name.
Using square bracket notation ([ … ]) and a negative index, get the last element of the tuple stored in the passenger variable and assign it to the variable age.
In a single print statement, print the values of the name and age variables. Run the script and verify that the person’s name and age were printed out.
Using square bracket notation with a range of indexes specifying both the start and end, get the second and third elements of the tuple stored in the passenger variable and assign it to the variable survived_and_name.
Using square bracket notation with a range of indexes specifying only the start, get the last two elements of the tuple stored in the passenger variable and assign it to the variable gender_and_age.
In a single print statement, print the values of the survived_and_name and gender_and_age variables. Run the script and verify that two tuples were printed out with the last four elements of passenger split between them.
Using the in keyword, get a boolean indicating whether the value “female” is in the tuple stored in the variable passenger, and assign it to the variable is_female.
Using the in keyword, get a boolean indicating whether the value “male” is in the tuple stored in the variable passenger, and assign it to the variable is_male.
In a single print statement, print the values of the is_female and is_male variables. Run the script and verify they each have a correct value.
Define a function named get_survival_info that expects a single parameter passenger and does the following:Unpacks passenger into the variables id, survived, name, gender, and age in a single statement (in that order).
Packs a new tuple with only age, gender, and survived (in that order).
Returns the new tuple.
Print the result of calling get_survival_info, passing passenger as an argument.
Print the result of calling get_survival_info with the addition data values:(11, True, “Sandstrom, Miss. Marguerite Rut”, “female”, 4)
(28, False, “Fortune, Mr. Charles Alexander”, “male”, 19)
(51, False, “Panula, Master. Juha Niilo”, “male”, 7)
Execute the script and verify each get_survival_info produced a tuple with an age, gender, and survived value.

GET HELP WITH YOUR ESSAY

If you need assistance with writing your essay, our professional Essay Writing Service is here to help!

DISCOUNT CODE FIRST25

ORDER THIS OR A SIMILAR PAPER NOW

How It Works

b

Tell us about your homework assignment.

~

Securely pay for your academic paper

j

Paper gets assigned to an expert tutor

Receive the complete paper via email

Team up With Your Own Writing Expert Now

Stuck with overwhelming assignments? We will take care of all your writing tasks.