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

Create a function with a local variable. Show what happens when you try to use that variable outside the function. Explain the results.



Write a function in this file called nine_lines that uses the function three_lines (provided below) to print a total of nine lines.


Now add a function named clear_screen that uses a combination of the functions nine_lines, three_lines, and new_line (provided below) to print a total of twenty-five lines. The last line of your program should call first nine_lines and then the clear_screen function.


The function three_lines and new_line are defined below so that you can see nested function calls. Also, to make counting “blank” lines visually easier, the print command inside new_line will print a dot at the beginning of the line:


def new_line():


print('.')


def three_lines():


new_line()


new_line()


new_line()



Define a function that takes an argument. Call the function. Identify what code is the argument and what code is the parameter.

Example 2: Call your function from Example 1 three times with different kinds of arguments: a value, a variable, and an expression. Identify which kind of argument is which.

Example 3: Create a function with a local variable. Show what happens when you try to use that variable outside the function. Explain the results.

Example 4: Create a function that takes an argument. Give the function parameter a unique name. Show what happens when you try to use that parameter name outside the function. Explain the results.

Example 5: Show what happens when a variable defined outside a function has the same name as a local variable inside a function. Explain what happens to the value of each variable as the program runs.

Numbers in String - 1

Given a string, write a program to return the sum and average of the digits of all 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 digits of all 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 digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line.

Sample Input 1

I am 25 years and 10 months old

Sample Output 1

8

2.0

Sample Input 2

Tech Foundation 35567

Sample Output 2

26

5.2


Ordered Matrix

Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.

Input

The first line of input will contain two space-separated integers, denoting the M and N.

The next M following lines will contain N space-separated integers, denoting the elements of each list.

Output

The output should be M lines containing the ordered matrix.

Note: There is a space at the end of each line.

Explanation

For example, if the given M is 3 and N is 3, read the inputs in the next three lines if the numbers given in the next three lines are the following.

1 20 3
30 10 2
5 11 15


By ordering all the elements of the matrix in increasing order, the ordered matrix should be

1 2 3
5 10 11
15 20 30

Sample Input 1

3 3

1 20 3

30 10 2

5 11 15

Sample Output 1

1 2 3

5 10 11

15 20 30

Sample Input 2

2 5

-50 20 3 25 -20

88 17 38 72 -10

Sample Output 2

-50 -20 -10 3 17

20 25 38 72 88


String Rotation

Given two strings(S1 and S2), write a program to determine if a string S2 is a rotation of another string S1.

Input

The first line of the input will be a string S1.

The second line of the input will be a string S2.

Output

If string S2 is a rotation of another string S1, print number of right rotations made by string S1 to match the string S2. Otherwise, print "No Match".

Where right rotation means all elements are moving towards the right side by one place where the last element will be placed in the first place example, one right rotation of "python" is "npytho".

Explanation

For example, if the given strings S1 and S2 are "python" and "onpyth",

The first right rotation of s1 is "npytho" which is not equal to string S2"onpyth"

The second right rotation of s2 is "onpyth" which is equal to string S2 "onpyth".

So the output should be 2

Sample Input 1

python

onpyth

Sample Output 1

2


Smallest Missing Number

Given a list of numbers, write a program to print the smallest positive integer missing in the given numbers.

Input

The input will be a single line containing numbers separated by space.

Output

The output should be a single line containing the smallest missing number from given numbers.

Explanation

For example, if the input numbers are 3, 1, 2, 5, 3, 7, 7.

The number 1, 2, 3 are present. But the number 4 is not. So 4 is the smallest positive integers that is missing from the given numbers.

Sample Input 1

3 1 2 5 3 7 7

Sample Output 1

4

Sample Input 2

5 5 2 3 1 8 8 4

Sample Output 2

6


New Year Countdown

Given date-time D, write a program to print the time left for the next New Year.

Input

The input will be a single line containing the date-time in the string format similar to "Dec 30 2020 02:43 PM".

Output

The output should be a single line containing hours and minutes left for the next new year in the format similar to "33 hours 17 minutes".

Explanation

For example, if the given date-time is "Dec 30 2020 02:43 PM", the difference between "Dec 30 2020 02:43 PM" and "Jan 1 2021 00:00 AM" is 1 day 9 hours 17 minutes. The difference in hours and minutes is 1 * 24 + 9 hours and 17 minutes. So the output should be "33 hours 17 minutes".

Sample Input 1

Dec 30 2020 02:43 PM

Sample Output 1

33 hours 17 minutes

Sample Input 2

Jan 31 2020 04:43 AM

Sample Output 2

8059 hours 17 minutes


Weekends

Given two dates D1 and D2, write a program to count the number of Saturdays and Sundays from D1 to D2 (including D1 and D2).

The date in string format is like "8 Feb 2021".

Input

The first line of input will contain date D1 in the string format.

The second line of input will contain date D2 in the string format.

Output

The output should be a single line containing two integers separated by space.

Explanation

For example, if the given dates are "25 Jan 2021" and "14 Feb 2021", the Saturdays and Sundays dates from "25 Jan 2021" to "14 Feb 2021" are

"30 Jan 2021" is a Saturday

"31 Jan 2021" is a Sunday

"6 Feb 2021" is a Saturday

"7 Feb 2021" is a Sunday

"13 Feb 2021" is a Saturday

"14 Feb 2021" is a Sunday

So the output should be

Saturday: 3

Sunday: 3

Sample Input 1

25 Jan 2021

14 Feb 2021

Sample Output 1

Saturday: 3

Sunday: 3


Hollow Rectangle - 2

Write a program to print a rectangle pattern of

M rows and N columns using the characters as shown below.Input

The first line of input is an integer

M. The second line of input is an integer N.Explanation

In the given example,

3 rows and 10 columns.Therefore, the output should be


LATEST TUTORIALS
APPROVED BY CLIENTS