ds 2001 practicum 1
play

DS 2001: Practicum 1 Warm-up: All TAs like puppies. No robots like - PowerPoint PPT Presentation

Fall 2020 Felix Muzny DS 2001: Practicum 1 Warm-up: All TAs like puppies. No robots like things that TAs like. Which of the following statements can we conclude given these two pieces of information? A. All robots like puppies B.


  1. Fall 2020 — Felix Muzny DS 2001: Practicum 1 Warm-up: • All TAs like puppies. • No robots like things that TAs like. Which of the following statements can we conclude given these two pieces of information? A. All robots like puppies B. All robots like kittens 0 C. No robots like puppies D. No robots like kittens E. All TAs like kittens 1

  2. Today's Computing History: The Difference Engine 2

  3. Recall: Running python programs ID IDLE → Atom hello.py python Hello! print("Hello!") interpreter input output (executes the program) $ python hello.py k terminal 3

  4. Values & Data Types Type Examples I -13 int too o -13.3 float 0.72 1.0 " hi " " " " " 12 string cat hat false True boolean 4

  5. Variables 9 € Which of the following statements are true about variable declarations: Jeff 1. the name of the variable always goes on the right side of the "=" sign 2. you can use operators like "+" and "-" but only on the left side of the "=" sign right xty=# NOT , 3. variable names may contain spaces 4. variable names are case insensitive A. 1 & 2 B. 3 C. 4 D. 1, 2, & 4 E. None of the above 5

  6. Variables • We use variables to save values of the results of expressions and functions so that we can use them later (to print, to do further calculations, etc) x = 12 x name = value y = 45 • When we declare a variable with a value, it allocates space in memory to store this value. We can think of the variable as the "name" that it's stored under. - I y t - 6

  7. The print function • The print function is what we use to display any values or information to the user. print(parameters) # print a value • print("hello") ) print 142 # print the value of a variable x = 47 # 42 print(x) var " ) " x string print ( # X print("hello", x) # print multiple values P 7

  8. input function • We say that the input function returns a value (the user's input) • To use this value, we must save it in a variable • All values have a data type, including the return value ① variable = input(prompt) string tix " # name = input("What is your name? ") print("Hello!", name) # string e.g " " 12 print(type(name)) 8

  9. functions - how to call them I return_value = function_name(arguments/parameters) not always included 9

  10. Type Casting • functions that change a value from one type to another • Each basic type has a corresponding function that changes other values to that type. (they return the new value) " " 3 dogs 13J on dogs = input("how many dogs? ") dgE.int ( dogs ) intdogs ) " " 33 # double_dogs = 2 * dogs print("That's so many dogs:", double_dogs) 10

  11. Running python programs Which one of these python program successfully changes ("casts") the integer value stored in the variable x to a string? 130 x = 12 A.x = string(12) print(type(x)) B.str(x) # missing line goes here C.x = "12" - str Cx ) x - O D.x = str(x) # want this to be string print(type(x)) 11

  12. Reading error messages • When you have an error, python will print out an error message. These many *feel* like you've done something wrong, but secretly this is a great thing! I EOLTD End of Line ↳ End of file 12

  13. Reading error messages • When you have an error, python will print out an error message. These many *feel* like you've done something wrong, but secretly this is a great thing! E - - - 13

  14. Work on your practicum - instructions on Canvas • Remote: we're going to put you in break out rooms of 2 - 3 people. • The TAs and myself will be moving between breakout rooms checking in • We recommend turning on your cameras and having one person screen share as you work through the problems • (Remember that you will all individually turn in your assignment though!) • Use the "ask for help" button in zoom if you have a question and there is no TA/Felix in your breakout room. • If your zoom crashes and you need to re-join, you'll be in the main room—we'll keep an eye on this and re-assign you to your breakout room if this happens :) • We'll walk through one of the problems together about 15 minutes before the end. 14

Recommend


More recommend