Computer Science
Define two variables first and second so that first = "Jimmy" and second = "Johny". Write a short python code segment that swaps the values assigned to these two variables and prints the results.
Python
Python String Manipulation
4 Likes
Answer
first = "Jimmy"
second = "Johny"
temp = first
first = second
second = temp
print("first =", first)
print("second =", second)
Output
first = Johny
second = Jimmy
Answered By
2 Likes
Related Questions
Write a short python code segment that prints the longest word in a list of words.
Write a program that creates a list of all the integers less than 100 that are multiples of 3 or 5.
Write a Python program that creates a tuple storing first 9 terms of Fibonacci series.
Create a dictionary whose keys are month names and whose values are the number of days in the corresponding months.
(a) Ask the user to enter a month name and use the dictionary to tell how many days are in the month.
(b) Print out all of the keys in alphabetical order.
(c) Print out all of the months with 31 days.
(d) Print out the (key-value) pairs sorted by the number of days in each month.