会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132776个问题
JAVA 全系列/第二阶段:JAVA 基础深化和提高/常用类 11536楼

import turtle

a=input("请输入一个x:")
b=input("请输入一个y:")
c=input("请输入一个width:")
d=input("请输入一个height:")

class MyRectangle:

    def __init__(self,x,y,width,height):


        self.x=x
        self.y=y
        self.width=width
        self.height=height

        if self.x=="":
            self.x=0

        if self.x!="":
            self.x=float(x)

        if self.y=="":
            self.y=0

        if self.y!="":
            self.y=float(y)

        if self.width == "":
            self.width = 100

        if self.width!="":
            self.width=float(width)

        if self.height == "":
            self.height = 100

        if self.height!="":
            self.height=float(height)

    def getArea(self):
        return self.width*self.height

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

    def draw(self):
        turtle.color("red")
        turtle.penup()
        turtle.goto(self.x,self.y)
        turtle.pendown()
        turtle.right(90)
        turtle.forward(self.width)
        turtle.right(90)
        turtle.forward(self.height)
        turtle.right(90)
        turtle.forward(self.width)
        turtle.right(90)
        turtle.forward(self.height)
        turtle.done



m1=MyRectangle(a,b,c,d)
print(m1.getArea())
print(m1.getPerimeter())
m1.draw()

老师,为什么我在调用draw方法的之后海龟作图不显示?

Python 全系列/第一阶段:Python入门/面向对象 11538楼
JAVA 全系列/(旧的隐藏)第十五阶段:百战商城项目(Spring Cloud最新架构)/百战商城项目 11539楼

你好老师,为啥我用新标签这个完全显示不了?没看出问题在哪儿
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .header{
            width: 1400px;
            background-color: pink;
        }
        div{
            margin-top: 10px;
            height: 600px;
        }
        .nav{
            height: 80px;
            margin-top: 10px;
            background-color: pink;
        }
        .section{
            width: 900px;
            margin-top: 10px;
            background-color: pink;
            height: 600px;
            float: left;
        }
        aside{
            width: 480px;
            margin-top: 10px;
            background: pink;
            height: 600px;
            float: right;
        }
        .footer{
            height: 80px;
            margin-top: 10px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <header>头部</header>
    <nav>导航</nav>
    <div>
        <section>主要内容</section>
        <aside>侧边栏</aside>
    </div>
    <footer>脚部</footer>
</body>
</html>


WEB前端全系列/第一阶段:HTML5+CSS3模块/HTML5新增元素 11541楼
Python 全系列/第一阶段:Python入门/函数和内存分析 11545楼
JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解(旧) 11546楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637