Question

Suppose s1 = 'ant' s2 = 'bat' s3 = 'cod' Write Python expressions using s1, s2,...

Suppose

s1 = 'ant'

s2 = 'bat'

s3 = 'cod'

Write Python expressions using s1, s2, and s3 and operators + and * that evaluate to:

  1. 'ant bat cod'
  2. 'ant ant ant ant ant ant ant ant ant ant '
  3. 'ant bat bat cod cod cod'
  4. 'ant bat ant bat ant bat ant bat ant bat ant bat ant bat '
  5. 'batbatcod batbatcod batbatcod batbatcod batbatcod '
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Suppose
s1 = 'ant'
s2 = 'bat'
s3 = 'cod'

Python expressions using s1, s2, and s3 and operators + and * that evaluate to:
'ant bat cod'
s1+" "+s2+" "+s3

'ant ant ant ant ant ant ant ant ant ant '
(s1+" ")*10

'ant bat bat cod cod cod'
(s1+" ")+((s2+" ")*2)+((s3+" ")*2)+s3

'ant bat ant bat ant bat ant bat ant bat ant bat ant bat '
(s1+" "+s2+" ")*7

'batbatcod batbatcod batbatcod batbatcod batbatcod '
(s2+s2+s3+" ")*5
Add a comment
Know the answer?
Add Answer to:
Suppose s1 = 'ant' s2 = 'bat' s3 = 'cod' Write Python expressions using s1, s2,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a ladder logic diagram for a system with 3 switches S1, S2, and S3. For...

    Write a ladder logic diagram for a system with 3 switches S1, S2, and S3. For turning the system on, either S1 and S2 have to be turned on simultaneously, else S3 has to be turned off.

  • Given the following sequence of instructions: lw $s2, 0($s1) //1 lw $s1, 40($s3) //2 sub $s3,...

    Given the following sequence of instructions: lw $s2, 0($s1) //1 lw $s1, 40($s3) //2 sub $s3, $s1, $s2 //3 add $s3, $s2, $s2 //4 or $s4, $s3, $zero //5 sw $s3, 50($s1) //6 a. List the read after write (current instruction is reading certain registers which haven’t been written back yet) data dependencies. As an example , 3 on 1 ($s2) shows instruction 3 has data dependency on instruction 1 since it is reading register $s2. b. Assume the 5...

  • Write the function in python and show the code 2. Write a function jscore (s1, s2)...

    Write the function in python and show the code 2. Write a function jscore (s1, s2) that takes two strings s1 and s2 as inputs and returns the Jotto score of s1 compared with s2 -.e., the number of characters in s1 that are shared by s2. The positions and the order of the shared characters within each string do not matter. Repeated letters are counted multiple times, as long as they appear multiple times in both strings. For example...

  • Consider the five-bit binary result (C0, S3, S2, S1, S0) representation in the table above. We...

    Consider the five-bit binary result (C0, S3, S2, S1, S0) representation in the table above. We would like to represent each combination as its equivalent in two decimal digits, each of which can be represented in binary as shown in the following table. Finish filling in the following truth table.  Find the logic expressions for N2X3, N2X2, N2X1, N2X0, N1X3, N1X2, N1X1, and N1X0 as a function of C0, S3, S2, S1 and S0  Write the verilog code for the Binary Coded...

  • python s1 = "hi!" s2 = "exam" Show a one line python expression that could construct...

    python s1 = "hi!" s2 = "exam" Show a one line python expression that could construct each of the following results by performing string operations on s1 and s2. Please write your answer against the roman numeral of the question to differentiate the answer. i) "Hi" ii) "hilexamhi!" iii) "ExamHi!ExamHi!ExamHi!" v) "exm" vi) "him" vii) "maxe

  • Write (and evaluate) Python expressions to compute the following. Show the code you write and the...

    Write (and evaluate) Python expressions to compute the following. Show the code you write and the result: The number of different encodings using 32 bits.

  • C programming 1 String Merging Write a program that reads two strings s1 and s2 from...

    C programming 1 String Merging Write a program that reads two strings s1 and s2 from the keyboard and merges them to a string s3. Strings s1 and s2 are statically allocated whereas s3 is dynamically allocated to fit exactly s1 and s2. The two original strings are no longer than 100 characters long. Use the following function to merge the two strings. char *stringMerge(char s1[], char s2 []); Example: Enter the first string: Hello world Enter the first string:...

  • SQL question Consider the three transactions T1, T2 and T3, and the schedules S1, S2, S3...

    SQL question Consider the three transactions T1, T2 and T3, and the schedules S1, S2, S3 and S4 given below. Which of the schedules is (conflict) serializable? The subscript for each database operation in a schedule denotes the transaction number for that operation. For each schedule, show all conflicts, draw the precedence graph, determine and write down if it is serializable or not, and the equivalent serial schedules if exist. T1: r1(x); w1(x); T2: r2(x); T3: r3(x); w3(x); S1: r1(x);...

  • Task 3: Understanding Programs Given the initial statements s1 = [2,1,4,3] s2 = [’c’,’a’,’b’] show the...

    Task 3: Understanding Programs Given the initial statements s1 = [2,1,4,3] s2 = [’c’,’a’,’b’] show the result of evaluating each of the following sequence expressions: s1 + s2 => 3 * s1 + 2 * s2 => s1[1] => s1[1:3] => s1 + s2[-1] => Given the same initial statements as in the previous problem, show the values of s1 and s2 after executing each of the following statements. Treat each part independently (i.e., assume that and start with their...

  • 1. (Expressions) Write Python expressions for the following tasks. Print the results of the expressions using...

    1. (Expressions) Write Python expressions for the following tasks. Print the results of the expressions using the ‘print’ function. Compute the product of 11111111 with itself. How often does 91 go into 1000? (Integer value) What remainder does 91 leave when divided into 1000? You scored 90/100, 46/50, 55/60 and 66/70. What is your best score on these four works? A KB (kilobyte) in information technology is really 1024 bytes (not 1000 bytes), where 1024 is 2 raised to the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT