Python Tutorial for Beginners - 1. Strings - Working with Textual Data

Table of Contents

  1. Run Code 1 in Python
  2. Run Code 2 in Python
  3. Run Code 3 in Python
  4. Run Code 4 in Python
  5. Run Code 5 in Python
  6. Run Code 6 in Python
  7. Run Code 7 in Python
  8. Run Code 8 in Python
  9. Run Code 9 in Python
  10. Run Code 10 in Python
  11. Run Code 11 in Python
  12. Run Code 12 in Python
  13. Run Code 13 in Python
  14. Run Code 14 in Python
  15. Run Code 15 in Python
  16. Run Code 16 in Python
  17. Run Code 17 in Python
  18. Run Code 18 in Python
  19. Run Code 19 in Python
  20. Run Code 20 in Python
  21. Run Code 21 in Python
  22. Run Code 22 in Python
  23. Run Code 23 in Python
  24. Run Code 24 in Python

Run Code 1 in Python

1
print('Hello World')

start.py

Run Code 2 in Python

1
2
message = 'Hello World'
print(message)

start.py

Run Code 3 in Python

1
2
message = 'Milovan's World'
print(message)

start.py

Run Code 4 in Python

1
2
message = 'Milovan\'s World'
print(message)

start.py

Run Code 5 in Python

1
2
message = "Milovan\'s World"
print(message)

start.py

Run Code 6 in Python

1
2
3
message = """Hello World
test test test"""
print(message)

start.py

Run Code 7 in Python

1
2
message = 'Hello World'
print(len(message))

start.py

Run Code 8 in Python

1
2
3
4
message = 'Hello World'
print(message[0])
print(message[10])
print(message[11]) #error

start.py

Run Code 9 in Python

1
2
3
4
message = 'Hello World'
print(message[0:5])
print(message[:5])
print(message[6:])

start.py

Run Code 10 in Python

1
2
message = 'Hello World'
print(message.lower())

start.py

Run Code 11 in Python

1
2
3
4
message = 'Hello World'
print(message.upper())
print(message.count('Hello'))
print(message.count('l'))

start.py

Run Code 12 in Python

1
2
message = 'Hello World'
print(message.find('World'))

start.py

Run Code 13 in Python

1
2
message = 'Hello World'
print(message.find('Universe'))

start.py

Run Code 14 in Python

1
2
3
message = 'Hello World'
message.replace('World', 'Universe')
print(message)

start.py

Run Code 15 in Python

1
2
3
message = 'Hello World'
new_message = message.replace('World', 'Universe')
print(new_message)

start.py

Run Code 16 in Python

1
2
3
message = 'Hello World'
message = message.replace('World', 'Universe')
print(message)

start.py

Run Code 17 in Python

1
2
3
4
greeting = 'Hello'
name = 'Milovan'
message = greeting + name
print(message)

start.py

Run Code 18 in Python

1
2
3
4
greeting = 'Hello'
name = 'Milovan'
message = greeting + ', '+ name
print(message)

start.py

Run Code 19 in Python

1
2
3
4
5
6
greeting = 'Hello'
name = 'Milovan'

message = greeting + ', '+ name + '. Welcome!'

print(message)

start.py

Run Code 20 in Python

1
2
3
4
5
6
greeting = 'Hello'
name = 'Milovan'

message = '{}, {}. Welcome!'.format(greeting, name)

print(message)

start.py

Run Code 21 in Python

1
2
3
4
5
6
greeting = 'Hello'
name = 'Milovan'

message = f'{greeting}, {name}. Welcome!'

print(message)

start.py

Run Code 22 in Python

1
2
3
4
5
6
greeting = 'Hello'
name = 'Milovan'

message = f'{greeting}, {name.upper()}. Welcome!'

print(message)

start.py

Run Code 23 in Python

1
2
3
4
greeting = 'Hello'
name = 'Milovan'

print(dir(name))

start.py

Run Code 24 in Python

1
2
3
4
greeting = 'Hello'
name = 'Milovan'

print(help(str))

start.py