python_math_stat/practica/stepik/stepik_tasks/README.md

89 lines
4.9 KiB
Markdown
Raw Permalink Normal View History

# Stepik tasks
Here you can find done tasks from stepik courses.
- [10_pass_100_break](10_pass_100_break.py)
For each entered number, check: if the number is less than 10, then pass this number;
if the number is greater than 100, then break;in other cases, print this number back to the console in a separate line.
- [Counting_numbers](counting_numbers.py)
A program that reads numbers from input and after the first zero entered, prints the sum of the received numbers
2023-10-24 15:56:27 +03:00
- [Geometric figures](geometric_figures.py)
Determine the area of the shape by the sides and other indicators
- [Index of num in list](index_of_num_in_list.py)
Write a program that reads the list of numbers from the first line and the number x from the second line, which outputs all the positions where the number x occurs in the transmitted list of lst.
If the number x does not occur in the list, print the string "Отсутствует".
- [Intervals](intervals.py)
Write a program that takes an integer as input and prints True if the passed value falls within the interval (15,12](14,17)[19,+∞) and False otherwise (case matters)
- [Percentage of letters](percentage_of_letters.py)
- #1 Write a program that calculates the percentage of characters G (guanine) and C (cytosine) in an input string (the program should not be case sensitive)
- #2 Write a program that reads a string, encodes it using the proposed algorithm, and prints the encoded sequence to standard output. Encoding must be case sensitive
- [Pie](pie.py)
Determine the area of the figure using the following input data:
1) **triangle**, a, b, c - lengths of the sides of the figure
2) **rectangle**, a, b - lengths of the sides of the figure
3) **circle**, r - radius of the circle
- [Programmer's names](programmer_names.py)
> Peculiarities of word endings in Russian, therefore the task is duplicated in Russian
| English ver | Russian ver |
|:-------------|:---------------|
|Write a program that reads an integer from user inputn (non-negative), outputting this number to the console along with the word "programmer" correctly modified so that the robot can communicate normally with people, for example: 1 programmer, 2 programmers, 5 programmers| Напишите программу, считывающую с пользовательского ввода целое число n (неотрицательное), выводящее это число в консоль вместе с правильным образом изменённым словом "программист", для того, чтобы робот мог нормально общаться с людьми, например: 1 программист, 2 программиста, 5 программистов|
- [Sapper game](sapper.py)
2023-10-10 15:38:21 +03:00
The program that accepts as input : number of rows, columns and bombs and outputs the table where:
1) numbers - the count of bombs nerby and also diagonally within 1 cell
2) '*' - bombs
3) '.' - there are not bombs nearby this cell
__*Plan of solution*__:
1) create a two-dimensional list
2) fill the cells with zeros
3) -1 - bombs, fill the bombs into the cells according to the coordinates, fill in the numbers depending on the location of the bombs
4) coordinates i(row number) -1 j(column number)-1, di dj \ i+di\ j + dj\ di dj -1..1
- [Sum_num_from_last](sum_num_from_last.py)
A program that takes the left and right character from each character and combines them into one number. For the first and last numbers, the left and right numbers are the last and first numbers respectively
- [Sum_num_nearby](sum_num_nearby.py)
A program that displays the sum of the right and left numbers from the main one. For the first and last numbers, the left and right numbers are the last and first numbers respectively
2023-10-13 22:51:28 +03:00
- [Sum of squared numbers](sum_of_squared_numbers.py)
A program reads numbers from the console (one per line) until their sum is equal to 0. Then it displays the sum of the squares of these numbers.
- [Tickets](tickets.py)
A program that issues a “Lucky” or "regular" ticket, the number of which we entered. If all the numbers are the same - the ticket is lucky
2023-11-22 17:56:46 +03:00
- [Function of updating dictionary](update_dictionary.py)
Function that searches the key in dictionary and in case key is exist append value, if it doesnt exist - searches key* 2 and update, if key* 2 doesnt exist too, so add it to the dictionary with value.
The coorect output:
```python
d = {}
print(update_dictionary(d, 1, -1)) # None
print(d) # {2: [-1]}
update_dictionary(d, 2, -2)
print(d) # {2: [-1, -2]}
update_dictionary(d, 1, -3)
print(d) # {2: [-1, -2, -3]}
```
2023-11-22 23:41:21 +03:00
- [Counter the same elements](peace_and_war.py)
You input some words like: a aa abC aa ac abc bcd a (with diff redisters), then the program count the same elements and displays it in the dictionary.
```python
Example output:
a 2
aa 2
abc 2
ac 1
bcd 1
```