Write a program to display the following diamond-shape like pattern based on the height given by the user. Assume that the user will always enter a positive odd number.

Answers

Answer 1

Answer:

try:

   size = int(input("Enter a number: "))

except ValueError:

   print("must be a number")

if size==0:

   print("number must be greater than zero.")

elif size%2==0:

   print("number must be odd.")

   

else:

   obj = '#'

   mid_size = round(size/2)

   s = size - mid_size

   count = 2

   counts = 1

   for i in range(size+1):

       if i<=mid_size:

           print(" " *(size - i) + (obj+" ") * i)

       elif i>mid_size:

           print(" " * (s + counts) + (obj + " ") * (i - count))

           count += 2

           counts += 1

Explanation:

The python source code uses a try and except statement to check for value error and print a diamond shape of the object "#" determined by the input number.


Related Questions

For the sake of maximizing hardware utilization in a multicore system with a many to many threading model, the relationship of the number of user threads U to the number of kernel threads K to the number of CPU cores P should be:

Answers

Answer:

"U > K > P" would be the appropriate answer.

Explanation:

When performing or executing the software, user threads (U) could easily be accomplished and therefore are typically wide in the amount to provide excellent or excellent performance. Multiple kernel threads could indeed be appointed to every other core as well as try to emulate the algorithm for scheduling.

On his website, Mario has a video that visitors must click to play. He wants the video to play automatically when the page loads. What attribute should Mario add to the
A. controls
B. loop
C. autoplay
D. play

Answers

Answer:

C: AutoPlay

Explanation:

it is C because the definition of AutoPlay is: a functionality that causes a video, audio file, etc. to play automatically, without action from a user.


Please help!! I’ll mark you brainly

Answers

Answer:

1. raster and vector

2. Resolution

3. Color depth

4. Forms, Shapes

5. Tone

6. Balance

7. White space

8. Aspect ratio

9. Focus

10. cropping

Hope this helped :)

i’m just your second response so you can mark him brainly lol

A database has one physical schema and one conceptual (logical) schema but many external schemas (views).
a) True
b) False

Answers

Answer:

true

Explanation:

A database has one physical schema and one conceptual (logical) schema but many external schemas (views): a. True.

A database refers to a structured (organized) collection of data that are stored on a computer system and usually accessed in various ways such as electronically.

In database management, a database schema can be defined as a structure which is typically used to represent the logical design of the database. Thus, it denotes how data are stored (organized) and the relationships existing in a database management system (DBMS).

Generally, there are two (2) main types of a database schema and these include;

Physical database schema: it is only one per database.Conceptual (logical) schema: it is only one per database.

However, there are multiple number of external schemas (views) for each database because it is what an end user is interested in.

Read more on database here: https://brainly.com/question/3259292

When would you insert a merge field?

A. when updating the source document

B. when choosing which information you want to enter into a letter

C. when choosing which information you want to insert in a merged letter

D. when creating a document

Answers

Answer:

Once you have a data source connected to your document, adding merge fields is a way to personalize a document with information from the data source.

I believe it’s C, but please correct me if I’m wrong!!

how has the Internet of Things affected business​

Answers

Internet of Things devices can be connected to each other and controlled to improve efficiency,which in turn has direct effects on the productivity of the business. Hope this helps!

Answer:

Business equipment can be continually adjusted based on analysis of data

Explanation:

A P E X

This is the department that is responsible for hiring, firing, training, new employees for the business or corporation.
Group of answer choices

Human Resources

Information Technology

Advertising

Marketing

Answers

Answer:

Explanation:

human resources

hoped this helped

A user can view
and
in the Reading pane.

Answers

Answer:

sorry,but I can't understand your question.

Answer:

email messaging and attachments

Explanation:

2023 edg 100%

what is the first things u do upon seeing this sheet?​

Answers

Answer:

umm ok

Explanation:

plz mark brainlyest

Mmmmmm yh, I’m not sure ??

Write pseudocode for a function that translates a telephone number with letters in it (such as 1-800-FLOWERS) into the actual phone number. Use the standard letters on a phone pad.

Answers

Answer:

Explanation:

Function telToNumbers with one parameter of a String input for the telephoneNumber

String var newTelephoneNum;

for loop through telephoneNumber {

Char var currentChar = current Character in the loop;

currentChar to lower Case;

Switch statement (currentChar) {

 case "a" or "b" or "c" : newTelephoneNum += "2"; break;

 case "d" or "e" or "f" : newTelephoneNum += "3"; break;

 case "g" or "h" or "i" : newTelephoneNum += "4"; break;

 case "j" or "k" or "l" : newTelephoneNum += "5"; break;

 case "m" or "n" or "o" : newTelephoneNum += "6"; break;

 case "p" or "q" or "r" or "s" : newTelephoneNum += "7"; break;

 case "t" or "u" or "v" : newTelephoneNum += "8"; break;

 case "w" or "x" or "y" or "z" : newTelephoneNum += "9"; break;

 default : newTelephoneNum += currentChar; break;

 }

}

print newTelephoneNum;

4.2 code need help plz someone 15 points if u help

Answers

def func():  

 total = 0

 while True:

   pet = input("What pet do you have? ")

   if pet == "rock":

     return

   total += 1

   print("You have a {} with a total of {} pet(s)".format(pet, total))

func()

We wrapped our code in a function so that whenever the user enters rock, we can simply return and exit the function. If you have any other questions, I'll do my best to answer them.

Help me! I’ll mark you brainly and give extra points!

Answers

Answer:

52 5,

Explanation:

Which logic correctly describes an algorithm to find the smallest of the three numbers a, b, and c and store the smallest number in small?

A.
If a is less than b, then set a to small, else set b to small, else set c to small.
B.
If a is less than b, then set small to a, else set small to b.
If c is less than small, then set small to c.
C.
If a is less than b, then set small to b, else set small to c.
If c is less than small, then set small to a.
D.
If a is less than small, then set small to a.
If b is less than small, then set small to b.
If c is less than small, then set small to c.

Answers

Answer:

D

Explanation:

Answer:

B. If a is less than b, then set small to a, else set small to b.

If c is less than small, then set small to

Explanation:

Plato correct!!

Information technology

Answers

Answer:

Study or use of systems

Explanation:

especially, computers, telecommunications for storing retrieving and sending some informations

Answer:

Information technology is the use of computers to store, retrieve, transmit and manipulate data, or information, often in the context of business or other enterpise.

Someone help me for about how to avoid online scams please I need help no trolls

Answers

Answer:

1. (for emails) Block spam messages.

2. Look at who sent whatever it is and make sure it is the exact email for the brand.

3. If someone is putting a lot of emojis in a comment or somthing its fake.

4. Make sure to read the fine print.

5. Do not giveaway personal information like zip code, address, social security number.

Write code which takes a sentence as an input from the user and then prints the length of the first word in that sentence.
Hint: think about how you know where the first word ends - you may assume that the sentence contains more than one word.
Input a code in the following:
/* Lesson 3 Coding Activity Question 4 */
import java.util.Scanner;
public class U2_L3_Activity_Four{
public static void main(String[] args){
/* Write your code here */
}
}

Answers

import java.util.Scanner;

public class U2_L3_Activity_Four {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Enter a sentence.");

       String sent = scan.nextLine();

       int count = 0;

       for (int i = 0; i < sent.length(); i++){

           char c = sent.charAt(i);

           if (c != ' '){

               count++;

       }

           else{

               break;

           }

       

   }

       System.out.println("The first word is " + count +" letters long");

   

   }

}

We check to see when the first space occurs in our string and we add one to our count variable for every letter before that. I hope this helps!

Following are the java code to the given question:

import java.util.Scanner;//import package

public class U2_L3_Activity_Four //defining a class U2_L3_Activity_Four

{

  public static void main(String[] args) //defining main method

  {

      String s;//defining String variable

      int x,v=0;//dclaring integer variable x,v

      Scanner obx = new Scanner(System.in);//creating Scanner class Object

      System.out.println("Enter a sentence.");//print message

      s = obx.nextLine();//input string value

      for (x = 0; x < s.length(); x++)//defining loop to count string length

      {

          char c = s.charAt(x);//defining char variable that hold char value

          if (c != ' ')//defining if that check space value

          {

              v++;

          }

      }

      System.out.println("The first word is " + v +" letters long");//print length of first word

  }

}

Output:

Please find the attached file.

Program Explanation:

Import package.Defining a class U2_L3_Activity_Four, inside the class main method is declared.Defining a string variable "s" and an integer variable "x,v=0", and a scanner class object is created that inputs string value.In the next step, a for loop is defined that checks the first word in the string value and prints its length value.

Learn more:

brainly.com/question/16092924

PLEASE ANSWER QUICK
How can improving one’s reasoning skills also improve one’s performance on the job?
A. If one can improve one’s reasoning, one can also improve one’s physical fitness and athletic performance.
B. If one can improve one’s reasoning, one can perform anything.
C. High-performing workers always work reasonable schedules.
D. High-performing workers are able to analyze sophisticated streams of data and solve complex problems.

Answers

Answer: C

Explanation:

C high performance workers always work

To italicize text located within a text box, which grouping would you use? Effects Text Font Typography

Answers

Answer:

Font

Explanation:

It seems like the only real answer from reading the lesson

Determine the number of character comparisons made by the brute-force algorithm in searching for the pattern GANDHI in the text
THERE_IS_MORE_TO_LIFE_THAN_INCREASING_ITS_SPEED
(Assume that the length of the text-it is 47 characters long- is known before the search starts).

Answers

Answer:

Total number of character comparison = 43

Explanation:

Using the Brute force algorithm

The string of n characters is known as text, and the string of m characters is known as the pattern.

From the given information:

The text (n)=THERE_IS_MORE_TO_LIFE_THAN_INCREASING_ITS_SPEED

The pattern (m) = GANDHI

The total no of characters that we have in the text = 47

The total number of characters in pattern = 6

For a brute force algorithm;

Since; the first character of the pattern does not exist in the text, then the number of trials made can be attempted can be expressed as = n – m + 1

= 47 – 6 + 1

= 47 – 5

= 42

Thus; the algorithm will attempt the trial 42 times.

Now, for loop in the algorithm to run 42 times, the G in the pattern will have to align against the for T in the text, and in the last case, it will be aligned against the last space.

On each attempted trial, the algorithm will make one unsuccessful comparison.

However, at the trial at which the G in the pattern Is aligned with the G in the text, there will be two successful comparisons.

Hence, we can calculate the total number of character comparison as follows:

Total number of character comparison = [tex]\mathbf{\bigg ( ( 42 - (no. \ of \ failed \ comparison) ) \times 1 + (1 \times ( Two \ successful \ comparisons) ) \bigg ) }[/tex]

Total number of character comparison = ( (( 42 – 1) × 1 ) + ( 1 × 2) )

Total number of character comparison = 41 + 2

Total number of character comparison = 43

Which input value causes the loop body to execute a 2nd time, thus outputting "In loop" again? { String s = "Go"; while ((!s.equals("q"))&& (!s.equals("")) System.out.println("In loop"); 5 - scnr.nextO;
a) "Quit"
b) "q" only
c) "Q only
d) Either "q" or "Q"

Answers

Answer:

a) "Quit"  

c) "Q only

Explanation:

Given

String s = "Go";

while ((!s.equals("q"))&& (!s.equals("")))  {

System.out.println("In loop");

s = scnr.next();

}

Required

What input causes another execution

Analyzing the while condition

while ((!s.equals("q"))&& (!s.equals("")))  

This can be split into:

!s.equals("q")) && (!s.equals(""))

Meaning

When s is not equal to "q" and when s is not an empty string

In other words,

the loop will be executed when user input is not "q" and user input is not empty.

So, from the list of given options: The loop both will be executed when:

a) Input is "Quit"

c) Input is Q only

Input of q will terminate the loop, hence b and d are incorrect

Which of the following internet protocols is used to request and send pages and files on the World Wide Web

Answers

it is . org Explanation:

If you need to download something for a class, first

Answers

Answer:

left click, then click save image

Explanation:

Answer:

first try to do it on kami, then on Google docs, then on doc-hub

Which choices correctly describe an Else
statement? Check all that apply.
a conditional statement that will show
different information if the answer to the If
statement is true
a conditional statement that will show
different information after the If statement
answer is false
a statement that contains the code to be
executed when the If value is false or zero
a conditional statement that runs a piece of
code when all program statements are true

Answers

Answer: B C

Explanation:

Answer:B,C,D

Explanation:

Write an If/else statement to check whether host is online. If it is online, then print system is online otherwise print system is unreachable.

Answers

Answer:

from socket import *

hostname = input('Enter the host to be scanned: ')

ip_add = gethostbyname(hostname)

connections = [ ]    

for i in range(133, 136):

   s = socket(AF_INET, SOCK_STREAM)

     

   conn = s.connect_ex((ip_add, i))

   print(conn)

   connections.append(conn)

if 0 in connections:

   print ('Host is online')

   s.close()

else:

   print ('system is unreachable')

Explanation:

The python source code above scans for all the available range of ports in the provided hostname, if any port is available, the host is online else the program print the error message "system is unreachable.

How can you enter Task Manager in Windows? Select 3 options. right-click the taskbar and choose Start Task Manager right-click the taskbar and choose Manage Tasks press Ctrl + Shift + Tab press Ctrl+Alt+Delete and then click Task Manager press Ctrl + Alt + Esc

Answers

Answer:

Press [Ctrl]+[Shift]+[Esc] and Windows Task Manager will launch instantly

Explanation:

Answer:
1. Press Ctrl+Alt+Delete and then click Task Manager
2. right-click the taskbar and choose Start Task Manager

3. Press Ctrl+Alt+Esc

Explanation:

Took the test. If you are on a windows computer you can also test the answers to see what works and what does not.

7-9 validation rule in a field will​

Answers

Answer:

Validation rule in a field will restrict the input from user into a field or table

Explanation:

Validation is used in database to ensure that the correct data type is entered in the fields. When validation is applied to a field, a message is displayed to the user if he enters the data of wrong datatype.

Hence,

Validation rule in a field will restrict the input from user into a field or table

What question did the use of a telescope by Hubble answer?

A

Is Earth the center of the universe


B

Is the sun the center of the universe


C

How do the planets move in the solar system


D

Are there more galaxies beyond the Milky Way

Answers

Answer:

The Answer is D

ANSWER THIS CORRECTLY TO GET BRAINLY
What is a row of data in a database called?

a
Field

b
File

c
Record

d
Title

Answers

the answer is c. record

Help me! I’ll mark you brainly ! Please help me I need this now

Answers

Explanation: For number 3 I would say shade and darkness.

Write function that ask for input from a user. Use this input as input for the countdown function that we wrote using the while loop. If the user types 'end', the program exits, otherwise it keeps going.

Answers

Answer:

Written in Python:

def myfunction():

     userinput = input("User input: ")

     while(userinput != "end"):

           countdown(userinput)

           userinput = input("User input: ")

Explanation:

This line defines the function

def myfunction():

           This line prompts user for user input

           userinput = input("User input: ")

           The following while loop checks if userinput is not "end". It continues execution until user input "end"

           while(userinput != "end"):

                       countdown(userinput) If yes, the input is passed to the countdown function for execution

                       This line prompts user for another user input

                       userinput = input("User input: ")

Please note the above code segment assumes that countdown() function has already been written and defined

Other Questions
Help....The Phoenician alphabet was based on A. syllables. B. words. C. vowels. D. sounds. Can somebody please help What destroyed the Roman economy duringthe 3rd century What contributed to the decline of Indus Valley Civilization?Select all of the correct answersA:Indus Valley populations migrated to central Asia and AfricaB:Centuriesof floods made the soil salty and unfit for farmingC:The surrounding land was severely deforestedD:Volcanic eruptions covered the land with molten and lavaE:Diseases reduced the population A gym charges a membership fee plus an additional fee per yoga class. The table shows the linear relationship between the number of yoga classes taken and the total cost including the membership fee.Which statement is true? A class of 32 students has 12 girls. What is the ratio of girls to boys?A. 3:5B. 5:3C. 3:8D. 8:3 Plzz Help! I need help with the rebuttal! :() which of the following is congruent please help if u can Read the excerpt from "The Most Dangerous Game."Rainsford's first impression was that the man was singularly handsome; his second was that there was an original, almost bizarre quality about the general's face. He was a tall man past middle age, for his hair was a vivid white; but his thick eyebrows and pointed military mustache were as black as the night from which Rainsford had come. His eyes, too, were black and very bright. He had high cheek bones, a sharp-cut nose, a spare, dark face, the face of a man used to giving orders, the face of an aristocrat. Turning to the giant in uniform, the general made a sign. The giant put away his pistol, saluted, withdrew.What details from the narration relate Rainsfords impression of Zaroff? Select 4 options.almost bizarre quality about the general's facehis thick eyebrows and pointed military mustache were as black as the nightHis eyes, too, were black and very brightthe face of an aristocratTurning to the giant in uniform, the general made a signThe giant put away his pistol, saluted, withdrew. hey i got riddles for peopleI am something people love or hate. I change peoples appearances and thoughts. If a person takes care of them self I will go up even higher. To some people I will fool them. To others I am a mystery. Some people might want to try and hide me but I will show. No matter how hard people try I will Never go down. What am I?Only one color, but not one size,Stuck at the bottom, yet easily flies.Present in sun, but not in rain,Doing no harm, and feeling no pain.What is it? In which of the following passages is the borrowed material framed following the quoted words?A)Even one's sense of taste is affected in the environment of space. "Body fluids migrate to your upper body, and you end up withengorged tissue around the nasal passages and ears." explains Gerald Cat, commander of the third Skylab missionB)The study concludes that a faulty work ethic is not responsible for the decline in our productivity quite the contrary, the studyIdentifies 'a widespread commitment among U.S. workers to improve productivity and suggests that there are large reservoirs ofpotential upon which management can draw."[Yankelovich, Daniel "Does the American work ethic work?" Chicago Tribune, 16 May1982]C)"This implies," reports Kevin Colgan, that areas can spell a word as fast as we can speak it.D)If you hold back crying when you're under stress you are more susceptible to infections because your endocrine system putsout steroids which reduce your resistance to disease,Dr Field insists. In 5th grade Flo learned that the volume of a rectangular prism can be stated as V = l w h. What is the volume of a prism with a length of 22 cm, width of 33.7 cm, and height of 12.5 cm? ANSWER PLEASE! The place of worship for a Muslim is aO SynagogueChurchMosqueTemple Which research questions would be too broad for a three-page research paper? Select the two correct answers.(1 point)What are all the animals that live in the Serengeti?How old is the oldest living dog?How fast do arctic winds blow?When was ice cream invented?What is the Egyptian civilization? How long would it take a car, starting from rest and accelerating uniformly in a straight line at 5m/s^2, to cover a distance of 200m? can someone help me on my spanish work sheet i will cash app you money like fr What is an analogy for transcription factors in cell signaling? The work in a office takes 150 hours to complete every week each person in the office works for 32 hours a week what is the smallest number of people needed to complete the work The cell membrane contains channels and pumps that help move materials from one side to the other. What are these channels and pumps made of? *A. CarbohydratesB. LipdsC. Bi-LipidsD. Proteins