Kevin

Python Beginner Tutorial 5 - Booleans and Conditionals

Recommended Posts

This tutorial covers declaring Boolean expressions and evaluating conditional expressions in python (if statement). After watching this video users should be able to create and evaluate Boolean expressions and use Boolean expressions in conditional operations (if statements).

Share this post


Link to post
Share on other sites

With there now 5 tutorials, do you know how many more there

On ‎23‎/‎11‎/‎2016 at 11:27 PM, Odi said:

I'm not able to find ' Python Beginner Tutorial 5 (For Absolute Beginners)' , having done Tutorials 1, 2, 3 & 4 i'm now used to Kevin's method and style of teaching so i would prefer to continue with his tutorials as opposed to someone else's. Does anyone have the link for it and the rest of the tutorials please ?

With there now 5 tutorials, do you know how many more there will be?

Share this post


Link to post
Share on other sites
On 6/8/2017 at 6:55 PM, johnfairweather said:

With there now 5 tutorials, do you know how many more there will be?

Many. The goal is to get to a point where we can talk about application design and systems architecture. That is being able to create an application in python that connects to a database, integrates with other apps, and then provides its own service. After that I'll start over from square one in another language. Probably c# next.

Share this post


Link to post
Share on other sites
On ‎10‎/‎06‎/‎2017 at 2:58 AM, Kevin said:

Many. The goal is to get to a point where we can talk about application design and systems architecture. That is being able to create an application in python that connects to a database, integrates with other apps, and then provides its own service. After that I'll start over from square one in another language. Probably c# next.

Thanks.  Though it is not my daytime job (Software Engineer/Tester), my main interest/background is in astronomy.  At the moment Python is the preferred language, in examining astronomical databases, so at the moment I'm trying to get a grounding in Python, before I tackle these databases, of which some are extremely large, with some data being too large to save to a database.

Share this post


Link to post
Share on other sites

Hey Kevin, can you tell me what's wrong with my code? It is returning the 'else' condition regardless of what I put for the operation.

Please see the attached pics.

 

PS: Thank you for this amazing series. Helping me get started you're an awesome teacher.

 

code.JPG

result.JPG

Share this post


Link to post
Share on other sites
On 7/6/2017 at 2:36 AM, clyde21 said:

Hey Kevin, can you tell me what's wrong with my code? It is returning the 'else' condition regardless of what I put for the operation.

result.JPG

In the output screenshot I see a space between in ") add" but I do not see a trailing space in the prompt "... and divide)". If you were adding a space that would cause that issue because " add" != "add"

Share this post


Link to post
Share on other sites

Hey Kevin,

any chance that you can please have a look at my code and tell me why its not working.
I attached a picture of my code, as well as of the error message.

Thanks for your help and the amazing video tutorials!

Edit: Found the mistake myself in line 20. Thanks anyways.

Tutorial5.thumb.PNG.d8b49c6f9da1e3b7c1f91eb33f7fb706.PNGTutorial5_ErrorMessage.PNG.68208299a69410bcad069f44a555afa8.PNG

Share this post


Link to post
Share on other sites
def PrintInput():  # here i make the func name
    name = input("your name", )  # here i make ver i call it name afte it i make input func and with for the user
    print("שלום לך ידידי במחשבון שלי יש לי 4 אופציות כפל חילוק חיבור חיסור")  # here i wont to print the input the  user enter
    print("hello", name, "My calculator has only 4 options)(for now)")
    pass





def add(num1, num2):
    return num1 + num2
def חיבור(מספר1, מספר2):
    return num1 + num2

def sub(num1,num2):
    return num1 - num2
def חיסור(מספר1,מספר2):
    return מספר1 - מספר2

def mul(num1, num2):
    return num1 * num2

def כפל(מספר1, מספר2):
    return מספר1 * מספר2

def div(num1, num2):
    return num1 / num2

def חילוק(מספר1, מספר2):
    return מספר1 / מספר2
def main2():
    פעולה = input("מה אתה רוצה לעשות?(חיבור,חיסור,כפל,חילוק")
    מספר1 = int(input("מספר1"))
    מספר2 = int(input("מספר2"))
    if (פעולה == 'חיבור'):
        print(חיבור(מספר1, מספר2))
    elif (פעולה == 'חיסור'):
        print(חיסור(מספר1, מספר2))
    elif (פעולה == 'כפל'):
        print(כפל(מספר1, מספר2))
    elif (פעולה == 'חילוק'):
        print(חילוק(מספר1, מספר2))
    else:
        print("משהו לא עובד")


def main():
    operation = input("what you wont to do?(add,subtract,multiply, and dvide,")
    num1 = int(input("מספר1:"))
    num2 = int(input("מספר2:"))
    if (operation == 'add'):
        print(add(num1,num2))
    elif (operation == 'subtract'):
        print(sub(num1,num2))
    elif (operation == 'multiply'):
        print(mul(num1,num2))
    elif (operation == 'dvide'):
        print(div(num1,num2))
    else:
        print("somting rong")
PrintInput()

main()

main2()

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...