Code Monkey home page Code Monkey logo

dz2second_seminar's Introduction

  1. Напишите программу, которая принимает на вход вещественное число и показывает сумму его цифр. Пример:
  • 6782 -> 23
  • 0,56 -> 11
real_number = input('Введите вещественное число: ')
sum = 0
for i in real_number:
    if i != '.':
        sum += int(i)
print(sum)
  1. Напишите программу, которая принимает на вход число N и выдает набор произведений чисел от 1 до N. Пример:
  • пусть N = 4, тогда [ 1, 2, 6, 24 ] (1, 1 * 2, 1 * 2 * 3, 1 * 2 * 3 * 4)
n = int(input('Введите число: '))
product_numbers = 1
for i in range(1, n + 1):
    product_numbers *= i
    print(product_numbers, end =' ')
  1. Задайте список из n чисел последовательности $(1+ 1 /n)^n$ и выведите на экран их сумму.
n = int(input('Введите число: '))
spisok = [] 

for i in range(1, n + 1):
    spisok.append((1 + 1/i)*i)
print(spisok)    
print(int(sum(spisok)))
  1. Реализуйте алгоритм перемешивания списка.
import random
list = ['a', 'b', 'c', 'd', 'e']
print(list)
random.shuffle(list)
print(list)

dz2second_seminar's People

Contributors

igor8814 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.