1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rudiy27
4 years ago
6

Create a function generateString(char, val) that returns a string with val number of char characters concatenated together.

Computers and Technology
1 answer:
NikAS [45]4 years ago
3 0

Answer:

Here is the function generateString() which has two parameters char for storing characters of a string and val is a number in order to return string with val number of char characters.        

def generateString(char, val):

 result = char * val

 return result      

If you want to see if the function works correct and generates right output you can check it by calling the generateString() function and passing values to it and printing the result using print() function as following:

print(generateString('a',7))

This will produce the following output:

aaaaaaa

   

Explanation:

The complete program is:

import sys

character= sys.argv[1]

count= int(sys.argv[2])

# Your code goes here

def generateString(char, val):

 result = char * val

 return result

print(character*count)

The logic of this function generateString(char, val) is explained below.

Lets say the value of char = a and val = 3 This means that generateString() should return 3 a's concatenated together. This concatenation is done by multiplication of the value of char i.e. 3 with the value of val i.e. 3.

So printing a 3 times displays aaa  

You might be interested in
A7DF is the hexadecimal representation for what bit pattern?
kipiarov [429]

Answer:

1010 0111 1101 1111

Explanation:

A = 10 in decimal = 1010 in binary

7 = 7 in decimal = 0111 in binary

D = 13 in decimal = 1101 in binary

F = 15 in decimal = 1111 in binary

Therefore 0xA7DF = 1010 0111 1101 1111 in binary

6 0
3 years ago
Two electronics technicians are looking at the representations of a silver atom and a copper atom in the figure above. Technicia
eduard
C is your correct answer.
5 0
4 years ago
____ is another term for document properties.
MArishka [77]
Metadata is the other term for document properties. It is a data that describes another data. The word “meta” means “an underlying definition or description”. Traditionally, it was used in libraries as card catalogs. In digitals, metadata is also used to describe digital data. 
3 0
3 years ago
) Consider the ambiguous CFG problem: given a context free grammar, does there exist a string that can be generated by two diffe
vodomira [7]

Answer:

See explaination

Explanation:

The post correspondence problem is: Given a_1, \ldots, a_n and b_1, \ldots, b_n , is there a sequence of indices 11. ..., im such that a_{i_1}\ldots a_{i_m} = b_{i_1}\ldots b_{i_m} .

To reduce from the PCP to the ambiguous CFG problem, do the following. Add some more symbols c_1, \ldots, c_n and define the following languages:

L_{A} = \{a_{i_1}\ldots a_{i_k}c_{i_k}\ldots c_{i_1} \mid k \geq 1\}

L_{B} = \{b_{i_1}\ldots b_{i_k}c_{i_k}\ldots c_{i_1} \mid k \geq 1\}

L_{AB} = L_A \cup L_B .

Define the following grammar for the language L_{AB} :

S \to S_{A} \mid S_{B}

S_A \to a_iS_Ac_i \mid a_ic_i, 1 \leq i \leq n

S_B \to b_iS_Bc_i \mid b_ic_i, 1 \leq i \leq n

It is easy to see that the given grammar generates the langauge L_{AB} . The reduction outputs the grammar thus constructed.

To see why this is a valid reduction, let there be a solution to the post correspondence problem, i.e. 11. ..., im such that a_{i_1}\ldots a_{i_m} = b_{i_1}\ldots b_{i_m} . Then the string a_{i_1}\ldots a_{i_m}c_{i_m}\ldots c_{i_1} = b_{i_1}\ldots b_{i_m}c_{i_m}\ldots c_{i_1} has two difference derivations in the given grammar, one using S_A and the other using S_B .

Conversely, let a string generated by the given grammar have two different derivations. Note that S_A and S_B can only generate one derivation tree for any string, hence the only way for two different derivations to happen is for one of them to go to S_A and the other to S_B .

Let the string for which ambiguity appears be of the form a_{i_1}\ldots a_{i_m}c_{i_m}\ldots c_{i_1} . Then the other derivation must produce a string of the form b_{i_1}\ldots b_{i_m}c_{i_m}\ldots c_{i_1} , this is because both derivations must produce the same string for ambiguity to occur, hence the part which uses c_i must be the same. Note that this further implies that a_{i_1}\ldots a_{i_m} = b_{i_1}\ldots b_{i_m} , which is equivalent to saying that the post correspondence problem has a solution.

Hence the reduction works as expected. This proves that the ambiguous CFG problem is undecidable, otherwise post correspondence problem would be decidable, which is a contradiction.

4 0
3 years ago
GAMER OYUNCU KOLTUĞU % YERLİ
rewona [7]

Answer:

what does that even say omg

3 0
4 years ago
Other questions:
  • Simon wants to use an invoice template created by Office.com. The first step after selecting the File tab is to select
    14·1 answer
  • 50 POINTS PLEASE HELP MEEEEEEEEE!!!!!!
    7·2 answers
  • Será que me podrían ayudar pasandome los códigos por favor
    13·1 answer
  • Please answer it’s timed
    14·1 answer
  • What do you use the Pygame library for?
    6·1 answer
  • Convert the following denary numbers into binary using 8-bit register:
    6·1 answer
  • Hello! I hope you have a great day! Good things will come your way.
    12·1 answer
  • What are the 3 rules of music<br><br> ps: there is no music subject so i had to put something else
    15·2 answers
  • Hey, can you guys please help me please??
    14·1 answer
  • Why do we need on output device?​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!