Tasks for procedures and functions


Plus
Pin


Problem description Progress
ID 39821. Exercise 1
Темы: Tasks for procedures and functions   

Complete the f(n) function so that the program displays the number 20 on the screen.

ID 39822. Task 2
Темы: Tasks for procedures and functions   

Complete the f(n) function so that the program displays the number 13 on the screen.

ID 39823. Task 3
Темы: Tasks for procedures and functions   

Complete the f(n) function so that the program displays two lines with values
100
100
It is forbidden to create new variables!

ID 39824. Task 4
Темы: Tasks for procedures and functions   

Complete the  f1(n) function so that the program displays the number 119.

ID 39825. Task 5
Темы: Tasks for procedures and functions   

Complete the  f1(n)  and f2(n) functions so that the program displays the number 29.

ID 39826. Task 6
Темы: Tasks for procedures and functions   

The program should display the number 75.
Decorate the procedure call f1(a, b) in the program.

ID 39828. Sum of fractions
Темы: Tasks for procedures and functions   

The program calculates the value of the expression
\(ans = {2 + \sqrt{2} \over {5 + \sqrt{5}}} + {5 + \sqrt{5} \over {13 + \sqrt {13}}}+{13 + \sqrt{13} \over {8 + \sqrt{8}}}\).

For calculation, the drop(a, b) function is used, which calculates the value of one term.
Write the missing line in this function.

ID 39829. Number of lucky six digits
Темы: Tasks for procedures and functions   

Determine the number of six-digit "happy" numbers. "Happy" we will call such a six-digit number, in which the sum of its first three digits is equal to the sum of its last three digits. 
Fill in the gaps in the program.

The  sum3(n) function calculates the sum of the digits of a three-digit number.
The happy(n) function determines whether the number n is happy. The happy(n) function uses the sum3(n) function to do its job.

ID 39831. Replacing letters, excluding first and last
Темы: Tasks for procedures and functions   

The program replaces in the string s all letters 'h' to 'H', except for the first and last occurrence. Insert the missing lines.
 

Examples
# Input Output
1 In the hole in the ground there lived a hobbit In the Hole in tHe ground tHere lived a hobbit

ID 39832. Lines with vowels and consonants
Темы: Tasks for procedures and functions    Strings    Symbols   

Write a vowels_count function that takes a string and counts the number of English vowels in it.
English vowels: a, e, i, o, u, y.

Using this function, define two lines:
s1 - the string with the largest number of vowels (if there are several such strings, take the one that occurs first).
s2 - the string with the smallest number of consonants (if there are several such strings, take the one that occurs first).


Input
The first line contains a natural number n (1 < n <= 10) - the number of lines. Next come n lines. Each line consists of small English letters and spaces.

Imprint
Print two lines on the screen: first, the line s1, then, on a new line, s2. Align the smallest of these strings with the largest one by adding the characters '*'.
 

Examples
# Input Output
1 4
mama papa
doughter son
brother sister
grandmama grandpa
grandmama grandpa
********mama papa
 

ID 42839. Pixel screen
Темы: Procedures and functions    Tasks for procedures and functions   

The pixel screen displays each digit as a 3x5 picture.

1 2 3 4 5
 *
 *
 *
 *
 *
***
  *
***
*
***
***
  *
***
  *
***
* *
* *
***
  *
  *
***
*
***
  *
***
6 7 8 9 0
***
*
***
* *
***
***
  *
 *
*
*
***
* *
***
* *
***
***
* *
***
  *
***
***
* *
* *
* *
***

The input to the program is a natural number n (n <= 109).

Print this number as a picture on a pixel screen. Print each number on a new line. The order of the digits must match the order of the digits in the original number (that is, the first digit is displayed first, then the second, etc.). If there is nothing else in the string after the asterisk (*), then no spaces are required.

 
 
Examples
# Input Output
1 12
 *
 *
 *
 *
 *
***
  *
***
*
***

ID 42871. Minimum Prime Divisor
Темы: Procedures and functions    Tasks for procedures and functions   

Alice knows that if a number n has no divisor less than or equal to\(\sqrt n\), then the number n is a prime number and its minimum prime divisor is the number itself n. You have been asked to write a program that will find the minimum prime divisor of any number.

Make your decision using functions. Write the following functions:
- the isPrime(n) function, which will take an integer and return True if the number is prime and False if it is not prime.
- minDivisor(n) function, which will return the minimum simple divisor.

The main program must contain a number input, a minDivisor(n) function call, and a response output.

Input
The program receives as input a natural number n > 1.

Imprint
Print the answer to the problem.
 

Examples
# Input Output
1 4 2
2 5 5

ID 42872. Access code
Темы: Procedures and functions    Tasks for procedures and functions   

Alice decided that she needed to put in an access code to control the ship. She believes that the access code should be of the form a:b:c, where a, b and c are integers. Moreover, the number a must be simple, the number b must be a palindrome, and the number c must be even. Captain Green came up with the code.

You've been given the task of writing a program that would print True if a given access code matches the rules and False if it doesn't. So that your program can be used for other checks, the captain asks you to issue a program using three functions:
- isPrime(n) - a function that determines whether the number n is prime or not;
- isPalindrome(n) - a function that determines whether the number n is a palindrome;
- isEven(n) - a function that determines whether the number n is even.

All checks of a number for primality, palindrome and evenness must be carried out only using these functions!

Input
The program receives one string as input - the access code that Captain Zeleny came up with.

Imprint
Print True if the access code matches Alice's rules, otherwise print False.
 

Examples
# Input Output
1 7:101:14 True
2 101:101:101 False
3 qwerty False