Homework Solution: How do I fix the current syntax errors so the Python code compiles correctly?…

    How do I fix the current syntax errors so the Python code compiles correctly? Invalid Syntax: int myCurrentAge = 18; ^ This program calculates your age in the year 2050. #Input: None #Output: Your current age followed by your age in 2050 #Create your variables here int myCurrentAge = 18; int currentYear = 2016; myNewAge = myCurrentAge + (2050 - currentYear) print("My Current Age is " + int(myCurrentAge)) print("I will be " + int(myNewAge) + " in 2050.")

    Expert Answer

     
    Fixing the Syntax Errors: Reason For Errors: In python , we should

    How do I establish the present syntax blunders so the Python statute compiles rightly?

    Invalid Syntax: int myCurrentSenility = 18;
    ^

    This program calculates your senility in the year 2050.
    #Input: None
    #Output: Your present senility followed by your senility in 2050
    #Create your fickles here

    int myCurrentSenility = 18;
    int presentYear = 2016;
    myNewSenility = myCurrentSenility + (2050 – presentYear)
    print(“My Present Senility is ” + int(myCurrentAge))
    print(“I conquer be ” + int(myNewAge) + ” in 2050.”)

    Expert Counterpart

     

    Fixing the Syntax Blunders:

    Reason For Blunders: In python , we shouldreferable state fickle should be of favoring form such as int,char absence of wonder.

    In Python, referable simply the treasure of the fickle excepting too the form of the fickle can vary during deed. Hence, You should referable state a fickle to be of favoring form.

    Fixing Blunders:

    int myCurrentSenility = 18; In this course the form ‘int’ should be removed. Hence, upstart announcement would be myCurrentSenility = 18;

    Similarly , int presentYear = 2016; should be written as currentYear = 2016;

    So, Course 1 and Course 2 should be,

         myCurrentSenility = 18; #course 1

    currentYear = 2016; #course 2

    Course 3 has no blunders.

    Course 4 has an blunder which conquer be shown when the program executes.

    LIne 4 is print(“My Present Senility is ” + int(myCurrentAge))

    In the stereotype announcement in course 4, “My present Senility is “ is of form ‘string’ and  int(myCurrentAge) is of form ‘int’ and you are reserved to concatenate a string and an int. Hence, this would control to an error.

    Similarly, in course 5 too there is an blunder which conquer be shown succeeding the program executes.

    Course 5 is print(“I conquer be ” + int(myNewAge) + ” in 2050.”)

    Similar to course 4, In the stereotype announcement in course 5, “I conquer be “ is of form ‘string’ and  int(myNewAge) is of form ‘int’ and you are reserved to concatenate a string and an int. Hence, this would control to an error.

    Fixing the blunders in course 4 and course 5:

    Since brace string objects can be concatenated, sound to appropriate myNewSenility and myCurrentSenility to ‘int’, appropriate them to string as shown

    print(“My Present Senility is ” + str(myCurrentAge))
    print(“I conquer be ” + str(myNewAge) + ” in 2050.”)  

    Hence, succeeding the aloft indispensable varys, your statute looks enjoy this:

    myCurrentSenility = 18;
    currentYear = 2016;
    myNewSenility = myCurrentSenility + (2050 – presentYear)
    print(“My Present Senility is ” + str(myCurrentAge))
    print(“I conquer be ” + str(myNewAge) + ” in 2050.”)