85
This is CS50

This is CS50

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: This is CS50

This is CS50

Page 2: This is CS50

Announcements 🍂● Masks are required. Please do not put classmates in a position of risk or

discomfort by not adhering to protocol. And please do not put staff in a position of having to remind or escalate. Step outside or watch online instead.

● No food or drink in Sanders, please!

● If you'd like to view the projector screen on your own laptop during class and/or ask Carter questions via chat, visit cs50.ly/sanders, which will open a Zoom webinar. Be sure to mute your audio, as this week's webinar also contains video for those in isolation or quarantine.

Page 3: This is CS50

This is CS50

Page 4: This is CS50

#include <stdio.h>

int main(void){ printf("Thank you, Luke!\n");}

Page 5: This is CS50

print("Thank you, Luke!")

Page 6: This is CS50

This is CS50

Page 7: This is CS50
Page 8: This is CS50

#include <stdio.h>

int main(void){ printf("hello, world\n");}

Page 9: This is CS50

print("hello, world")

Page 10: This is CS50
Page 11: This is CS50

printf("hello, world");

Page 12: This is CS50

printf("hello, world\n");;

Page 13: This is CS50

print("hello, world");

Page 14: This is CS50
Page 15: This is CS50

string answer = get_string("What's your name?\n");printf("hello, %s\n", answer);

Page 16: This is CS50

string answer = get_string("What's your name? ");printf("hello, %s\n", answer);

Page 17: This is CS50

answer = get_string("What's your name? ")print("hello, " + answer)

Page 18: This is CS50

answer = get_string("What's your name? ")print("hello, " + answer)

Page 19: This is CS50

answer = get_string("What's your name? ")print("hello, " + answer)

Page 20: This is CS50

answer = get_string("What's your name? ")print(f"hello, {answer}")

Page 21: This is CS50
Page 22: This is CS50

int counter = 0;

Page 23: This is CS50

int counter = 0;

Page 24: This is CS50

counter = 0

Page 25: This is CS50

counter = counter + 1;

Page 26: This is CS50

counter = counter + 1;

Page 27: This is CS50

counter = counter + 1

Page 28: This is CS50

counter += 1;

Page 29: This is CS50

counter += 1

Page 30: This is CS50
Page 31: This is CS50

if (x < y){ printf("x is less than y\n");}

Page 32: This is CS50

if (x < y){ printf("x is less than y\n");}

Page 33: This is CS50

if x < y: print("x is less than y")

Page 34: This is CS50
Page 35: This is CS50

if (x < y){ printf("x is less than y\n");}else{ printf("x is not less than y\n");}

Page 36: This is CS50

if (x < y){ printf("x is less than y\n");}else{ printf("x is not less than y\n");}

Page 37: This is CS50

if x < y: print("x is less than y")else: print("x is not less than y")

Page 38: This is CS50
Page 39: This is CS50

if (x < y){ printf("x is less than y\n");}else if (x > y){ printf("x is greater than y\n");}else{ printf("x is equal to y\n");}

Page 40: This is CS50

if (x < y){ printf("x is less than y\n");}else if (x > y){ printf("x is greater than y\n");}else{ printf("x is equal to y\n");}

Page 41: This is CS50

if x < y: print("x is less than y")elif x > y: print("x is greater than y")else: print("x is equal to y")

Page 42: This is CS50
Page 43: This is CS50

while (true){ printf("meow\n");}

Page 44: This is CS50

while (true){ printf("meow\n");}

Page 45: This is CS50

while True: print("meow")

Page 46: This is CS50
Page 47: This is CS50

int i = 0;while (i < 3){ printf("meow\n"); i++;}

Page 48: This is CS50

int i = 0;while (i < 3){ printf("meow\n"); i++;}

Page 49: This is CS50

i = 0while i < 3: print("meow") i += 1

Page 50: This is CS50

for (int i = 0; i < 3; i++){ printf("meow\n");}

Page 51: This is CS50

for (int i = 0; i < 3; i++){ printf("meow\n");}

Page 52: This is CS50

for i in [0, 1, 2]: print("hello, world")

Page 53: This is CS50

for i in range(3): print("hello, world")

Page 54: This is CS50

bool

char

double

float

int

long

string

...

Page 55: This is CS50

bool

float

int

str

...

Page 56: This is CS50

range sequence of numbers

list sequence of mutable values

tuple sequence of immutable values

dict collection of key-value pairs

set collection of unique values

...

Page 57: This is CS50

range sequence of numbers

list sequence of mutable values

tuple sequence of immutable values

dict collection of key-value pairs

set collection of unique values

...

Page 58: This is CS50

get_char

get_double

get_float

get_int

get_long

get_string

...

Page 59: This is CS50

get_float

get_int

get_string

Page 60: This is CS50

#include <cs50.h>

Page 61: This is CS50

import cs50

Page 62: This is CS50

from cs50 import get_float

from cs50 import get_int

from cs50 import get_string

Page 63: This is CS50

from cs50 import get_float, get_int, get_string

Page 64: This is CS50

#include <stdio.h>

int main(void){ printf("hello, world\n");}

Page 65: This is CS50

make hello

./hello

Page 66: This is CS50

clang -o hello hello.c -lcs50

./hello

Page 67: This is CS50

print("hello, world")

Page 68: This is CS50

python hello.py

Page 69: This is CS50

interpretersource code →

Page 70: This is CS50

1 Recoge guía telefónica2 Abre a la mitad de guía telefónica3 Ve la página4 Si la persona está en la página5 Llama a la persona6 Si no, si la persona está antes de mitad de guía telefónica7 Abre a la mitad de la mitad izquierda de la guía telefónica8 Regresa a la línea 39 Si no, si la persona está después de mitad de guía telefónica10 Abre a la mitad de la mitad derecha de la guía telefónica11 Regresa a la línea 312 De lo contrario13 Abandona

Page 71: This is CS50

1 Pick up phone book2 Open to middle of phone book3 Look at page4 If person is on page5 Call person6 Else if person is earlier in book7 Open to middle of left half of book8 Go back to line 39 Else if person is later in book10 Open to middle of right half of book11 Go back to line 312 Else13 Quit

Page 72: This is CS50

This is CS50

Page 73: This is CS50

input

Page 74: This is CS50

OOP

Page 75: This is CS50

floating-point imprecision

Page 76: This is CS50

exceptions

Page 77: This is CS50
Page 78: This is CS50
Page 79: This is CS50
Page 80: This is CS50

docs.python.org

Page 81: This is CS50

integer overflow

Page 82: This is CS50

cs50.ly/hogwarts

Page 83: This is CS50

regular expressions

Page 84: This is CS50

. any character

.* 0 or more characters

.+ 1 or more characters? optional

^ start of input$ end of input

...

Page 85: This is CS50

This is CS50