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
Python Program
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
rceast
cat create sat
Sample Output1
2
Sample Input2
tacren
trance recant
Sample Output2
108
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
4
1 1 2 2
Sample Output1
4
Sample Input2
2
10 200
Sample Output2
210
2 trains each traveling with a speed of 37.5km/h is aapproaching each other on the same straight track.a bird that can fly 60km/h flies off from one train when they are 90km and head directly from the other train .on approaching other train it flies back to the first and so on.total distance covered by bird is?
Chemist to determine copper concentration in rock sample. Knowing copper undergoes redox reactions, they chose to use iodometric titration for analysis. Unknown sample weighing 1.5098g was acidified with 3.0M H2SO4 to dissolve copper compounds and diluted with 30mL distilled water. This was followed by addition of excess KI producing I2 and CuI precipitate from Cu2+(Reaction 1). Then, liberated I2 reacted with excess KI forming triiodide anion(Reaction 2), which was titrated with Na2S2O3 titrant(Reaction 3). This entire solution required 17.60 mL of titrant to reach starch end point.
MW: Cu (63.546)
a. Write balanced chemical equation for Reactions 1-3
b. Write mole ratio between Cu2+ and S2O32–
Prior to titration of sample, titrant was standardized by taking 50.0 mL of 6.7863x10-3M standard KIO3 solution, acidifying, and adding KI crystals. Titration of this solution required 9.80mL to reach starch endpoint.
c. Write concentration of S2O32– titrant in M
d. Write copper content of rock sample in %w/w
A 7.70-kg steel ball at 18.7°C is dropped from a height of 12.7 m into an insulated container with 4.50 L of water at 10.1°C. If no water splashes, what is the final temperature of the water and steel? The specific heat of steel and water is 450 J/(kg·K) and 4186 J/(kg·K) respectively.
A monatomic ideal gas at 27.0°C undergoes a constant volume process from A to B and a constant-pressure process from B to C.
where P1 = 2.70, P2 = 5.40, V1 = 2.70, and V2 = 5.40.
Find the total work done on the gas during these two processes.
Find the sum-of-products expansions of these boolean functions: F(x,y,z) = x.