Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

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.

Sample Input 1

25C

Sample Output 1

25.0C

77.0F

298.0K

Sample Input 2

37.5F

Sample Output 2

3.06C

37.5F

276.06K


heck values in the Array is a String

Given an array

myArray, write a Python program to check whether each value of the array is a string or not .


Input:

  • The input will be a single line containing an array myArray

Output

  • The output should be a single line containing a boolean value


input:

["apple","goa","hyderabad"]

output:

true


input:

["dog","fox","70","movie"]

output:

false





Split and Replace


Given three strings


inputString, separator and replaceString as inputs. Write a Python program to split the

inputString with the given separator and replace strings in the resultant array with the replaceString whose length is greater than 7.


input:

Javascript-is-amazing

-

programming



output:

programming is amazing



input:

the&lion&king

&

tiger



output:

the lion king



Square at Alternate Indices

Given an array

myArray of numbers, write a function to square the alternate numbers of the myArray, starting from index 0.Input

  • The input will be a single line containing an array myArray

Output

  • The output should be a single line containing an array with alternate numbers squared

Constraints

  • Each value in the array must be a number

input:

[1,2,3,4,5]

output:

[1,2,9,4,25]


input:

[2,4]

output:

[4,4]



Consider the 2021 puzzle, which is a lot like the 15-puzzle we talked about in class, but: (1) it’s played on a 4x5 board, (2) it has 20 tiles, so that there are no empty spaces on the board, (3) instead of moving a single tile into an open space, a move in this puzzle consists of either (a) sliding an entire row of tiles left or right, with the left- or right-most tile “wrapping around” to the other side of the board, or (b) sliding an entire column of the puzzle up or down, with the top- or bottom-most tile “wrapping around.” However, each given row or column can only be slid in a certain way: the first and third rows can only be slid left; the second and fourth rows can only be slid right; the first, third, and fifth columns can only be slid up; and the second and fourth columns can only be slid down. For example, here is a sequence of two moves on such a puzzle: 2 1 2 3 4 5 1 2 3 4 5 1 17 3 4 5 6 7 8 9 10 → 10 6 7 8 9 → 10 2 7 8 9 11 12 13 14 15 11 12 13 14 15 11 6 13 14 15 16 17 18 19 20 16 17 18 19 20 16 12 18 19 20 The goal of the puzzle is to find a short sequence of moves that restores the canonical configuration (on the left above) given an initial board configuration. We’ve provided skeleton code to get you started. You can run the skeleton code on the command line: python3 solver2021.py [input-board-filename] where input-board-filename is a text file containing a board configuration (we have provided an example). You’ll need to complete the function called solve(), which should return a list of valid moves, each of which is encoded as a letter L, R, U, or D for left, right, up, or down, respectively, and a row or column number (indexed beginning at 1). (For instance, the moves in the picture above would be R2 D2.) The initial code does not work correctly. Using this code as a starting point, implement a fast version, using A* search with a suitable heuristic function that guarantees finding a solution in as few moves as possible. Try to make your code as fast as possible even for difficult boards, although it is not necessarily possible to write code that will be able to quickly solve all puzzles. In addition to doing your own testing, it is important that you test your program on the SICE Linux servers to ensure that we will be able to run it and grade it accurately


Given an integer N, write a program to print the sandglass star pattern, similar to the pattern shown below.
* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

Input

The input will be a single line containing a positive integer (N).
Output

The output should contain the asterisk(*) characters in the sandglass star pattern.
Note: There is a space after each asterisk(*) character.
Explanation

For example, if the given number is 5, the pattern should contain 9 rows and 9 columns as shown below.
* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

Sample Input 1
5
Sample Output 1
* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

Sample Input 2
3
Sample Output 2
* * * 
 * * 
  * 
 * * 
* * * 
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
    A

The input will be a single line containing a positive integer (N).
Output

The output should be (2*N - 1) rows and (2*N - 1) columns containing the alphabet characters in the hollow diamond pattern.
Explanation

For example, if the given number is 5, the pattern should contain 9 rows and 9 columns as shown below.
    A
   B B
  C   C
 D     D
E       E
 D     D
  C   C
   B B
    A

Sample Input 1
5
Sample Output 1
    A
   B B
  C   C
 D     D
E       E
 D     D
  C   C
   B B
    A

Sample Input 2
3
Sample Output 2
  A
 B B
C   C
 B B
  A
Given a string in camel case, write a python program to convert the given string from camel case to snake case.
Input

The input will be a single line contain a string.
Output

The output should contain the given word in snake case.
Explanation

For example, if the given word is "PythonLearning" in camel case, your code should print given word in snake case "python_learning".
Sample Input 1
PythonLearning
Sample Output 1
python_learning

Sample Input 2
CamelCase
Sample Output 2
camel_case
Given a number N, write a program to print a triangular pattern of N lines with numbers as shown below.
Input

The input will be a single line containing a positive integer (N).
Output

The output should be N rows with numbers.
Note: There is no space between the numbers.
Explanation

For example, if the given number of rows is 4,
your code should print the following pattern
1
121
12321
1234321

Sample Input 1
4
Sample Output 1
1
121
12321
1234321

Sample Input 2
9
Sample Output 2
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321


Write a program to print the right alphabetic triangle up to the given N rows.
Input

The input will be a single line containing a positive integer (N).
Output

The output should be N rows with letters.
Note: There is a space after each letter.
Explanation

For example, if the given number of rows is 4,
your code should print the following pattern.
A 
A B 
A B C 
A B C D

Sample Input 1
4
Sample Output 1
A 
A B 
A B C 
A B C D 

Sample Input 2
6
Sample Output 2
A 
A B 
A B C 
A B C D 
A B C D E 
A B C D E F 


LATEST TUTORIALS
APPROVED BY CLIENTS