print("this is the input")

function name, followed by parentheses

input goes inside the parens

# assigning variables (examples)

someString = "some value"

some_integer = 10000000000

anotherInteger = some_integer + 25

this_might_crash = someString * some_integer

sup = input("What's up? ")
repeat = "y"

while repeat == "y":
    print("Hello World!")
    repeat = input("Repeat? Y or N").lower()

main program

gen = 0
total = 1

while gen <= 10:
  print("Gen", gen, ":", total, "cells")
  gen = gen + 1
  total = 2 ** gen
count = 1
total = 2

while count <= 10:
  print("Division", count, ":", total, "cells")
  count = count + 1
  total = 2 ** count
response = ""

while response != "because":
    response = input("Why?").lower()
n = 1

while n < 4:
    print(n)
    n = n + 1
n = 1

while n < 4:
    print(n)
    n = n + 1
age = input("How old are you? ")

print("Your age:")
print(age)

print("Your age in 10 years:")
print(int(age) + 10)
age = int(input("How old are you? "))

print("Your age:")
print(age)

print("Your age in 10 years:")
print(age + 10)
print(int(age) + 10)
int("27") => 27

  data types

  • string  "hello" // character(s)      
  • integer 321     // whole number
  • float   321.0   // decimal pt
  • Boolean true or false

 

  • array   ["hi", 321, 321.0, true]   
    // a list of values
    

  primitive data types

  • string  "hello" // character(s)      
  • integer 321     // whole number
  • float   321.0   // decimal pt
  • Boolean true or false

 

from picamera import PiCamera
from time import sleep

camera = PiCamera()

# image settings
camera.rotation = 180
camera.resolution = (1024, 768)
camera.framerate = 15

# brightness
camera.brightness = 50

# EDIT: text
camera.annotate_text = "Hello world!"
camera.annotate_text_size = 32

# EDIT: image effects
camera.image_effect = "none"

# start preview
camera.start_preview()

# wait
sleep(10)

# EDIT: take photo & save
camera.capture("/home/pi/Desktop/name.jpg")

# stop preview
camera.stop_preview()
# EDIT TEXT:
camera.annotate_text = "Hello world!"

# EDIT IMAGE EFFECT:
camera.image_effect = "none"

# EDIT NAME OF FILE:
camera.capture("/home/pi/Desktop/name.jpg")

1. Choose an image effect

  • Run effects.py to preview the effects

 

2. Edit camera.py

  • Edit the settings below                          
  • Run module!

Raspberry Pi Camera Demo

response = input("Do you like kittens? ")


if response.lower() == "yes" :
    print("Meow")

elif response.lower() == "no" :
    print("Me neither.")

else :
    print("Ok...")

convert the response so it's in the same case as your test word (in this case, we're using lowercase)

indentation matters!
use the tab key to indent

elif means "or else if..."
you can have as many
of these as you want!

else covers all other possible responses

name = input("What is your name? ")




print("Hi, " + name.capitalize())

# storing user input in a variable

this is what the program will say to the user

the user's response will be stored in this variable

>>> name = "aDa LoVeLaCe"


>>> name.swapcase()

# creating a variable

# calling a METHOD on a variable

variable

method

observation

- error messages

- other examples

hypothesis

- idea for how to fix

- one idea at a time

testing

- try a single idea

- rerun the program

Made with Slides.com