Вопрос Информатика 8 класс помогите,нужна программа для python

Регистрация
17 Окт 2013
Сообщения
84
Репутация
-3
Спасибо
0
Монет
0
1. Ввести семизначное число. Найти сумму и произведение цифр, стоящих на нечетных местах. Пример: 1234567.

Сумма равна =1+3+5+7=17. Произведение=105.

2. Дана сторона квадрата a. В квадрат вписана окружность, в окружность вписан еще квадрат. Найти площадь закрашенной части окружности. Изображение в графическом файле kvadrat.bmp.
308729201_81aa4199be5e30e0ab99e265ee3ad5ea_800.jpg

 
Вот как ты сам думаешь? Люди сейчас все бросили и кинулись решать твои задачки,…… Ну, ради разминки, что-нибудь уж очень интересное – и можно…… Но….на хрен!!!
 
Прошу пардону, но 1+3+5+7=16, а не 17 n = int(input()[::-1])
s,p,i = 0,1,1
while n > 0:
if i % 2:
s += n % 10
p *= n % 10
n //= 10
i += 1
print(s, p)
 
from PIL import Image
import pytesseract

# Load the image from the file system
img_path = '/mnt/data/image.png'
img = Image.open(img_path)

# Since OCR may not be effective on this image due to its simplicity and lack of actual text,
# let's try to analyze the image directly to find the side length 'a' by finding the width of the square.
# The image appears to have a large square with a smaller square inside it, both aligned to the bottom left corner.

# Convert the image to black and white to simplify analysis
bw_img = img.convert('1')

# Get the size of the image
width, height = bw_img.size

# Scan the image horizontally from the left until we find the first black pixel
# This will be the left edge of the outer square
for x in range(width):
if bw_img.getpixel((x, height // 2)) == 0: # Look at the middle of the height for a horizontal line
left_edge = x
break

# Scan the image horizontally from the left edge to find the first white pixel
# This will be the right edge of the outer square
for x in range(left_edge, width):
if bw_img.getpixel((x, height // 2)) == 255:
right_edge = x
break

# The length of the side 'a' is the difference between the right and left edges
side_length_a = right_edge - left_edge
side_length_a
 
Назад
Сверху