0

Hi all. I'm taking a beginner python course and have an assignment to write code using a 'for loop' + 'named variable' + 'branching logic'

Trouble is, I have no idea what 'branching logic' is - if anyone has the time to respond, I'd really appreciate it!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by lmn_k
0

branching is just 'which part of the program runs next'. Branches in python are mostly made using 'if', 'elif' and 'else', so for example

a = 10
if a < 5:
  print 'this branch handles case where a < 5'
elif a < 10:
  print 'this branch handles case where 5 <= a and a < 10'
else:
  print 'this branch handles case where 10 <= a'
0

Thanks so much! Very helpful!

branching is just 'which part of the program runs next'. Branches in python are mostly made using 'if', 'elif' and 'else', so for example

a = 10
if a < 5:
  print 'this branch handles case where a < 5'
elif a < 10:
  print 'this branch handles case where 5 <= a and a < 10'
else:
  print 'this branch handles case where 10 <= a'
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.