Day 1 of 100 Days of Code
Introduction
- Welcome to the 100 Days of Code challenge.
- Goal: Write and understand code from scratch.
- Future videos will include more complex programs.
Writing the First Program
- Example program: Printing "Hello World"
- Function: A piece of code designed to perform a specific task.
print: Function used to display output.
- Syntax for using functions in Python:
- Write the function name (e.g.,
print)
- Use parentheses
() to call the function.
- Place contents to print inside the parentheses, enclosed in double quotes "" for strings.
Understanding Errors and Debugging
- Example error: Red line under code, indicating syntax error.
- Python requires valid objects within functions.
- Strings must be enclosed in double quotes.
Script Execution
- Manually typing and running each line is not efficient.
- Use scripts (e.g.,
main.py) to execute multiple lines sequentially.
- Example script with multiple print statements:
print('Hello World')
print(5)
print('Bye')
- Scripts allow batch execution of code lines.
Interactive vs. Script Mode
- Interactive mode (REPL): Run and test code line by line manually.
- REPL stands for Read-Evaluate-Print Loop.
- Script mode: Write a sequence of commands in a file and execute them together.
Computations in Print Statements
- Can perform arithmetic operations within
print:
- Addition (
+)
- Subtraction (
-)
- Multiplication (
*)
- Division (
/)
- Example:
print(17 * 13)
print(221) # Direct number output
- Results of computations are printed directly.
Importance of Consistency and Practice
- This course requires daily, consistent practice.
- Not suitable for quick shortcuts or learning without practice.
- Success requires dedication and practice over the entire 100 days.
Conclusion
- Stay dedicated and keep practicing.
- Bookmark the playlist and follow along daily.
Thank you for watching and see you next time!