Home > Software engineering >  Interpreat python syntax
Interpreat python syntax

Time:07-04

question_num = 5, num_1 = 7, num_2 = 9
statement =  '#%s: %s x %s =  ' % (question_num, num_1, num_2)

What is the meaning of the statement syntax? Please explain how does this syntax work?

CodePudding user response:

Here %s acts as a placeholder of your data (variable). There are even better ways to do same like using f-string or format method.

statement = f"#{q}: {n} x {n2} = "
  • Related