Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Pre-Lab Tasks: Read the introduction in this manual and answer the following: 1) In the Python statement , x=a+5b : - a and b

python
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Pre-Lab Tasks: Read the introduction in this manual and answer the following: 1) In the Python statement , x=a+5b : - a and b are called logied - a+5b is an Arithmetic 2) What is the value of the expression 100/25 and 100//25? Explain your answer. 3) A Python program must be enclosed in \{\} brackets to be executed. ( True/(alse) 4) Identify the expression that may result in arithmetic overflow in Python: a) a*b b) a/b c) ab d) ab 5) operators act on single operands. 6) operator performs logical negation on each bit of the operand. 7) can change the order in which an operator is applied. 8) operators are used to compare the values of either sides of an expression. 9) Bitwise operator can be applied on which datatype? a) integer b) float c) string d) none of the above 10) num =56.8. The statement to print integer equivalent of num is 8) Which of the following statements are the same? (A) xx+4 (B) x=x+4x (C) x=x(x+4) a) (A) and (B) are the same b) (A) and (C) are the same c) (B) and (C) are the same d) none 9) Write a program to calculate the number of seconds in a day. 10) Write a program that prompts the user to enter two integers x and y. The program then calculates and displays x2y. Task 4: Write a program to swap two numbers using a temporary variable. Task 5: Write a temperature conversion Python program that converts the temperature from Celsius to Fahrenheit. Use the formula: fahr =( cels* //5)+32. The program must output the following: Welcome to Temperature Conversion Progran Enter the Celsius Temperature 26 The Fahrinheit temprature is:78.8 Thank You for Using The Temperature Conversion Program Post Lab Tasks: 1) Which of the following expressions will yield 0.5 ? a) 1/2 b) 1//2 c) 1.0//2 d) 2/2 2) 25%1 is a) 1 b) 2 c) 3 d) 0 3) 2.03 evaluates to a) 9 b) 8 c) 9.0 d) 8.0 4) 232 evaluates to a) 36 b) 18 c) 12 d) 81 5) What is the result of evaluating 2+23/2 ? a) 4 b) 6 c) 4.0 d) 6) What is the value of i printed? j=i=li+=j+j5 print(i) a) 1 b) 5 c) 6 d) 7) To add a value 1 to variable x, you write a) 1+x=x b) x+=1 c) x=1 d) x=+1 Lab Tasks: Task 1: For each of the following questions type in IDLE shell. Include screenshot of result. The first is done for your reference. 1) What will be displayed by the following code? x=5x=2x+1print(x) x=11 as , by precedence 25=10+1=11 2) Put parentheses in the expression below so that they show the precedence of operations: a=5+yorz>3andq==p 3) What are the values of a and b after this code? y=2.3a=int(y2)b=y%a 4) Calculate the values of the expressions. Indicate what type the answer is. a) 5+4(3.2+4.5) b) 7%5+12//7 c) 8+4.0 5) Why is this typecast redundant? x=str( input("what's your name?")) 6) For a=10 and b=4. print (ab) and print (a>>2). Show the calculations 7) Arrange the following operators in highest to lowest order of precedence? and,%, not, +, 8) Solve ((40+20)30)/10 9) Identify the correct arithmetic expression in Python: a) 11(12+13) b) 44(32) c) 5+43 d) (56)(7+8) Task 2: Create a new file on IDLE text editor. Save file as Lab2_task2.Write a program to calculate the area of a triangle using the Heron's formula. The user inputs float numbers as sides of a triangle. \begin{tabular}{|l|} \hline Heron's Formula \\ x=2a+b+c \\ tesa =(sa)(sb)(sc) \\ \hline \end{tabular} Task 3: Write a program to get an integer input from the user and print it's: - the hex equivalent - square root - cube - digit at one's place

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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