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 program that ask the user to enter the current year and the year of birth. Then, the program should compute the age by subtracting the year of birth from the current year and display the result (which represents the age). Use the following formula: 𝐴𝑔𝑒 = π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘ π‘¦π‘’π‘Žπ‘Ÿ βˆ’ π‘π‘–π‘Ÿπ‘‘β„Ž π‘¦π‘’π‘Ž


how to Write a program that asks the user to enter the number of people he wants to compute the ticket price for. Then, your program should ask the user to enter the age for each person and calculate the ticket price of each entered age using the given formula, then display the result with two digits after the decimal point.π‘‡π‘–π‘π‘˜π‘’π‘‘ π‘ƒπ‘Ÿπ‘–π‘π‘’ = βˆšπ‘Žπ‘”π‘’ + 10Β 


given a list of M numbers and a positive integers N, print the sum of numbers whose position in the list is divisible by N .consider that the position of numbers range from 1 to N


INPUT:

the first line contains two-spaced integers N, M

the second line contain M space-separated integers.


output:

print a single integer representing the required sum


explanation:

Sample Output1

Given N=1 , M=7

and the number list = [4,8,6,6,7,9,3]

As every position is divisible by 1,

4+8+6+6+7+9+3=43

so the output should be 43


Write a function(preLetterCase) that accepts two parameters ( a string ,and a letter). The function must return the string with all characters before the first instance of the letter converted to lowercase and all other characters converted to uppercase. Hence, if the specified letter is the first character of the string then the entire string will be converted to uppercase. The new string should be returned by the function.


e.g.

  1. preLetterCase ("CAtCHa","a") -> "cATCHA",
  2. preLetterCase ("Preteen","e") -> "prETEEN"
  3. preLetterCase ("You've got this", "m") -> "you've got this"
  4. preLetterCase ("Keep trying", "k") -> "KEEP TRYING"

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.

For example: If the given number is 4 --

1

121

12321

1234321


If given number is 7 --

1

121

12321

1234321

123454321

12345654321

1234567654321


Note: In left hand side there will be no gap ,it should look like Right Triangle.

Coloring the blocks question :


Find total cost of coloring each block out of 3 colors such that cost should be minimum and not adjacent


B. There are n blocks placed in a row. Each block must be covered with one of the three colors available, but no two adjacent blocks can be the same color. The cost of coloring each block varies and is given in an array. Given the cost of using each color on each block, determine the minimum cost to color all the blocks.


C. Given colors price in rows, select a min price from the row and no two adjacent rows should have the same minimum price .


input = 3


1 2 3


4 3 2


8 3 2


output: 1+2+3 = 6



D. colored blocks


input = 3


1 2 2


1 2 2


1 2 1


output= 4


E. color cost picker


Input :[1 2 3]


[2 1 3]


[2 1 1]


Output : 1+2+1= 4


Finding the cheapest color and add them



Right Angle Triangle

This is the code and it doesn't run completely, I don't know what's wrong because it also says that there is no error/s at all. Hope you help me with this.



ign = input("Pick an In Game Name!: ")


print(" Welcome to the guessing game ", ign ,"! ")



import random


def guess_number(s):


randomnum = random.randint (1, s )


guessnum = 0


while guessnum != randomnum:


guessnum = int(input(f"Guess the number, choose an integer from 1 -{s}:"))



if guessnum < randomnum:


print ("Guess again the value is low!!")



elif guessnum > randomnum:


print ("Guess again the value is high!!")



print (" Congratulations! You guessed ",randomnum," Right! ")



guess_number= 10

3.Β In or Out

byΒ CodeChum Admin

I'm quite into games now, so how about we play In or Out! When a given number is even, the team scores so we shall print "In", but if it's not an even number, then we print "Out". Simple, right?


Now let's get this game started.


Input

A line containing an integer.

35

Output

A line containing a string.

Out




Guessing numbers

Rahul is playing a guessing number game with computer . the objective of the game is to guess the number that computer think . A guess is "correct" when the guess exactly matches the computer number. After each guess by Rahul, the computer will give a score comprising black & white coins:

Black coins = guessed digit is present in the computer's number and in same position

white coins =Β guessed digit is present in the computer's number and in another position

your task is to find out the number of black coins and number of white coins

Input:

The first line of input contains two space-separated integers

denoting the Rahul's Guess and the computer's Number.

Output:

The output should be a string denoting the number of Black coins and the number of White coins in the format as shown in the same output.

sample output:

given rahul=1423, computer=1234

so the output should be "blacksΒ :Β 1Β whitesΒ :Β 3 "

sample input2;

1423 5678

blacksΒ Β :Β Β 0Β whitesΒ :Β 0


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS