ALS2

.pdf

School

University of Calgary *

*We aren’t endorsed by this school

Course

249

Subject

Mathematics

Date

Jan 9, 2024

Type

pdf

Pages

3

Uploaded by MinisterInternet10606

Report
Reading assignment: Zybook sections 1.6 to 2.7 Questions: The TA can choose to ask general questions regarding variables, identi±ers, arithmetic expressions and python expressions as in Chapter 1 and Chapter 2. Best way to prepare is to answer the questions in the book sections and understand the answers. If you don’t understand some of the questions/answers in the Zybook/Chapter 2 then be sure to ask TA, instructor or discuss with those around you. ALS-2 Variables and Expressions P1. Write a ²owchart and python program, for displaying ±rst 10 numbers for ±bonacci sequence. The ±bonacci sequence is given by the following set of equations: for Programming assignments: P2. Write an algorithm and python program to convert temperature from degree Celsius to Fahrenheit by using the formula. (F=9/5*C+32). Use input() for the Celsius input P3. Evaluate the following numerical expressions in your head, then use the Python interpreter to check your results for print(x). Do you get any error in either of these? If yes which expression and why? 1. x= '55'+'5' 2. x= '786' * 3 3. x= '35' +12 4. x= 2**15 5. x= 8 % 6 ³. x=0 / 20 7. x= 20 % 0
P4. Answer the following questions 1. What is the output of print(type("40.3"))? 2. What is the output of type(range(5))? 3. What is the output of print(type({})) and why? 4. What is the output of the following code print(bool(0),bool(3.14159),bool(-30.2),bool(1.0+2j)) and why? 5. Which of the following are valid names for a variable: a) ALS_assignment_! b) als_Assign c) ALS assignment d) als_Assignment_1 ³. What is the output of the following code snippet and why? x = 'ALS_ASSIGNMENT' print(id(x)) P5. Do the participation activities of Zybook 1.8.1 to 1.8.7 given here 1. Select the statement that prints the following: Welcome! (a) print(Welcome!) (b) print('Welcome!") (c)print('Welcome!') [Zybook 1.8.1] 2. Type a statement that prints the following: Hello [Zybook 1.8.2] 3. Write the simplest statement that prints the following: " 3 2 1 Go!" Note: Whitespace (blank spaces / blank lines) matters; make sure your whitespace exactly matches the expected output [Zybook 1.8.3] 4. Given the variable num_cars = 9, which statement prints 9? (a)print(num_cars) (b)print("num_cars") [Zybook 1.8.4] 5. Write a statement that prints the value of the variable num_people.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help