CS50P - Lecture 2 - Loops

CS50 July 8, 2022
Video Thumbnail
CS50 Logo

CS50

@cs50

About

This is CS50, Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. Demanding, but definitely doable. Social, but educational. A focused topic, but broadly applicable skills. CS50 is the quintessential Harvard course.

Video Description

This is CS50P, CS50's Introduction to Programming with Python. Enroll for free at https://cs50.edx.org/python. Slides, source code, and more at https://cs50.harvard.edu/python. Playlist at https://www.youtube.com/playlist?list=PLhQjrBD2T3817j24-GogXmWqO5Q5vYy0V. TABLE OF CONTENTS 00:00:00 - Introduction 00:00:24 - Loops 00:00:50 - cat.py 00:03:24 - while 00:16:21 - for 00:27:00 - Validating Input 00:34:59 - Iteration with Lists 00:40:36 - len 00:45:47 - Dictionaries 00:57:02 - Lists of Dictionaries 01:05:02 - Nested Loops 01:20:17 - Conclusion An introduction to programming using a language called Python. Learn how to read and write code as well as how to test and "debug" it. Designed for students with or without prior programming experience who'd like to learn Python specifically. Learn about functions, arguments, and return values (oh my!); variables and types; conditionals and Boolean expressions; and loops. Learn how to handle exceptions, find and fix bugs, and write unit tests; use third-party libraries; validate and extract data with regular expressions; model real-world entities with classes, objects, methods, and properties; and read and write files. Hands-on opportunities for lots of practice. Exercises inspired by real-world programming problems. No software required except for a web browser, or you can write code on your own PC or Mac. Whereas CS50x itself focuses on computer science more generally as well as programming with C, Python, SQL, and JavaScript, this course, aka CS50P, is entirely focused on programming with Python. You can take CS50P before CS50x, during CS50x, or after CS50x. But for an introduction to computer science itself, you should still take CS50x! *** HOW TO SUBSCRIBE http://www.youtube.com/subscription_center?add_user=cs50tv HOW TO TAKE CS50 edX: https://cs50.edx.org/ Harvard Extension School: https://cs50.harvard.edu/extension Harvard Summer School: https://cs50.harvard.edu/summer OpenCourseWare: https://cs50.harvard.edu/x HOW TO JOIN CS50 COMMUNITIES Discord: https://discord.gg/cs50 Ed: https://cs50.harvard.edu/x/ed Facebook Group: https://www.facebook.com/groups/cs50/ Faceboook Page: https://www.facebook.com/cs50/ GitHub: https://github.com/cs50 Gitter: https://gitter.im/cs50/x Instagram: https://instagram.com/cs50 LinkedIn Group: https://www.linkedin.com/groups/7437240/ LinkedIn Page: https://www.linkedin.com/school/cs50/ Medium: https://cs50.medium.com/ Quora: https://www.quora.com/topic/CS50 Reddit: https://www.reddit.com/r/cs50/ Slack: https://cs50.edx.org/slack Snapchat: https://www.snapchat.com/add/cs50 SoundCloud: https://soundcloud.com/cs50 Stack Exchange: https://cs50.stackexchange.com/ TikTok: https://www.tiktok.com/@cs50 Twitter: https://twitter.com/cs50 YouTube: http://www.youtube.com/cs50 HOW TO FOLLOW DAVID J. MALAN Facebook: https://www.facebook.com/dmalan GitHub: https://github.com/dmalan Instagram: https://www.instagram.com/davidjmalan/ LinkedIn: https://www.linkedin.com/in/malan/ Quora: https://www.quora.com/profile/David-J-Malan TikTok: https://www.tiktok.com/@davidjmalan Twitter: https://twitter.com/davidjmalan *** CS50 SHOP https://cs50.harvardshop.com/ *** LICENSE CC BY-NC-SA 4.0 Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License https://creativecommons.org/licenses/by-nc-sa/4.0/ David J. Malan https://cs.harvard.edu/malan [email protected]

You May Also Like

Master Loops with These Essentials

AI-recommended products based on this video

Loading...
Lenovo IdeaPad 3 Laptop| Intel Core i7-1255U Processor| Touchscreen| 15.6 inch Full HD Display| 40GB RAM, 1TB PCIe SSD|USB-C, HDMI, Card Reader| Office Trial| Backlit Keyboard| Windows 11

Lenovo IdeaPad 3 Laptop| Intel Core i7-1255U Processor| Touchscreen| 15.6 inch Full HD Display| 40GB RAM, 1TB PCIe SSD|USB-C, HDMI, Card Reader| Office Trial| Backlit Keyboard| Windows 11

(1)
$699.99
FREE delivery Tue, Jun 17
Loading...
Lenovo 2025 New Touchscreen Laptop • 6-Cores Intel Core i3 • 40GB RAM • 2TB SSD • 15.6 inch FHD (1920 x 1080) Display • Long Battery Life • WOWPC Recovery USB • Windows 11 Pro with Microsoft Office

Lenovo 2025 New Touchscreen Laptop • 6-Cores Intel Core i3 • 40GB RAM • 2TB SSD • 15.6 inch FHD (1920 x 1080) Display • Long Battery Life • WOWPC Recovery USB • Windows 11 Pro with Microsoft Office

(2)
$1,159.99$469.99
FREE delivery Jun 23 - 25
300+ bought in past month
Loading...
Lenovo V-Series V15 Business Laptop | 15.6" FHD 1920 * 1080 | 13th Gen Intel Core i7-13620H | 40GB RAM | 1TB SSD | Webcam | Wi-Fi 6 | Windows 11 Pro | Black | Bundle with ADATA 512GB External SSD

Lenovo V-Series V15 Business Laptop | 15.6" FHD 1920 * 1080 | 13th Gen Intel Core i7-13620H | 40GB RAM | 1TB SSD | Webcam | Wi-Fi 6 | Windows 11 Pro | Black | Bundle with ADATA 512GB External SSD

(6)
$849.00
FREE delivery Jun 18 - 23
50+ bought in past month
Loading...
Lenovo IdeaPad 15.6” FHD Touchscreen Laptop, 40GB RAM 2.5TB Storage (2TB SSD+512GB Docking Station Set), 6-Cores Intel Core i3, Windows 11 Pro with Microsoft Office Included, Plusera Earphones

Lenovo IdeaPad 15.6” FHD Touchscreen Laptop, 40GB RAM 2.5TB Storage (2TB SSD+512GB Docking Station Set), 6-Cores Intel Core i3, Windows 11 Pro with Microsoft Office Included, Plusera Earphones

(94)
$599.99
FREE delivery Tue, Jun 17
300+ bought in past month
Loading...
UGREEN USB C to USB Hub with 4 USB 3.0, Powered USB C Splitter for Laptop, MacBook Pro, Mac mini M4, iMac, iPad Pro, Chromebook, Dell XPS, Galaxy S23, and More, 0.5FT

UGREEN USB C to USB Hub with 4 USB 3.0, Powered USB C Splitter for Laptop, MacBook Pro, Mac mini M4, iMac, iPad Pro, Chromebook, Dell XPS, Galaxy S23, and More, 0.5FT

(12,070)
9.99
PrimeFREE delivery Saturday, June 14 on orders shipped by Amazon over $35
400+ bought in past month
Loading...
Anker Power Bank(PowerCore 10K),Compact Travel-Ready 10,000mAh Battery Pack with PowerIQ Charging Technology,5V/3A High-Speed Charging for iPhone,iPad,and More (USB-C Input and Output(Black),1pack) ClimatePartner certified

Anker Power Bank(PowerCore 10K),Compact Travel-Ready 10,000mAh Battery Pack with PowerIQ Charging Technology,5V/3A High-Speed Charging for iPhone,iPad,and More (USB-C Input and Output(Black),1pack) ClimatePartner certified

(109,961)
$17.99$17.81
FREE delivery Fri, Aug 8 on $35 of items shipped by Amazon
10K+ bought in past month
Loading...
Lenovo V15 Laptop | 15.6" FHD Anti-Glare Display | AMD Ryzen 7 7730U | 40GB RAM | 1TB PCIe SSD | HDMI | Type-C | Webcam | Wi-Fi | THUNDEROBOT Wireless Ergonomic Mouse | Windows 11 Pro | Black

Lenovo V15 Laptop | 15.6" FHD Anti-Glare Display | AMD Ryzen 7 7730U | 40GB RAM | 1TB PCIe SSD | HDMI | Type-C | Webcam | Wi-Fi | THUNDEROBOT Wireless Ergonomic Mouse | Windows 11 Pro | Black

(26)
$649.00$636.02
FREE delivery Jun 18 - 23
Loading...
acer Nitro V 15 Gaming Laptop, Intel i9-13900H Up to 5.4GHz, GeForce RTX 4060, 15.6" 144 Hz IPS Display, 64 GB DDR5, 4 TB SSD, Wi-Fi 6, Backlit Keyboard, Windows 11 Pro, Gaming Mouse, 256GB UFD

acer Nitro V 15 Gaming Laptop, Intel i9-13900H Up to 5.4GHz, GeForce RTX 4060, 15.6" 144 Hz IPS Display, 64 GB DDR5, 4 TB SSD, Wi-Fi 6, Backlit Keyboard, Windows 11 Pro, Gaming Mouse, 256GB UFD

(2,753)
$1,899.99
FREE delivery Tomorrow, Jun 12Arrives before Father's Day
Loading...
Lenovo ThinkPad E14 Gen 5 Business Laptop (14" FHD+ Anti-glare, Intel 10-Core i7-1355U, 40GB RAM, 1TB SSD) Backlit, Fingerprint, Fast Charge, 1080p RGB Webcam, Wi-Fi 6, Win 11 Pro w/ Copilot

Lenovo ThinkPad E14 Gen 5 Business Laptop (14" FHD+ Anti-glare, Intel 10-Core i7-1355U, 40GB RAM, 1TB SSD) Backlit, Fingerprint, Fast Charge, 1080p RGB Webcam, Wi-Fi 6, Win 11 Pro w/ Copilot

(12)
$899.99
FREE delivery Wed, Jun 18
Loading...
Lenovo ThinkPad E16 Business Laptop, 16" FHD+ Touchscreen, Intel i7-1355U, 40GB RAM, 1TB SSD, AI Copilot, Fingerprint, Backlit KB, HDMI, Wi-Fi 6, Windows 11 Pro, Bundle with UC310 64GB USB Flash Drive

Lenovo ThinkPad E16 Business Laptop, 16" FHD+ Touchscreen, Intel i7-1355U, 40GB RAM, 1TB SSD, AI Copilot, Fingerprint, Backlit KB, HDMI, Wi-Fi 6, Windows 11 Pro, Bundle with UC310 64GB USB Flash Drive

(1)
$996.55
FREE delivery Jun 18 - 23
50+ bought in past month
Loading...
Hydrocolloid Bandages for Wound Care, Extra Large Medical-Grade Hydrocolloid Roll with Self-Adhesive, Ultra Absorbent, Flexible & Waterproof, DIY Size & Shape First Aid Kit Essential (2in*4.8ft)

Hydrocolloid Bandages for Wound Care, Extra Large Medical-Grade Hydrocolloid Roll with Self-Adhesive, Ultra Absorbent, Flexible & Waterproof, DIY Size & Shape First Aid Kit Essential (2in*4.8ft)

(126)
$8.99
FREE delivery Fri, Oct 3 on $35 of items shipped by Amazon
8K+ bought in past month
Loading...
GOOACC - GRC-33 240PCS Bumper Retainer Clips Car Plastic Rivets Fasteners Push Retainer Kit Most Popular Sizes Auto Push Pin Rivets Set -Door Trim Panel Fender Clips for GM Ford Toyota Honda Chrysler
Best Seller

GOOACC - GRC-33 240PCS Bumper Retainer Clips Car Plastic Rivets Fasteners Push Retainer Kit Most Popular Sizes Auto Push Pin Rivets Set -Door Trim Panel Fender Clips for GM Ford Toyota Honda Chrysler

(76,396)
$10.92$10.37
FREE delivery Sun, Sep 21 on $35 of items shipped by Amazon
20K+ bought in past month
Loading...
Lexar ES3 1TB External SSD, USB 3.2 Gen2 Portable SSD, PSSD Up to 1050MB/s Read, 1000MB/s Write, External Solid State Drive Compatible with iPhone 16/15 Series/Mac/PS5/XBOX/Laptop/PC

Lexar ES3 1TB External SSD, USB 3.2 Gen2 Portable SSD, PSSD Up to 1050MB/s Read, 1000MB/s Write, External Solid State Drive Compatible with iPhone 16/15 Series/Mac/PS5/XBOX/Laptop/PC

(37)
69.99
PrimeFREE delivery Saturday, June 14
300+ bought in past month
Loading...
soundcore Sport X20 by Anker, True-Wireless Workout Earbuds, Rotatable and Extendable Ear Hooks, Noise Cancelling, Deep Bass, IP68 Waterproof, Sweatproof, Dustproof, 48H Play, Sport Earbuds for Gym

soundcore Sport X20 by Anker, True-Wireless Workout Earbuds, Rotatable and Extendable Ear Hooks, Noise Cancelling, Deep Bass, IP68 Waterproof, Sweatproof, Dustproof, 48H Play, Sport Earbuds for Gym

(5,721)
79.99
PrimeFREE delivery Saturday, June 14
1K+ bought in past month
Loading...
Wireless Earbuds, Bluetooth 5.4 Headphones, True Wireless Stereo Earphones with IPX7 Waterproof, Noise Cancelling Mic, Fast Charging and Comfort Fit Ear Buds for Sports/Workouts - Black

Wireless Earbuds, Bluetooth 5.4 Headphones, True Wireless Stereo Earphones with IPX7 Waterproof, Noise Cancelling Mic, Fast Charging and Comfort Fit Ear Buds for Sports/Workouts - Black

(1,741)
$19.99
FREE delivery Sun, Jun 22 on $35 of items shipped by Amazon
10K+ bought in past month
Loading...
Apple AirPods 4 Wireless Earbuds, Bluetooth Headphones, Personalized Spatial Audio, Sweat and Water Resistant, USB-C Charging Case, H2 Chip, Up to 30 Hours of Battery Life, Effortless Setup for iPhone
Best Seller

Apple AirPods 4 Wireless Earbuds, Bluetooth Headphones, Personalized Spatial Audio, Sweat and Water Resistant, USB-C Charging Case, H2 Chip, Up to 30 Hours of Battery Life, Effortless Setup for iPhone

(23,152)
$89.99$83.69
FREE delivery Thu, Sep 4
10K+ bought in past month
Loading...
Wireless Earbuds Bluetooth V5.3 Headphones 50H Playback Deep Bass Stereo Ear Buds with LED Power Display Charging Case IPX7 Waterproof Earphones with Mic Headset for Laptop Pad Android/iOS Phones

Wireless Earbuds Bluetooth V5.3 Headphones 50H Playback Deep Bass Stereo Ear Buds with LED Power Display Charging Case IPX7 Waterproof Earphones with Mic Headset for Laptop Pad Android/iOS Phones

(1,809)
$6.99
FREE delivery Jun 17 - 20 on $35 of items shipped by Amazon
10K+ bought in past month