Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control-flow tutorial #35

Open
GabiGrin opened this issue Jun 30, 2023 · 7 comments
Open

Control-flow tutorial #35

GabiGrin opened this issue Jun 30, 2023 · 7 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed

Comments

@GabiGrin
Copy link
Contributor

Write a tutorial that covers how to do:

  • loops
  • conditionals
@GabiGrin GabiGrin added documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed labels Jun 30, 2023
@xbz-24
Copy link

xbz-24 commented Jun 30, 2023

Python Loops and Conditionals Tutorial

Loops

Loops are one of the most fundamental control structures in programming. They allow a block of code to be repeated multiple times. Python has two types of loops: for and while.

For Loop

The for loop is used to iterate over a sequence (list, tuple, dictionary, set, string) or any other iterable object.

Iterating over a list

for i in [1, 2, 3, 4, 5]:
    print(i)  # Prints numbers from 1 to 5

While Loop

The while loop allows the execution of a group of instructions as long as a condition is met (i.e., as long as the condition evaluates to True).

# Example of using the while loop
i = 1
while i <= 5:
    print(i)  # Prints numbers from 1 to 5
    i += 1

Conditionals

Conditionals allow us to check conditions and make our program behave one way or another, according to the results of these conditions.

If, Elif, Else

In Python, the syntax for conditionals is through the reserved words if, elif (else if), and else.

age = 20
if age < 18:
    print("You are underage.")
elif age >= 18 and age < 65:
    print("You are an adult.")
else:
    print("You are a senior.")

This is a very basic rundown of loops and conditionals in Python. There is much more you can do with them, including nesting loops and conditionals, using break and continue in loops, among other things. However, I hope this gives you a solid foundation upon which you can build.

@GabiGrin
Copy link
Contributor Author

GabiGrin commented Jun 30, 2023

@xbz-24 Although obviously GPT generated, I appreciate the willingness to help.

This issue refers to control flow with Flyde, of course. If you want to learn more about Flyde and try giving a shot at this, I'd love to guide you through it!

@GabiGrin GabiGrin mentioned this issue Jun 30, 2023
@xbz-24
Copy link

xbz-24 commented Jun 30, 2023

@GabiGrin I already have the extension, look what I get when I do new visual flow :
image

@GabiGrin
Copy link
Contributor Author

Awesome! Perhaps this issue #8 can help

Also, you're welcome to discuss this on Discord - https://discord.gg/qeetahUmgU

@GabiGrin
Copy link
Contributor Author

Weird! what is your setup?

@xbz-24
Copy link

xbz-24 commented Jun 30, 2023

m1 mac :( should I try with linux mint

@GabiGrin
Copy link
Contributor Author

I'm on a m1 mac too :) works great
the error you're seeing means something pretty basic broke, as the commands failed to register

Can you try looking for an error in the VSCode developer tools and then reloading VSCode and looking for related errors?
Screenshot 2023-06-30 at 12 06 05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants