Question: HW2: Variables In this assingment, we will practice variables and data types of Python. Q1. Different data types (1.5 points) Provide one example of each


![of each of the following data types: In [ ]: # integer](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4e2a418a13_83566f4e2a3ae28a.jpg)
![number: a = In [ ]: # Float number: b = In](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4e2a4b2c69_83666f4e2a45573e.jpg)
HW2: Variables In this assingment, we will practice variables and data types of Python. Q1. Different data types (1.5 points) Provide one example of each of the following data types: In [ ]: # integer number: a = In [ ]: # Float number: b = In [ ]: # Complex number: C = In [ ]: # Booleans d = In [ ]: # string e = Q2. String data types: (1.5 points) Fill pieces below to have correct values for lower_cased, stripped and stripped_lower_case variables. In [ ]: original = ' PYTHON IS COOL!' length_of_the_text = # (1) show the lengeth of the string. lower_cased = original. # (2) convert the string to the lower case strin stripped = lower_cased. # (3) remove the space from both side. stripped_lower_cased = original. #apply 2 & 3 at the same time Q3. Numbers and Creating Formulas: (2 points) Write the following mathematical formula in Python: 862 result = 6a? + 11 4c alhost:8888otebooks/423_HW2_Variables.ipynb 1/3 4/2021 423_HW2_Variables - Jupyter Notebook Assume a = 2, b = 3, C = 2 In [ ]: # Your formula here: make sure to use enough paranthesis in your equation. a,b,c = 2, 3, 2 result = Q4. + and * in numbers & string data types (2 points) Consider the following variables. In [ ]: a, b = 2,5 c, d = 'a','b' Which of the following statements are correct and which ones are inccorrect? why? In [ ]: # 4.1. Is this a correct operation? why? What is the measing of this opeation a + b In [ ]: # 4.2. Is this a correct operation? What is the measing of this opeation? Cud In [ ]: # 4.3. Is this a correct operation? why? What is the measing of this opeation a * b In [ ]: # 4.4. Is this a correct operation? why? What is the measing of this opeation C* d In [ ]: # 4.5. Is this a correct operation? why? What is the measing of this opeation a * d Q5. (2 points) Fill the blanks in the following cell based on the instructions. In [ ]: message = 'Hello everybody!' message. # sperate the text based on the space character. print(message[ : ]) # print only Hello. New_message= message. # replace ! with the red heart emojy. # Simply replace '!' with '\u2764\ufe0f' print(New_message) localhost:8888otebooks/423_HW2_Variables.ipynb 2/3 1/24/2021 423_HW2_Variables - Jupyter Notebook Q6. (1 point) The purpose of this question is convertin one data type to another. In [ ]: a, b, c = '2','4', '6' d = a + b + c e = ? (d) # convert d into an integer number. print(?(e)) # check data type of e f = ? (d) # convert d into a floting number. print(?(f)) # check data type of f print(e ? f) # check whether e and f have the same data type g = ? (d) + a # convert d into string
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
