Python Forum
Understanding if Statements in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding if Statements in Python
#1
Okay, I completely understand what a if statement in python is but, I missed a day of class and that was the day when my professor begin to teach python. I have an assignment to do and so far i've assigned that variables but every time it try to write the program and run it successfully I get many syntax errors or an indentation error. So could anybody please provide some examples on writing if statements with like 4 variables just so I can get an idea of how it's supposed to be set up. Thank you in advance !! Shy
Reply
#2
thor = 'God'

if thor == 'dog':
    print('is a dog')
else:
    print('not a dog')
    
thaw = True

if thaw:
    print('melted')
    
four = 4

if four > 3:
    print(f'{four} is greater than 3')
    
for fore in range(four):
    if fore+1 == four:
        print(f'{thaw} {thor}')

print([four for phwoah in [4]*4 if four == 4])
Output:
not a dog melted 4 is greater than 3 True God [4, 4, 4, 4]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Understanding venv; How do I ensure my python script uses the environment every time? Calab 1 2,158 May-10-2023, 02:13 PM
Last Post: Calab
  New to python/coding Need help on Understanding why this code isn't working. Thanks! mat3372 8 1,664 May-09-2023, 08:47 AM
Last Post: buran
  Understanding Python classes PythonNewbee 3 1,150 Nov-10-2022, 11:07 PM
Last Post: deanhystad
  Understanding Python super() for classes OmegaRed94 1 1,793 Jun-09-2021, 09:02 AM
Last Post: buran
  Better Understanding Of Object Orientation In Python JoeDainton123 3 2,419 Aug-30-2020, 02:49 PM
Last Post: deanhystad
  Understanding Python's Import Engine MysticaL 1 2,125 Feb-07-2020, 11:26 PM
Last Post: snippsat
  Optimal Statements in Python dukoolsharma 2 2,219 Apr-27-2019, 01:17 PM
Last Post: DeaD_EyE
  Help with understanding a python package pyhill00 4 2,970 Mar-21-2019, 12:42 AM
Last Post: Larz60+
  Understanding Scoping in Python yksingh1097 5 3,795 Aug-06-2018, 07:42 PM
Last Post: nilamo
  Python Iteration Understanding giteepag 3 2,669 Jul-26-2018, 02:23 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020