Computer Science, asked by Muskaan2457, 1 year ago

Write a script that performs all the following tasks:
Create a string 's1' by concatenating two strings with values "Py" and 'thon'. Print 's1'.
Consider the string 's2' with value 'Python is amazing'. Print 's2'.
Consider the string 's3' with value 'Python\nis\namazing'. Print 's3'.
Consider the string 's4' with value 'Python\tis\tamazing'. Print 's4'.

Answers

Answered by codiepienagoya
2

The Python code to this question can be given as:

Code:

#for option 1 code:

s1='py'+'thon'  #define variable s1 that hold value with using concatenate operator

print(s1) #print value.

#for option 2 code:

s2='Python is amazing' #define variable s2.

print (s2)  #print value of s2 variable.

#for option 3 code:

s3='Python\nis\namazing'  #define variable s3 and assign value.

print (s3) #print value.

#for option 4 code:

s4='Python\tis\tamazing' #define variable s4.

print (s4) #print s4 value.

Output:

python

Python is amazing

Python

is

amazing

Python is amazing

Explanation:

  • In code 1, The s1 variable holds two strings of value that is 'py' and 'thon'. In this variable a concatenate operator is used that holds value. To print variable value we use print function and pass the value on it.
  • In code 2, The s2 variable holds a value that is 'Python is amazing'.To print variable value we use print function and pass variable in the function parameter.
  • In code 3, The s3 variable holds a value that is 'Python\nis\namazing' in this value '\n' is used that print word in the next line.  
  • In code 4, The s4 variable holds a value that is 'Python\tis\tamazing' in this value '\t' is used that gives a tab space between word.  

Learn more:

  • String in python: https://brainly.in/question/12243675
Answered by dubeyswati06
0

Answer:

here is your code:

s1 = 'py' + 'thon'

print(s1)  

s2 = 'Python is amazing'

print(s2)

s3 = 'Python\nis\namazing'

print(s3)

s4 = 'Python\tis\tamazing'

print(s4)

Explanation:

Similar questions