Goal

Learn and Fun with Python Strings!

Pre-Requisites

Download and Install Python Interpreter

Deployment

Assign below strings to variables to perform below tasks.

a = “Hello DevOps Realtime”

b = “Hello Python ”

c = “Hello World”

e = 2022

Tasks

  1. Print the variable a in reverse order
  2. Print number of elements in the variable a
  3. Check if the variable  a contains pattern “DevOps” and print the status as True or False.
  4. Use Type Casting and convert the variable a to integer type  and assign result to another variable d. Note: If any error observe the error.
  5. Check if the given two variables a & b are same?
  6. Check if the given two variables a & b are not same?
  7. Write in the comments the difference between assignment(=) and equal to comparison operator(==) in Python?
  8. Compare the given two variables a & b and print the string that has more elements
  9. Print the 5th element of the given two variables a & b
  10. Concatenate the given three variables a,b,c and assign the output to another variable d and print the d variable using print(). Note: d variable value should be: “Hello DevOps Realtime Hello PythonHello World”
  11. Check if any numbers are there in the given variables a & b
  12. Insert a string ‘,’ in the middle of variable a and assign the output to variable d. Note: d variable value should be: “Hello, DevOps Realtime”
  13. Print the elements between index 3 and 6 of variable a.
  14. Check if the starting letter of the variable a is Capital Letter?
  15. Check if the pattern ‘Python’ repeated how many times in the variable b.
  16. Concatenate the given two variables a & e , and assign the value too another variable d and print the d variable value. Use type casting if required. Note: d variable value should be “Hello DevOps Realtime 2022”
  17. Replace all spaces with %20 in the given variable a and assign the value to another variable d and print the d variable value. Note: d variable value should be “Hello%20DevOps%20Realtime”
  18. Assign below string to a variable and print it using print().String: ‘Welcome,  This is “Python for DevOps Engineers” course.’
  19. Use print () to print the below string directly without variable assignment.

String: “Welcome,

This is Python for DevOps Engineers course.”

20. Assign below string to a variable d and print it using print().

String: “Welcome,

This is Python for DevOps Engineers course.”

 

Congratulations!!  Its fun to play with Python strings! Still not confident and want to play again? Repeat the steps.

Comment below your experience these Python String Tasks.

 

© Edwiki Trainings – Click HERE If you are interested to learn more on Cloud & DevOps stack.

0 Shares:
2 comments
  1. a single equal mark is used to assign a value to a variable, whereas two consecutive equal marks is used to check whether 2 expressions give the same value .
    = is an assignment operator
    == is an equality operator

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like