Aprenda Python em 1 Hora (De Verdade!) – Comece Hoje Mesmo! | Curso de Python para iniciantes
Table of Contents
Introduction
This tutorial is designed to help you learn Python programming from scratch in just one hour. Whether you're a complete beginner or looking to refresh your skills, this guide provides clear, actionable steps based on the tutorial video by Jhonatan de Souza from Dev Aprender. By the end, you'll have a solid understanding of basic Python concepts and will be able to create your own simple projects.
Step 1: Setting Up Your Python Environment
Before you start coding, you need to set up an environment to run your Python code.
- Visit one of the following online platforms to write and execute Python code:
- Create a new Python file to begin coding.
Step 2: Understanding Variables
Variables are fundamental in Python and are used to store data.
- A variable is created by simply assigning a value to a name:
my_variable = 10 - Variable names must start with a letter or underscore and can contain letters, numbers, and underscores.
Step 3: Learning About Conditionals
Conditionals allow you to execute different code based on certain conditions.
- Use
if,elif, andelsestatements to control the flow of your program:if my_variable > 5: print("Greater than 5") elif my_variable == 5: print("Equal to 5") else: print("Less than 5")
Step 4: Exploring Loops
Loops enable you to execute a block of code multiple times.
For Loop
- Use a
forloop to iterate over a sequence:for i in range(5): print(i)
While Loop
- A
whileloop continues as long as a condition is true:count = 0 while count < 5: print(count) count += 1
Step 5: Working with Lists
Lists are used to store multiple items in a single variable.
- Create a list and access its elements:
my_list = [1, 2, 3, 4, 5] print(my_list[0]) # Outputs 1 - Lists can be modified:
my_list.append(6) # Adds 6 to the end of the list
Step 6: Building Simple Projects
Apply your knowledge by creating simple projects.
Project 1: Factorial of a Number
- Create a program to calculate the factorial:
def factorial(n): if n == 0: return 1 else: return n * factorial(n - 1) print(factorial(5)) # Outputs 120
Project 2: Guess a Number
- Build a simple number guessing game:
import random number_to_guess = random.randint(1, 10) guess = int(input("Guess a number between 1 and 10: ")) if guess == number_to_guess: print("You guessed it!") else: print("Try again!")
Project 3: Speed Detector
- Create a speed meter:
speed = int(input("Enter your speed: ")) if speed > 60: print("You're speeding!") else: print("You're within the speed limit.")
Conclusion
By following these steps, you have learned the fundamentals of Python programming, including variables, conditionals, loops, lists, and how to create simple programs. As your next steps, consider practicing more complex projects, exploring Python libraries, or enrolling in a comprehensive Python course to deepen your knowledge. Happy coding!