I Haz Codes

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Menu
double a number

Copy the code into a new file. Save it as “double.py”.

The program should ask for a number and then double it. (multiply by 2)

Make the following changes.

– Replace the ???? with the variable num1.
– run the code and test it with the number 4. It should display 8.
– There is an error in the code. Replace input(“Enter a number to double – “) with int(input(“Enter a number to double – “))
– Be careful of the extra brackets!
– run the code and test it with the number 12. It should display 24.

num1 = input("Enter a number to double - ")
answer = ???? * 2
print(answer)


<iframe src=”https://trinket.io/embed/python/6737d87461″ width=”100%” height=”600″ frameborder=”0″ marginwidth=”0″ marginheight=”0″ allowfullscreen></iframe>

Comments are closed.

Information