Search Header Logo

PRP411 Practice Questions

Authored by Nomongi Hlatshwayo

Computers

Professional Development

Used 1+ times

PRP411 Practice Questions
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

18 questions

Show all answers

1.

OPEN ENDED QUESTION

30 mins • 5 pts

Write a program that checks whether a given number is positive, negative, or zero.

Evaluate responses using AI:

OFF

Answer explanation

To check if a number is positive, negative, or zero, use conditional statements. If the number is greater than zero, it's positive; if less than zero, it's negative; if equal to zero, it's zero.

2.

OPEN ENDED QUESTION

30 mins • 5 pts

Write a program that calculates the average of all numbers in a list.

Evaluate responses using AI:

OFF

Answer explanation

To calculate the average, sum all numbers in the list and divide by the count of numbers. This can be done using built-in functions like sum() and len() in Python.

3.

OPEN ENDED QUESTION

30 mins • 5 pts

Write a program that prints all the even numbers from 1 to 50 using a for loop.

Evaluate responses using AI:

OFF

Answer explanation

To print even numbers from 1 to 50, use a for loop that iterates through numbers 1 to 50. Check if each number is even by using the modulus operator (%). If the number % 2 equals 0, print it.

4.

OPEN ENDED QUESTION

30 mins • 5 pts

Write a program that takes a sentence as input and counts how many words it contains.

Evaluate responses using AI:

OFF

Answer explanation

To count the words in a sentence, split the string by spaces and filter out any empty strings. The length of the resulting list gives the word count.

5.

OPEN ENDED QUESTION

30 mins • 5 pts

Write a program that creates a text file named example.txt, writes a few lines to it, and then reads and prints the content.

Evaluate responses using AI:

OFF

Answer explanation

To create 'example.txt', use file handling in Python: open the file in write mode, write lines, then close it. To read, open the file in read mode, read the content, and print it. This demonstrates basic file operations.

6.

OPEN ENDED QUESTION

30 mins • 5 pts

Write a program that prints a multiplication table 10.

Evaluate responses using AI:

OFF

Answer explanation

To print a multiplication table for 10, use a loop that iterates from 1 to 10, multiplying each number by 10 and printing the result. This will display the products of 10 with numbers 1 through 10.

7.

OPEN ENDED QUESTION

30 mins • 5 pts

Write a program that stores student names and their scores in a dictionary. Then, allow the user to input a name and display the corresponding score if it exists.

Evaluate responses using AI:

OFF

Answer explanation

Create a dictionary to store names as keys and scores as values. Use input() to get a name from the user, then check if it exists in the dictionary. If it does, print the corresponding score.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?