Help to interpret in python


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>.

Write a single-line comment on line 1. It can be anything! (Make sure it starts with #)
Set the variable monty equal to True.
Set another variable python equal to 1.234.
Set a third variable monty_python equal to python squared

Can anyone help me to interpret in python code???.


#2

Alright, let’s go through this one by one…

  1. Write a single-line comment on line 1. It can be anything! (Make sure it starts with #)

For this, it wants you to write a single-line comment, comments are done using # like this:

#This is a single-line comment
  1. Set the variable monty equal to True.

Here, it wants you to set a variable, named monty equal to the boolean value True. To set a variable equal to a boolean value, do something like this:

myVar = False

Above, I have set a variable, named myVar equal to the boolean value False.

  1. Set another variable python equal to 1.234.

Here, it wants you to make a new variable, called python and set it equal to the number 1.234. To set a variable equal to a number, do something like this:

myNum = 2.46

Above, I have set a variable, named myNum equal to the number 2.46

  1. Set a third variable monty_python equal to python squared

Lastly, it wants you to make a new variable, named monty_python and set it equal to python squared. To set a variable equal to another variable and square it, do something like this:

myNum = 2.46
myNewNum = myNum ** 2

Above, I have set a variable, called myNewNum equal to myNum to the power of 2. We use ** in python to denote exponentiation.


#3

A post was split to a new topic: Common elements in lists


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.