0% found this document useful (0 votes)
12 views2 pages

Quiz Python EN (3 Hours)

The document contains a quiz consisting of five programming questions in Python. These questions involve creating functions for tasks such as finding indices of numbers that sum to a target, playing a rock-paper-scissors game, checking for palindromes, implementing a guessing game, and analyzing a sentence for word frequency and reversal. Each question specifies the expected input and output, along with additional requirements.

Uploaded by

anyejude96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Quiz Python EN (3 Hours)

The document contains a quiz consisting of five programming questions in Python. These questions involve creating functions for tasks such as finding indices of numbers that sum to a target, playing a rock-paper-scissors game, checking for palindromes, implementing a guessing game, and analyzing a sentence for word frequency and reversal. Each question specifies the expected input and output, along with additional requirements.

Uploaded by

anyejude96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Quiz Python (3h)

1)​ Question:​
Given a list of integers and a target value, returns the indices of the two
numbers whose sum equals the target. The program must be dynamic and
also use a function, such that the user enters the list and the target. If no
numbers match, return None.​

Example:​
Input: numbers = [2, 7, 11, 15], target = 9​
Output: [0, 1] because nums[0] + nums[1] == 9

2)​ Question:​
Write a program for a rock, paper, scissors game between the system and
a user. The game should last 3 rounds, and for each round, the winner
should be displayed and their points increased. At the end of the 3rd
round, the program should display the final winner and all the points.

Note that if both the system and the user choose the same choice, no one
wins and no points are added.

3)​ Question:​
Write a function to check if a string is a palindrome. If it is, use another
function to count the number of vowels and consonants found in the word,
and shift the letters by 2. The results should be displayed. Otherwise, if it is
not a palindrome, simply return the word.

Example:​
Input: against = radar, target = 9​
Output: consonants: 2(r,d) - Vowels: 1(a) - words: radar
- word with shift of of 2: arrad
4)​ Question:​
Write a program to play a guessing game. The program generates a
random number and then asks the user to guess the number. The program
should prompt the user if their guess is greater than or less than the
system number and should only exit once the user gets the correct
number.

5)​ Question:​
Write a program that takes a sentence from a user and does the following:
●​ count how many times each word appears in the sentence
●​ reverse the sentence and display the result.
●​ Count the number of words in this sentence.

The result to be displayed includes: the number of times each word


appears, the reversed sentence, and the total number of words in the
sentence

You might also like