Question

Question 1. The variable word references the string ‘winter’. Use for loops to create new strings...

Question

1. The variable word references the string ‘winter’. Use for loops to create new strings with various text effects as follows.

  1. Variable long_word becomes ‘wwwiiinnnttteeerrr’

  2. Variable crossed_word becomes ‘XwXiXnXtXeXr’

word = 'winter'
long_word = ''
# write the for loop that traverses word to create
# long_word with value 'wwwiiinnnttteeerrr'

crossed_word = ''
# write the for loop that traverses word to create
# crossed_word with value 'XwXiXnXtXeXr'

print(long_word)
print(crossed_word)

Homework Answers

Answer #1
word = 'winter'
long_word = ''
# write the for loop that traverses word to create
# long_word with value 'wwwiiinnnttteeerrr'
for x in word:
    long_word += (x*3)

crossed_word = ''
# write the for loop that traverses word to create
# crossed_word with value 'XwXiXnXtXeXr'
for x in word:
    crossed_word += ('X'+x)

print(long_word)
print(crossed_word)

Know the answer?
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
Similar Questions
1.Create a function that will let you enter in a word or sentence in lower case...
1.Create a function that will let you enter in a word or sentence in lower case (as a user input) and will convert the input to a string with the first letter capitalized. Next, use the format method to print the following result: "Before: word, After: Word" i.e. >>> Enter a word: house >> Before: house, After: House 2. Write a program that will let you enter a sentence and will print each word out separately with the first letter...
Create program that sorts words of a string based on first letter of each word. Use...
Create program that sorts words of a string based on first letter of each word. Use C programming language. - Only use stdio.h and string.h - Remove any newline \n from input string - Use insert function - Input prompt should say "Enter string of your choice: " - Output should print sorted string on new line Example:     Enter string of your choice: this is a string     a is string this
1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b....
1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b. Print out the elements in the week_tuple. 2-a. The following list has been declared as follows: credit_list = [24,3,15] b. Convert the credit_list to a tuple named credit_tuple. c. Print out the elements in the credit_tuple. 3-a. Write an initialize_list_values function that takes in a number for the number of elements in a list and an initial value for each element. The function creates...
1-To create an ArrayList of strings, which of the following is correct? `a ArrayList<String> list =...
1-To create an ArrayList of strings, which of the following is correct? `a ArrayList<String> list = new ArrayList<String>(); b ArrayList<String> list = new String<String>​[]; c ArrayList<String> list = new ArrayList<String>; d ArrayList​[String] list = new ArrayList​[String]; 2-All instance variables? a Are assigned a default value if they are not initialized b Must be initialized as part of their declaration c Are assigned an arbitrary value if they are not initialized d Must be initialized by the constructor 3-An instance method...
Use Rstudio to create a script by following the instruction below. I've created the first question...
Use Rstudio to create a script by following the instruction below. I've created the first question code but I can not continue it further. Thank you. ## Write a function called `make_introduction` that takes in two arguments: name, and age. ## This function should return a string value that says something like "Hello, my name is {name}, and I'm ## {age} years old". make_introduction <- function(name, age){ print(paste("Hello, my name is", name, "and I'm", age, "years old")) } ## Create...
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c....
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c. Write a for loop which will display this set of values 2,4,6,8,10,12,14,16. d. Write a while which will display this set of values 16,13,10,7,4,1,-2. e. Write a for loop which will print ‘Loops are fun’ three times. f. Write a while loop that will prompt you for four numbers. Convert the number to an integer. Compute the power as power = power ** number....
Use nested loops to write a function called substring(s,b) that returns True or False depending on...
Use nested loops to write a function called substring(s,b) that returns True or False depending on whether or not b is a substring of s. A substring is a series of characters which appears inside another word in the exact same order. For example, substring(“banana”, “ana”) should return True whereas substring(“banana”,”bna”) should return False. Use this function to write a program that asks the user for a string s and a substring b and prints whether b is a substring...
4.9.1: Nested loops: Indent text. JAVA Print numbers 0, 1, 2, ..., userNum as shown, with...
4.9.1: Nested loops: Indent text. JAVA Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex: userNum = 3 prints: 0 1 2 3 Please use my template import java.util.Scanner; public class...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an array of ints, an int value named element, and an int value named end. Return a bool based on whether the element appears in the array starting from index 0 and up to but not including the end index. Generate Random Array Write a function that takes as parameters an array of integers and another integer for the size of the array. Create a...
Assignment 1. Console Application IN PYTHON For this assignment you are to create a class called...
Assignment 1. Console Application IN PYTHON For this assignment you are to create a class called Lab1. Inside the class you will create three methods that will modify a three-digit whole number: sumNums - This method takes as input a three digit int and returns the sum of the three numbers. For instance, 123 would return 6 because 3 + 2 + 1 is 6 reverseNums - This method takes as input a three digit whole number and returns the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT