TORONTO KIDS COMPUTER CLUB | PMCA Sunday 10:00 Practice -03.
post-template-default,single,single-post,postid-17529,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

PMCA Sunday 10:00 Practice -03.

19 May PMCA Sunday 10:00 Practice -03.

You can do Question 1~ 3 in Python IDLE:

Question 1.

Use float() to create a number from a string like ‘12.34’. Make sure the result is really a number!

Question 2.

Try using int() to create an integer from a decimal number like 56.78. Did the answer get rounded up or down?

Question 3.

Try using int() to create an integer from a string. Make sure the result is really an integer!

You should create python file and Write program for the following questions (you can read instruction about how to write python program and run the program at the end of page):

Question 4.

Write a program that asks for your first name, then asks for your last name, and then prints a message with your first and last names in it.

Use input() to ask question and get answer, for example:

firstName = input("What is your first name?")

The string answer as value will be assigned to variable firstName.

Question 5.

Write a program that asks for the dimensions (length and width) of a rectangular room, and then calculates and displays the total amount(area) of carpet needed to cover the room.

Use input() to ask question and get answer, however, you can only get string data type of answer. In order to get decimal number as dimensions, you need to use float(input(…..)) which will convert from string answer into a decimal number.

Question 6.

Write a program that helps the user add up her change. The program should ask:

  • “How many quarters?”
  • “How many dimes?”
  • “How many nickels?”

Then use print to show the total value of the change


q = int(input("how many quarters?"))
d = ____________________
n = ____________________

changeInQuarter = q * 25
changeInDime = _________
changeInNickel = __________

changeInTotal = _________________
print("the change is" _________)

Instruction of how to create and run a program in Python:

  • Open Python IDLE
  • In Menu Bar, Click “File” => “New File”
  • In the file write your program
  • After finishing writing the program, click “Run”=>”Run Module” in menu bar or just press “F5”
  • Python will ask you save the file before run the program
  • Check your code and fix the errors.

No Comments

Sorry, the comment form is closed at this time.