Python coding help

  

Task 1

Please write code to print the type of the following variables. Please write down the codes and the output as well.

x = 3.5

y = ‘3.5’

z = {1:’John’, 2:’Wick’, 3:’Barry’, 4:’Allen’}

  

Task 2

Please write code to calculate the value of the following function when a = 1, and b=2.

                   

Please note   .

Please write down the codes and the output as well. Beware the use of the parentheses.

  

Task 3

Given a word, write one line of command that print “True” if the first letter is the same as the last letter, and the length of the word is greater than 2. Otherwise, the program prints a “False”.

For example, if x=’dad’, then we expect that line of command to return a “True”. Please review page 15-24 of the slides very carefully to answer this question.

Tags: No tags