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

Write a Python program that will ask the user to enter a word as an input.

  • If the length of the input string is less than 4, then your program should print the same string as an output.
  • If the input string’s length is greater than 3, then your program should add "er" at the end of the input string.
  • If the input string already ends with "er", then add "est" instead, regardless of the length of the input string
  • If the input string already ends with "est", then your program should print the same input string as an output

Suppose you are given two strings, s1, and s2. Now, print a new string made up of the last characters and then the first characters of the input strings.



=====================================================================



Sample Input 1:



s1 = new



s2= string



Sample Output 1:



gwsn



Explanation: The last character of the String s2 is 'g'. The last character of the String s1 is 'w'. The first character of the String s2 is 's'. The first character of the String s1 is 'n'. Together they give us the ouput we want 'gwsn'.



=====================================================================



Sample Input 2:



s1 = abcd



s2= efgh



Sample Output 2:



hdea



Explanation: The last characters of the Strings s2 and s1 is 'h' and 'd' respectively while the first characters of the Strings is 'e' and 'a' respectively. Together they give us the ouput we want 'gwsn'

Number Guessing Game


In the number guessing game, the computer will randomly

select a number from a range of numbers e.g. 1-100 and then the game

will give the player five attempts to guess the number.


Gameplay:

If the player’s guess is higher than the chosen number, the

program will tell the player to try another LOWER than the

previous guess.


If the player’s guess is lower than the chosen number, the

program will tell the player to try another number HIGHER than

the previous guess.


If the player guesses the number before he consumes the five

attempts, then display congratulatory message.


I need the code to have an output stated above.


In the game Rock Paper Scissors, two players simultaneously choose one of the three options: rock, paper, scissors. If both player choose the same option, then the result is a tie. However, if they choose differently, the winner is determined as follows:


• Rock beats scissors, because a rock can break a pair of scissors

• Scissors beats paper, because scissors can cut paper

• Paper beats rock, because a piece of paper can cover a rock


Create a Python script in which a computer randomly choose

rock, paper or scissors. Let the user enter a number 1, 2, or 3 each

representing one of the three choices. Then, determine the winner.


I need the code to have an output stated above.


Create a Python script that will generate random n integers from a given start and end of a range.


I need the code to have an output stated below:


Value for n : 5

Value for start : 1

Value for end : 10

10 8 7 8 3


Write a for loop to print the numbers from 20 to 30, inclusive (this means it should include both the 20 and 30). The output should all be written out on the same line.



You decide to buy some stocks for a certain price and then sell them at another

price. Write a program that determines whether or not the transaction was

profitable.

• Take 3 separate inputs: the # of shares, the purchase

price of the stocks, and the sale price, in that order.

• You purchase the # of stocks determined by the input.

• When you purchase the stocks, you pay the price determined by the input.

• You pay your stockbroker a commission of 3% on the amount paid for

the stocks.

• Later, you sell the all of the stocks for the price determined by the input.

• You pay your stockbroker another commission of 3% on the amount

you received for the stock.


Your program should calculate your net gain or loss during this transaction and

print it in the following format:


If your transaction was profitable (or if there was a net gain/loss of 0) print:

"After the transaction, you made 300 dollars."


If your transaction was not profitable, print:

"After the transaction, you lost 300 dollars."



Machine Problem 1



Number Guessing Game



In the number guessing game, the computer will randomly select a number from a range of numbers e.g. 1-100 and then the game will give the player five attempts to guess the number.



Gameplay:



• If the player's guess is higher than the chosen number, the program will tell the player to try another LOWER than the previous guess.



• If the player's guess is lower than the chosen number, the program will tell the player to try another number HIGHER than the previous guess.



■ If the player guesses the number before he consumes the five attempts, then display congratulatory message.

Machine problem 3



In the game Rock Paper Scissors, two players simultaneously choose one of the three options: rock, paper, scissors. If both player choose the same option, then the result is a tie. However, if they choose differently, the winner is determined as follows:



• Rock beats scissors, because a rock can break a pair of scissors



• Scissors beats paper, because scissors can cut paper



• Paper beats rock, because a piece of paper can cover a rock



Create a Python script in which a computer randomly choose rock, paper or scissors. Let the user enter a number 1, 2, or 3 each representing one of the three choices. Then, determine the winner.

why using num variable please explain


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS