Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.

Have an account? Sign In

Captcha Click on image to update the captcha.

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Tech Answered Logo Tech Answered Logo
Sign InSign Up

Tech Answered

Tech Answered Navigation

  • Home
  • Tutorials
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us
Home / Questions /Q 1728
Next
In Process
Sidharth
Sidharth

Sidharth

  • India
  • 10 Questions
  • 8 Answers
  • 0 Best Answers
  • 17 Points
View Profile
  • 4
Sidharth
Asked: May 2, 20212021-05-02T15:15:24+05:30 2021-05-02T15:15:24+05:30In: Python

what is the code to design a doormat in python?

  • 4

I am trying to write a code for the question, but I am unable to get the logic of the code. So can anyone write code to this question using python?

Question:

Mr. Vincent works in a doormat manufacturing company. One day, he designed a new doormat with the following specifications:

  • Mat size must be N x M. ( N is an odd natural number, and M is 3 times of N .)
  • The design should have ‘WELCOME’ written in the center.
  • The design pattern should only use |, . and - characters.

Input:  7 21

output:

---------.|.---------
------.|..|..|.------
---.|..|..|..|..|.---
-------WELCOME-------
---.|..|..|..|..|.---
------.|..|..|.------
---------.|.---------


codecodingdesign a door matproblem solvingpython
  • 1
  • 766
  • 0
  • 0
Answer
Share
  • Facebook

    Related Questions

    • Python Program To Print Stars (*) In Different Patterns?
    • What Is The Python Program To Print The Calendar Of A Particular Month?
    • Write A Python Program To Accept A File Name From The User And Print The Extension Of The File Name.
    • Python Program To Count The Number Of Vowels In A Sentence?
    • Best Programming Language To Learn in 2021?
    • How to crack Coding Rounds in Technical Interviews?
    • How to create a dictionary in Python

    1 Answer

    1. Rashika

      Rashika

      • India
      • 4 Questions
      • 5 Answers
      • 0 Best Answers
      • 40 Points
      View Profile
      Rashika
      2021-05-03T17:04:48+05:30Added an answer on May 3, 2021 at 5:04 pm
      This answer was edited.

      To design a doormat in python, please check the below code

      print(“Enter the mat dimensions which must be N*M ( N is an odd natural number, and M is 3 times of N)”)
      #read the dimensions convert them into int because by default input will be taken as a string
      #Map function iterates over input and reads two dimensions at the same time
      N,M = map(int,input().split())

      #range starts from 1 to N and increments it by 2
      for i in range(1, N, 2):
      #str function in python gives the string version of the object
      #center function center aligns the string with the specified interval and given character

      #so here, starting from 1 to N at every even intervals “.|.” will be printed “i” times at the center and the rest will be filled with “-”

      print (( str(‘.|.’)*i ).center(M, ‘-‘))
      #welcome will be printed at center, remember N is height M is width
      print (str(‘WELCOME’).center(M, ‘-‘))

      #range starts from N-2 till -1 and decrements by 2
      for i in range(N-2, -1, -2):
      #same as that of the above for loop
      print (( str(‘.|.’)*i ).center(M, ‘-‘))

      what is the code to design a doormat in python?
      • 1
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    More Questions

    • Himasree

      What is the difference between modules and packages in Python?

    • Swathi

      how to remove indentation error in python

    • Swathi

      what is the difference between list and tuple in python

    • Vipinkv

      Python Program To Print Stars (*) In Different Patterns?

    • Vipinkv

      What Is The Python Program To Print The Calendar Of

    • Krishna Vijayan

      Write A Python Program To Accept A File Name From

    • Vipinkv

      Python Program To Count The Number Of Vowels In A

    • arunraj503

      Addition of two numbers in Python using user input example

    Stats

    • Questions 1,940
    • Answers 2,048
    • Posts 8
    • Best Answers 72

    Related Questions

    • Vipinkv

      Python Program To Print Stars (*) In Different Patterns?

    • Vipinkv

      What Is The Python Program To Print The Calendar Of A Particular

    • Krishna Vijayan

      Write A Python Program To Accept A File Name From The User

    • Vipinkv

      Python Program To Count The Number Of Vowels In A Sentence?

    • Vipinkv

      Best Programming Language To Learn in 2021?

    • Priyanka Chakraborty

      How to crack Coding Rounds in Technical Interviews?

    • Priyanka Chakraborty

      How to create a dictionary in Python

    • Priyanka Chakraborty

      How Python is used in Data Science?

    Explore

    • Home
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help

    Footer

    Recent Comments

    • jackmaalisaa on how to solve export problem in kinemaster
    • arunraj503 on How to recover images from Google Drive.
    • ethancargio on Which programming language should I learn?
    • glenn on How to stop windows 11 update permanently
    • glenn on How to fix the POS limit has been reached on windows 10 and saying your device need to install updates
    Ask A Question

    Archives

    Tags

    laptop buying guide (1) limit google news notifications (1) printer buying guide (1) stop google news notifications (1) turn off google news notifications (1)

    Social media

    © 2021 @ Techanswered.com.
    Terms, Privacy policy & Sitemap.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.