Write the code for function diamond in the file exercise1.py. The function diamond: takes one...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write the code for function diamond in the file exercise1.py. The function diamond: • takes one parameter N (type int), its value must be odd and in the range [3,99] • it draws a square shape made of integer values and spaces: integer values are always printed with 2 digits (for example, value 7 is printed 07 every line consists of integer values from 1 up to N, where some values have to be replaced by spaces instead the first and last row are full (no space) the middle row is empty except for values 1 and N each row from the first one to the middle one is increasingly empty from its center each row from the middle one to the last one is increasingly full to its center Below are a couple of example outputs when using the diamond function from the shell: >>> diamond (5) 0102030405 0102 0405 01 05 0102 0405 0102030405 Write the code for function diamond in the file exercise1.py. The function diamond: • takes one parameter N (type int), its value must be odd and in the range [3,99] • it draws a square shape made of integer values and spaces: integer values are always printed with 2 digits (for example, value 7 is printed 07 every line consists of integer values from 1 up to N, where some values have to be replaced by spaces instead the first and last row are full (no space) the middle row is empty except for values 1 and N each row from the first one to the middle one is increasingly empty from its center each row from the middle one to the last one is increasingly full to its center Below are a couple of example outputs when using the diamond function from the shell: >>> diamond (5) 0102030405 0102 0405 01 05 0102 0405 0102030405
Expert Answer:
Answer rating: 100% (QA)
from os import sys def diamondn rintn12 for i in ranger for j in rangen if j1 ... View the full answer
Related Book For
Concepts of Database Management
ISBN: 978-111182591
7th edition
Authors: Philip J. Pratt, Joseph J. Adamski
Posted Date:
Students also viewed these programming questions
-
Write the code for the following triggers following the style shown in the text. a. When adding a customer, add the customers balance times the sales reps commission rate to the commission for the...
-
You are to write the code for a convergence module that can deal with one to three tear stream variables using theWegstein algorithm, as outlined in Appendix A.2. The object is to determine the...
-
Write the code for a function named GetState. The function should prompt the user to enter the name of a U.S. state and then return the users response. Then write a statement to invoke the GetState...
-
What is the coefficient of sliding friction and what is a representative value for this coefficient for the brittle crust?
-
Justify Remark 1 following Example 6 in Section 2.2.
-
Determine each dealerships apportionment using Jeffersons method. (Some divisors between 88.5 and 89 will work.) When appropriate round quotas to the nearest hundredth. Boat manufacturer has 120 new...
-
Plaintiffs purchased stock warrants (rights to purchase) for blocks of Osborne Computer Corp., the manufacturer of the first mass-market portable personal computer. Because of inability to produce a...
-
In a recent year Ives Township acquired six police cars at a total cost of $200,000. The vehicles are expected to have a useful life of four years. 1. Prepare the journal entries that the township...
-
An Olympic lifter (m =103kg) is holding a lift with a mass of 350 kg. The bar exerts a purely vertical force that is equally distributed between both hands. Each arm has a mass of 9 kg, are 0.8m long...
-
Restful Sleep Mattress Company is planning to expand into selling bedroom furniture. This expansion will require a loan from the bank. The bank has requested financial information. Discuss, in a...
-
Fun with IRR. Suppose you have just graduated from college and are deciding on a career. Your four career options, along with your salary in each of the four earning periods, are displayed in table...
-
What is the theoretical and practical implications for a study on the factors influencing the customers decisions to use online food delivery services after the Covid-19 pandemic in Malaysia....
-
Your company has determined that the time is right to expand globally. As a corporate manager within the organization, you have been assigned to identify and select a team of five to ten members from...
-
What are the political, economic, sociological, technological, legal and environmental elements that impact the global hotel industry in spain? please identify elements, factors and impacts for each...
-
1) Explain in detail the crystallization of a pure metal of your selection. Your explanation should include Mechanism Cooling curve Kinetics 2) Compare the selected pure metal in (1) with one of its...
-
Discusses the following organizational concepts: Organizational mission: the organization's mission and purpose, stated in terms of benefits to customers, employees, and society Organizational...
-
Access the Business Resource Center. (Directions for creating an account, IF YOU DO NOT ALREADY HAVE AN ACCOUNT) are under resources in this module. The article about leadership at a bank but is...
-
$10,000 was borrowed at 3.5% on July 17. The borrower repaid $5000 on August 12, and $2000 on September 18. What final payment is required on November 12 to fully repay the loan?
-
Describe the process of creating a table in SQL and the different data types you can use for fields.
-
Consider a Student table containing StudentNum, StudentName, students StudentMajor, students AdvisorNum, students AdvisorName, students AdvisorOfficeNum, students AdvisorPhone, students NumCredits,...
-
How can the complexity of a DBMS be a disadvantage?
-
Fill in the blanks to make the following statements correct. a. Economists have designed____________ to better explain and predict the behaviour we observe in the world around us. b. A variable, such...
-
The following supply and demand schedules describe a hypothetical Canadian market for potash. a. What is the equilibrium price of potash? b. How much potash would actually be purchased if the price...
-
According to Statistics Canada, Canada's exports and imports of energy (combined totals of fossil fuels, hydro, and nuclear, all measured in petajoules) over a five-year period were as follows: a....
Study smarter with the SolutionInn App