python_math_stat/practica/stepik/stepik_tasks/README.md
2023-11-22 23:41:21 +03:00

4.9 KiB
Raw Permalink Blame History

Stepik tasks

Here you can find done tasks from stepik courses.

  • 10_pass_100_break

    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

    A program that reads numbers from input and after the first zero entered, prints the sum of the received numbers

  • Geometric figures

    Determine the area of the shape by the sides and other indicators

  • Index of num in list

    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

    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

    • #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

    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

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

    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

    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

    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

  • Sum of squared numbers 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

    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

  • Function of updating dictionary

    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:

    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]}
    
  • Counter the same elements

    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.

    Example output: 
    a 2
    aa 2
    abc 2
    ac 1
    bcd 1