Answer to Question #309931 in Python for big eddy

Question #309931

You must use looping to solve the problem 

Given the following variables: 

slash = "/" 

backslash = "\\" 

asterisk = "*" 

uscore = "_" 

Define a function that builds the following patterns based on variables given above: 

  pattern1: 

  /\/\/\/\/\/\/\/\/\ 

pattern2: 

*-*-*-*-*-*-*-*-* 

Tip: You may pass those symbols to the function as arguments. For example, your function header could look as following: 

def create_pattern(symbol1,symbol2): 

 

where: 

symbol1 will be assigned to slash 

symbol2 will be assigned to backshash 

 

The same for the second pattern: 

symbol1 will be assigned to asterisk 

symbol2 will be assigned to underscore 

 

 

 

Once the function is ready, you can use it to print the following pattern on the screen: 

create_pattern(slash,backslash) 

create_pattern(asterisk,uscore) 

create_pattern(asterisk,uscore) 

create_pattern(asterisk,uscore) 

create_pattern(slash,backslash) 

 



1
Expert's answer
2022-03-11T17:39:23-0500
def create_pattern(symbol1,symbol2): 
    j = int(input(''))
    com =   symbol1 + symbol2
    return com * j
create_pattern('*','_') 

5


Out[44]:

'*_*_*_*_*_'

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS