How do I root the exoteric syntax blunders so the Python principle compiles justly?
Invalid Syntax: int myCurrentEpoch = 18;
^
This program calculates your epoch in the year 2050.
#Input: None
#Output: Your exoteric epoch followed by your epoch in 2050
#Create your inconstants here
int myCurrentEpoch = 18;
int exotericYear = 2016;
myNewEpoch = myCurrentEpoch + (2050 – exotericYear)
print(“My Exoteric Epoch is ” + int(myCurrentAge))
print(“I earn be ” + int(myNewAge) + ” in 2050.”)
Fixing the Syntax Blunders:
Reason For Blunders: In python , we shouldnot attributable attributable approve inconstant should be of local mold such as int,char foreseeing.
In Python, not attributable attributable attributable attributable attributable attributable singly the rate of the inconstant not attributable attributablewithstanding besides the mold of the inconstant can modify during dissuasive. Hence, You should not attributable attributable attributable attributable attributable attributable approve a inconstant to be of local mold.
Fixing Blunders:
int myCurrentEpoch = 18; In this row the mold ‘int’ should be removed. Hence, newlightlight proposition would be myCurrentEpoch = 18;
Similarly , int exotericYear = 2016; should be written as currentYear = 2016;
So, Row 1 and Row 2 should be,
myCurrentEpoch = 18; #row 1
currentYear = 2016; #row 2
Row 3 has no blunders.
Row 4 has an blunder which earn be shown when the program executes.
LIne 4 is print(“My Exoteric Epoch is ” + int(myCurrentAge))
In the imimimprint proposition in row 4, “My exoteric Epoch is “ is of mold ‘string’ and int(myCurrentAge) is of mold ‘int’ and you are unamenable to concatenate a string and an int. Hence, this would transfer to an error.
Similarly, in row 5 besides there is an blunder which earn be shown succeeding the program executes.
Row 5 is print(“I earn be ” + int(myNewAge) + ” in 2050.”)
Similar to row 4, In the imimimprint proposition in row 5, “I earn be “ is of mold ‘string’ and int(myNewAge) is of mold ‘int’ and you are unamenable to concatenate a string and an int. Hence, this would transfer to an error.
Fixing the blunders in row 4 and row 5:
Since couple string objects can be concatenated, aim to appropriate myNewEpoch and myCurrentEpoch to ‘int’, appropriate them to string as shown
print(“My Exoteric Epoch is ” + str(myCurrentAge))
print(“I earn be ” + str(myNewAge) + ” in 2050.”)
Hence, succeeding the overhead expedient modifys, your principle looks enjoy this:
myCurrentEpoch = 18;
currentYear = 2016;
myNewEpoch = myCurrentEpoch + (2050 – exotericYear)
print(“My Exoteric Epoch is ” + str(myCurrentAge))
print(“I earn be ” + str(myNewAge) + ” in 2050.”)