Sam Gue
Quiz by , created more than 1 year ago

Quiz on Python programming language, created by Sam Gue on 25/05/2014.

40
1
1
Sam Gue
Created by Sam Gue over 10 years ago
Close

Python programming language

Question 1 of 10

1

Variables: How do you form a variable?

Select one of the following:

  • variable_name = ("variable_content")

  • variable_name = ["variable_content"]

  • variable_name = {"variable_content"}

  • variable_name = "variable_content"

Explanation

Question 2 of 10

1

If statements: What follows an if statement?

Select one of the following:

  • A colon :

  • An equals =

  • A semi-colon ;

Explanation

Question 3 of 10

1

If statements: what are the other statements?

Select one of the following:

  • Elseif and Else

  • Elif and Else

Explanation

Question 4 of 10

1

Loops: How do you form a while loop?

Select one of the following:

  • while 'X' then:

  • while 'X':

Explanation

Question 5 of 10

1

Loops: What will this 'for loop' do?: for i in range(5):

Select one of the following:

  • repeat the number five forever

  • repeat something five times

  • repeat five things, five times

Explanation

Question 6 of 10

1

String indexing: print(word[3]), what will happen?

Select one of the following:

  • it will print word three times

  • it will print the third letter in word

  • it will print the third item in the list: word

  • it will print the fourth letter in word

Explanation

Question 7 of 10

1

Lists: how do you add something to a list?

Select one of the following:

  • list_name.add(value)

  • list_name.input(value)

  • append(value).list_name

  • list_name.append(value)

Explanation

Question 8 of 10

1

Functions: How do you form a user defined function?

Select one of the following:

  • define function_name():
    return X

  • def function_name():
    return X

Explanation

Question 9 of 10

1

Text Files: How do you open and close a reading text file?

Select one of the following:

  • file_name.open("X.txt", "r")

  • file_name.open("X.txt", "r+")

  • file_name.open("X.txt", "w")

  • file_name.open("X.txt", "a")

Explanation

Question 10 of 10

1

Procedures: What does a procedure lack as opposed to a User Defined Function

Select one of the following:

  • return X

  • def procedure_name():

Explanation