设为首页收藏本站

经济影院--温州大学公选课网站

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
热搜: 活动 交友 discuz
楼主: 李子羽
打印 上一主题 下一主题

不是说可以随便水 吗

  [复制链接]

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
181#
发表于 2023-6-13 22:42:46 | 只看该作者
def is_perfect_number(n):
    sum = 0
    for i in range(1, n):
        if n % i == 0:
            sum += i
    return sum == n

for i in range(1, 1001):
    if is_perfect_number(i):
        print(str(i) + " its factors are ", end="")
        for j in range(1, i):
            if i % j == 0:
                print(j, end=" ")
        print()
回复 支持 反对

使用道具 举报

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
182#
发表于 2023-6-13 22:43:55 | 只看该作者
def sum_of_digits(number):
    return sum(int(digit) for digit in str(number))

def find_self_dividing_numbers(n):
    self_dividing_numbers = []
    for i in range(10, n + 1):
        if i % sum_of_digits(i) == 0:
            self_dividing_numbers.append(i)

    return self_dividing_numbers

n = int(input())
self_dividing_numbers = find_self_dividing_numbers(n)
for number in self_dividing_numbers:
    print(number)

回复 支持 反对

使用道具 举报

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
183#
发表于 2023-6-13 22:44:50 | 只看该作者
def sum_of_digits(number):
    return sum(int(digit) for digit in str(number))

def find_self_dividing_numbers(n):
    self_dividing_numbers = []
    for i in range(10, n + 1):
        if i % sum_of_digits(i) == 0:
            self_dividing_numbers.append(i)

    return self_dividing_numbers

n = int(input())
self_dividing_numbers = find_self_dividing_numbers(n)
for number in self_dividing_numbers:
    print(number)
回复 支持 反对

使用道具 举报

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
184#
发表于 2023-6-13 22:45:21 | 只看该作者

def sum_of_digits(number):
    return sum(int(digit) for digit in str(number))

def find_self_dividing_numbers(n):
    self_dividing_numbers = []
    for i in range(10, n + 1):
        if i % sum_of_digits(i) == 0:
            self_dividing_numbers.append(i)

    return self_dividing_numbers

n = int(input())
self_dividing_numbers = find_self_dividing_numbers(n)
for number in self_dividing_numbers:
    print(number)
回复 支持 反对

使用道具 举报

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
185#
发表于 2023-6-13 22:46:45 | 只看该作者

def sum_of_digits(number):
    return sum(int(digit) for digit in str(number))

def find_self_dividing_numbers(n):
    self_dividing_numbers = []
    for i in range(10, n + 1):
        if i % sum_of_digits(i) == 0:
            self_dividing_numbers.append(i)

    return self_dividing_numbers

n = int(input())
self_dividing_numbers = find_self_dividing_numbers(n)
for number in self_dividing_numbers:
    print(number)
回复 支持 反对

使用道具 举报

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
186#
发表于 2023-6-13 22:48:30 | 只看该作者


def sum_of_digits(number):
    return sum(int(digit) for digit in str(number))

def find_self_dividing_numbers(n):
    self_dividing_numbers = []
    for i in range(10, n + 1):
        if i % sum_of_digits(i) == 0:
            self_dividing_numbers.append(i)

    return self_dividing_numbers

n = int(input())
self_dividing_numbers = find_self_dividing_numbers(n)
for number in self_dividing_numbers:
    print(number)
回复 支持 反对

使用道具 举报

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
187#
发表于 2023-6-13 22:55:36 | 只看该作者
import math   class Shape:     PI = 3.14   class Cylinder(Shape):     def __init__(self, radius, height):         self.radius = radius         self.height = height      def surface_area(self):         return 2 * self.PI * self.radius * (self.radius + self.height)      def volume(self):         return self.PI * self.radius ** 2 * self.height   class Sphere(Shape):     def __init__(self, radius):         self.radius = radius      def surface_area(self):         return 4 * self.PI * self.radius ** 2      def volume(self):         return 4 / 3 * self.PI * self.radius ** 3   class Cube:     def __init__(self, edge_length):         self.edge_length = edge_length      def surface_area(self):         return 6 * self.edge_length ** 2      def volume(self):         return self.edge_length ** 3   class Cuboid:     def __init__(self, length, width, height):         self.length = length         self.width = width         self.height = height      def surface_area(self):         return 2 * (self.length * self.width + self.width * self.height + self.height * self.length)      def volume(self):         return self.length * self.width * self.height   N = int(input()) for _ in range(N):     r_cylinder, h_cylinder = map(float, input().split())     r_sphere = float(input())     edge_cube = float(input())     l_cuboid, w_cuboid, h_cuboid = map(float, input().split())      cylinder = Cylinder(r_cylinder, h_cylinder)     sphere = Sphere(r_sphere)     cube = Cube(edge_cube)     cuboid = Cuboid(l_cuboid, w_cuboid, h_cuboid)      shapes = [cylinder, sphere, cube, cuboid]      for shape in shapes:         print(f"{shape.surface_area():.2f} {shape.volume():.2f}")
回复 支持 反对

使用道具 举报

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
188#
发表于 2023-6-13 22:56:03 | 只看该作者
import math


class Shape:
    PI = 3.14


class Cylinder(Shape):
    def __init__(self, radius, height):
        self.radius = radius
        self.height = height

    def surface_area(self):
        return 2 * self.PI * self.radius * (self.radius + self.height)

    def volume(self):
        return self.PI * self.radius ** 2 * self.height


class Sphere(Shape):
    def __init__(self, radius):
        self.radius = radius

    def surface_area(self):
        return 4 * self.PI * self.radius ** 2

    def volume(self):
        return 4 / 3 * self.PI * self.radius ** 3


class Cube:
    def __init__(self, edge_length):
        self.edge_length = edge_length

    def surface_area(self):
        return 6 * self.edge_length ** 2

    def volume(self):
        return self.edge_length ** 3


class Cuboid:
    def __init__(self, length, width, height):
        self.length = length
        self.width = width
        self.height = height

    def surface_area(self):
        return 2 * (self.length * self.width + self.width * self.height + self.height * self.length)

    def volume(self):
        return self.length * self.width * self.height


N = int(input())
for _ in range(N):
    r_cylinder, h_cylinder = map(float, input().split())
    r_sphere = float(input())
    edge_cube = float(input())
    l_cuboid, w_cuboid, h_cuboid = map(float, input().split())

    cylinder = Cylinder(r_cylinder, h_cylinder)
    sphere = Sphere(r_sphere)
    cube = Cube(edge_cube)
    cuboid = Cuboid(l_cuboid, w_cuboid, h_cuboid)

    shapes = [cylinder, sphere, cube, cuboid]

    for shape in shapes:
        print(f"{shape.surface_area():.2f} {shape.volume():.2f}")

回复 支持 反对

使用道具 举报

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
189#
发表于 2023-6-13 22:56:56 | 只看该作者

import math


class Shape:
    PI = 3.14


class Cylinder(Shape):
    def __init__(self, radius, height):
        self.radius = radius
        self.height = height

    def surface_area(self):
        return 2 * self.PI * self.radius * (self.radius + self.height)

    def volume(self):
        return self.PI * self.radius ** 2 * self.height


class Sphere(Shape):
    def __init__(self, radius):
        self.radius = radius

    def surface_area(self):
        return 4 * self.PI * self.radius ** 2

    def volume(self):
        return 4 / 3 * self.PI * self.radius ** 3


class Cube:
    def __init__(self, edge_length):
        self.edge_length = edge_length

    def surface_area(self):
        return 6 * self.edge_length ** 2

    def volume(self):
        return self.edge_length ** 3


class Cuboid:
    def __init__(self, length, width, height):
        self.length = length
        self.width = width
        self.height = height

    def surface_area(self):
        return 2 * (self.length * self.width + self.width * self.height + self.height * self.length)

    def volume(self):
        return self.length * self.width * self.height


N = int(input())
for _ in range(N):
    r_cylinder, h_cylinder = map(float, input().split())
    r_sphere = float(input())
    edge_cube = float(input())
    l_cuboid, w_cuboid, h_cuboid = map(float, input().split())

    cylinder = Cylinder(r_cylinder, h_cylinder)
    sphere = Sphere(r_sphere)
    cube = Cube(edge_cube)
    cuboid = Cuboid(l_cuboid, w_cuboid, h_cuboid)

    shapes = [cylinder, sphere, cube, cuboid]

    for shape in shapes:
        print(f"{shape.surface_area():.2f} {shape.volume():.2f}")

回复 支持 反对

使用道具 举报

1

主题

329

帖子

1002

积分

金牌会员

Rank: 6Rank: 6

积分
1002
190#
发表于 2023-6-13 22:58:03 | 只看该作者
class Cuboid:
    def __init__(self, length, width, height):
        self.__length = length
        self.__width = width
        self.__height = height

    def set_length(self, length):
        self.__length = length

    def set_width(self, width):
        self.__width = width

    def set_height(self, height):
        self.__height = height

    def get_bottom_area(self):
        return self.__length * self.__width

    def get_volume(self):
        return self.__length * self.__width * self.__height

length, width, height = map(int, input().split())
cuboid = Cuboid(length, width, height)
print(cuboid.get_bottom_area())
print(cuboid.get_volume())

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|经济影院--温州大学公选课网站    

GMT+8, 2024-9-27 12:22 , Processed in 0.234677 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表