Given a string of length N, made up of only uppercase characters 'R' and 'G', where 'R' stands for Red and 'G' stands for Green. Find out the minimum number of characters you need to change to make the whole string of the same colour.
Temperature Conversion
You are given the temperature T of an object in one of Celsius, Fahrenheit, and Kelvin scales.
Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.
Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.
Formula to convert from Kelvin K to Celsius C is C = K - 273.
Here "C", "F", "K" represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively.
The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space.
The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places.
Input
The first line of the input contain a temperature Value in one of Celsius, Fahrenheit, and Kelvin scales.
Output
The first line of output should contain the Celsius value and the unit of the Celsius without any space.
The second line of output should contain the Fahrenheit value and the unit of the Fahrenheit without any space.
The third line of output should contain the Kelvin value and the unit of the Kelvin without any space.
Explanation
For example, if the given temperature Value is 25C then Celsius value is 25.0C, Fahrenheit value is 77.0F, and Kelvin value is 298.0K.
Abhinav and Anjali are playing Rock-Paper-Scissors game. Rock-Paper-Scissors is a hand game usually played between two people, in which each player simultaneously forms one of three shapes with an outstretched hand. These shapes are "rock", "paper" and "scissors". Based on the shapes the player chooses the outcome of the game is determined. A rock beats scissors, scissors beat paper by cutting it, and paper beats rock by covering it. If the same shape is chosen by both of the players, then it is tie. Write a program to decide the winner of each round of the game based on the shapes the players chose.
Input
The first line of input will be one of the strings "Rock", "Paper", "Scissors", representing the shape chosen by Abhinav. The second line of input will be the sting representing the shape chosen by Anjali..
Output
The output should either be "Abhinav Wins" or "Anjali Wins", based on the winner. If it is a tie, the output should be "Tie".
Explanation
For example, if player1 choice is rock and player2 choice is paper then output is "Player 2 wins"
Describe the difference between a chained conditional and a nested conditional. Give your own example of each. Do not copy examples from the textbook.
Deeply nested conditionals can become difficult to read. Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to become a single conditional, and show the equivalent single conditional. Do not copy the example from the textbook.
Given a string of length N, made up of only uppercase characters 'R' and 'G', where 'R' stands for Red and 'G' stands for Green. Find out the minimum number of characters you need to change to make the whole string of the same colour.
Input
The input will be a single line containing a string.
Output
The output should be single line containing the integer representing the minimum number of characters you need to change to make the whole string of the same colour.
Explanation
For example, if string is "GGGGGGR" . We need to change only the last character to 'G' to make the string same-coloured.then output is 1.
Describe the difference between a chained conditional and a nested conditional. Give your own example of each. Do not copy examples from the textbook.
Deeply nested conditionals can become difficult to read. Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to become a single conditional, and show the equivalent single conditional. Do not copy the example from the textbook.
Write the substitutionDecrypt method. Test your algorithm as shown below. Your code should work for any key.
Sample Output:
CipherText: gsv jfrxp yildm ulc
PlainText: the quick brown fox
The transposition cipher can be generalized to any number of rails. Write a function to implement a three-rail fence cipher that takes every third character and puts it on one of the three rails. Test your algorithm with two sample input as shown below.
Sample:
PlainText: ABCDEFGHI
CipherText: CFIBEHADG
Given the number of rows N, write a program to print the hallow diamond pattern similar to the pattern shown below.
A
B B
C C
D D
E E
D D
C C
B B
AThe input will be a single line containing a positive integer (N).
Modify the program from Lab 3 to show the shades of green and then move the turtle forward 300 steps without writing (use the penup() and pendown() turtle functions) and repeat the same loop, but backwards.
Your output should look similar to: