Language Basics

From Training Material
Revision as of 17:29, 13 February 2013 by Kristian Rother (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Check all syntactically correct statements.

<quiz display=simple > {Which input statements are correct?

|type="[]"} -a = raw_input() -a = raw_input(“enter a number”) -a = raw_input() - a = raw_input(enter your name) {

Answer >>


}

{ Which print statements are correct?

|type="[]"} -print “9” + “9” -print int(“nine”) -print str(9) + “nine” -print 9 + 9 -nine = 9 print nine {

Answer >>


}

{Which are correct arithmetical operations?

|type="[]"} -a = 1 * 2 -2 = 1 + 1 -5 + 6 = y -seven = 3 * 4 {

Answer >>


}

{ Which are correct variable names?

|type="[]"} -result -my.result -print -result77 {

Answer >>


}

{Which are correct type conversions?

|type="[]"} -int(7.0+0.1) -str(1.2 * 3.4) -float(“77”+”.0”) -str( 9 / 0 ) {

Answer >>


}

{Which operations result in 8?

|type="[]"} -65 // 8 -17 % 9 -2 ** 4 -64 ** 0.5 {

Answer >>


}

{Which lines are commented?

|type="[]"} +“””This is a comment””” +# This is a comment -// this is a comment - This is a comment {

Answer >>


}

Answer the questions:

  • What is a variable?
  • What names may variables have?
  • What is an integer?
  • What is a string?
  • How to assign a variable?
  • How to add, substract, and multiply numbers?
  • What can be printed with print?
  • How can text be read from the keyboard?
  • How are comments written in a program?