write a code to swape from upper to lower case the given word in
Write a Python program that simulates a simple slot machine in which three numbers between 0 and 9 are randomly selected and printed side by side. The user has an initial sum of $100. The user enters his/her bet (make sure it is a valid bet, i.e., the bet is positive and less than or equal to the sum). If the three numbers are the same, the user hits the Jackpot, this means that he wins ten times his/her bet. If only two of the three numbers are the same the user wins four times his/her bet. After each round, the program outputs the sum that the user has and asks the user if he/she wish to continue playing. If yes the program repeats, else, the program displays the total winnings or losses of the user and then ends.
Make a class named Fruit with a data member to calculate the number of fruits in a basket. Create two other class named Apples and Mangoes to calculate the number of apples and mangoes in the basket. Print the number of fruits of each type and the total number of fruits in the basket.
Write a program to print the following, Given a word W and pattern P, you need to check whether the pattern matches the given word.The word will only contain letters(can be Uppercase and Lowercase). The pattern can contain letters, ? and *.
? : Can be matched with any single letter.
* : Can be matched with any sequence of letters (including an empty sequence).
If the pattern matches with the given word, print True else False.
Sample Input1
3
Hello *l?
Hell He?ll
Hell ?*
Sample Output1
True
False
True
Sample Input1
3
Hello Hell*
Hell He*ll
Hell hell*
Sample Output1
True
True
False
Write a program to print the following output.
Input
The first line contains a string.
The second line contains some space-separated strings.
Output
The output should be a single integer.
Explanation
scramble word = "tacren"
guessed words = ["trance", "recant"]
Since "trance" and "recant" both have length 6 then you score 54 pts each.
So the output is 108.
Sample Input1
tacren
trance recant
Sample Output1
108
Sample Input2
rceast
cat create sat
Sample Output2
2
Write a python program to print the following output.
Input
The first line of input contains a single line positive integer N.
The second line of input contains a space-separated integers denoting the cost of the item.
Output
The output is a single line integer.
Explanation
For example, Given N = 2 and cost = 10 200
Ram has to pay for both the items, he won't get anything for free.
So the output is 210.
Sample Input1
2
10 200
Sample Output1
210
Sample Input2
4
1 1 2 2
Sample Output2
4
Python Problem Solving
You're given a positive integer: Perform the sequence of operations as per below guidelines until the value reaches 1:
If N is even --> N / 2
If N is odd --> N * 3 + 1
Print the total number of steps it took to reach 1.
Input
The first line of input contains an integer.
Output
The output should be a single integer denoting the total number of steps.
Explanation
For Example, using N = 10 as the input, with 6 steps.
10 is even - 10/2 = 5
5 is odd - 5 * 3 + 1 = 16
16 is even - 16 / 2 = 8
8 is even - 8 /2 = 4
4 is even - 4/2 = 2
2 is even - 2/2 = 1 --> Reached 1.
So the output should be 6.
Sample Input1
10
Sample Output1
6
Sample Input2
345
Sample Output2
125
Python Program
Write a python program to print the following output.
Input
The first line contains a string S representing a unique id.
The second line contains an integer N representing group length.
Output
The output should be a single string representing the new unique id.
Sample Input1
2-4A0r7-4k
3
Sample Output1
24-A0R-74K
You are given with a list of positive integers nums, return whether there exist integers a, b, and c such that a ** 2 + b ** 2 = c ** 2.
In this exercise you will create a program that reads a letter of the alphabet from the user. If the user enters a, e, i, o or u then your program should display a message indicating that the entered letter is a vowel. If the user enters y then your program should display a message indicating that sometimes y is a vowel, and sometimes y is a consonant. Otherwise your program should display a message indicating that the letter is a consonant.