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

Using while loop and If statements, print all the letters in the following string except for the letter ‘g’ and ‘o’. (5 marks)

‘goodbyemybaloon’

Hint: use continue keyword. Continue and Break are keywords to control the flow of a loop. Continue keyword returns the control to the beginning of the loop. Now try using the break keyword and see what happens. Expain your findings.


Given a string, write a program to print a secret message that replaces characters with numbers 'a' with 1, 'b' with 2, ..., 'z' with 26 where characters are separated by '-'.


Note: You need to replace both uppercase and lowercase characters. You can ignore replacing all characters that are not letters.


Input:-

The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).


Output:-

The output should be a single line containing the secret message. All characters in the output should be in lower case.


For Example -

Input 1:-

python


Output 1:-

16-25-20-8-15-14


Input 2:-

Foundations

Output 2:-

6-15-21-14-4-1-20-9-15-14-19


Input 3:-

python learning

Output 3:-

16-25-20-8-15-14 12-5-1-18-14-9-14-7

Note:- there is a space between two strings that means 16-25-20-8-15-14 12-5-1-18-14-9-14-7


We want given both three inputs they can get both three outputs we code was run one by one input and output


Using while loop and If statements, print all the letters in the following string except for the letter ‘g’ and ‘o'.Sentence is  ‘goodbyemybaloon’. Use break and continue in program as well.

Write a program that takes an input letter from the user until a vowel is entered.  Use infinite loops (while True:)


Write a program that rolls a dice until the user chooses to exit the program.

Use random module to generate random numbers.


Non-Adjacent Combinations of Two Words

Given a sentence as input, find all the unique combinations of two words and print the word combinations that are not adjacent in the original sentence in lexicographical order.Input


Sample Input 1

python is a programming language


Sample Output 1

a language

a python

is language

is programming

language python

programming python


Sample Input 2

raju always plays cricket


Sample Output 2

always cricket

cricket raju

plays raju




Secret Message - 1

Given a string, write a program to mirror the characters of the string in alphabetical order to create a secret message.

Input

The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).Output

The output should be a single line containing the secret message. All characters in the output should be in lower case.

Explanation

For example, if the given input is "python", "p" should replaced with "k", similarly "y" with "b", "t" with "g", "h" with "s", "o" with "l", "n" with "m". So the output should be "kbgslm".


Input 1:-

python

Output 1:-

kbgslm


Input 2:-

Foundations

Output 2:-

ulfmwzgrlmh


Input:-3

python learning

Output 3:-

kbgslm ovzimrmt


Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.


Input

The input will be a single line containing a string.


Output

The output should contain the sum and average of the numbers that appear in the string.

Note: Round the average value to two decimal places.


Explanation

For example, if the given string is "I am 25 years and 10 months old", the numbers are 25, 10. Your code should print the sum of the numbers(35) and the average of the numbers(17.5) in the new line.


Input 1:-

I am 25 years and 10 months old

Output 1:-

35

17.5


Input 2:-

Tech Foundation 35567

Output 2:-

35567

35567.0


Input 3:-

Anjali25 is python4 Expert

Output 3:-

29

14.5


We want given both three inputs they can get both three outputs we code was run one by one input and output


A number, a, is a power of b if it is divisible by b and a/b is a power of b. Write a function called is_power that takes parameters a and b and returns True if a is a power of b. Note: you will have to think about the base case. After writing your is_power function, include the following test cases in your script to exercise the function and print the results:

print("is_power(10, 2) returns: ", is_power(10, 2))

print("is_power(27, 3) returns: ", is_power(27, 3))

print("is_power(1, 1) returns: ", is_power(1, 1))

print("is_power(10, 1) returns: ", is_power(10, 1))

print("is_power(3, 3) returns: ", is_power(3, 3))

You should submit a script file and a plain text output file (.txt) that contains the test output. Multiple file uploads are permitted. Don’t forget to include descriptive comments in your Python code.


Invent your own function that does some useful computation of your choosing. Do not copy the function from somewhere else. Use incremental development, and record each stage of the development process as you go. Finally, print output that demonstrates that the function works as you intended.

Include all of the following in your Learning Journal:

  • An explanation of each stage of development, including code and any test input and output.
  • The output of three calls to your function with different arguments.
LATEST TUTORIALS
APPROVED BY CLIENTS