Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Variables and types Open a python interpreter and write the instructions in the following block list. Please note that the examples are indeed examples. Therefore,

Variables and types

Open a python interpreter and write the instructions in the following block list. Please note that the examples are indeed examples. Therefore, you should use different values doing your code, do not copy-paste, or you will get errors.

Create a string, e.g., my_string=Hello Jeddah. Print the variable.

Create a string that contains the text representing a number, e.g., number_string=22. Test the type of the variable, e.g., type(number_string). Print the variable.

Get a integer from the previous string, e.g., my_integer=int(number_string). Test the type of the variable, e.g., type(my_integer). Print the variable.

Get a floating from the previous string, e.g., my_floating=float(number_string). Test the type of the variable, e.g., type(my_floating). Print the variable.

Get a string from the previous floating number, e.g., my_new_string=str(my_floating). Test the type of the variable, e.g., type(my_floating). Print the variable.

Get an integer from a floating number, e.g., int(22.3). Print the variable.

Eval a string to get a number, e.g., my_eval=eval(23.8). Test the type of the variable, e.g., type(my_eval). Print the variable.

Eval a new string to get a number, e.g., my_eval2=eval(23). Test the type of the variable, e.g., type(my_eval2). Print the variable. The function eval gave a different type of variable. Say why.

Reply below:

Try to get an integer from the first string, e.g., my_integer_fail=int(my_string). Then, say why the operation failed.

Reply below:

Try to print the integer you were trying to get from a string, e.g., print(my_integer_fail). It does not work. Explain why.

Reply below:

Create a Boolean variable with the value False, e.g., my_bool=False. Print its value. Make a string from that variable with the str operator, e.g., my_false=str(my_bool). Note that the string is not the same as the Boolean variable. Test this concept with:

my_bool == my_false

my_bool != my_false

To finalize this part, attach a screenshot of your computer.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions

Question

At the core of the video, Howard Roarks speech, is that it is a

Answered: 1 week ago