Question
Use loops in python for solving these problems: 1.Alice and Bob decided to play a game in which only one must win. Alice moves the
Use loops in python for solving these problems:
1.Alice and Bob decided to play a game in which only one must win. Alice moves the first and Bob the second. The game consists of choosing elements from the list numbers. Numbers are chosen, one at a time and after the choice was made, the chosen element is removed from the list. Who have no choice of an element loses the game. Alice and Bob choose only the elements that are palindromes (121, 656, 444). A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward. Print each step of the game in a new line.
Example: Input: numbers = [212, 100, 131]
Output:
Alice choses 212
Bob choses 131
Noooo, Alice has lost!
Input: numbers = [4114, 202, 111, 34, 17, 101, 44]
Alice choses 101
Bob choses 4114
Alice choses 202
Bob choses 111
Alice choses 44
Noooo, Bob has lost!
2) Given a paragraph of the text, in which the sentences are separated by a dot (.). Construct a list of sentences of the given text, which starts with an uppercase letter in range A-P.
Example:
Input: Programming is the process of creating a set of instructions that tell a computer how to perform a task. Programming can be done using a variety of computer programming languages, such as JavaScript, Python, and C++. Different programming languages support different styles of programming. This determines different programming paradigms.
Output: [Programming is the process of creating a set of instructions that tell a computer how to perform a task, Programming can be done using a variety of computer programming languages, such as JavaScript, Python, and C++, Different programming languages support different styles of programming]
Notice that the sentence This determines different programming paradigms was not included, because it starts with the letter T that is not in the range A-P.
5) Given a list of words countries and list of the areas of the given countries. Find a country with the largest area. The name of the country also must satisfy the following conditions:
a) The word does not include any of these symbols - [z,k,t, u]
b) The word has an even length
Example:
Input: countries = [Ecuador, USA, Ghana, Germany,Armenia, Cuba, Norway],
areas = [248360, 9147420, 227540, 348560, 28470, 106440, 365268]
Output: The largest country in the list that satisfy conditions is Norway with the area of 365268.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started