print and strings in Python part-2

Опубликовано: 30 Декабрь 2017
на канале: Cook The Code
17
1

Strings are amongst the most popular types in Python. We can create them simply by enclosing characters in quotes. Python treats single quotes the same as double quotes. Creating strings is as simple as assigning a value to a variable.
For example −
var1 = 'Hello World!'
var2 = "Python Programming"

Accessing Values in Strings
Python does not support a character type; these are treated as strings of length one, thus also considered a substring.

To access substrings, use the square brackets for slicing along with the index or indices to obtain your substring.
For example −
#!/usr/bin/python

var1 = 'Hello World!'
var2 = "Python Programming"

print "var1[0]: ", var1[0]
print "var2[1:5]: ", var2[1:5]

When the above code is executed, it produces the following result −

var1[0]: H
var2[1:5]: ytho

reference:-https://www.tutorialspoint.com/python...

website:- https://coderworld109.blogspot.com/


Смотрите видео print and strings in Python part-2 онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Cook The Code 30 Декабрь 2017. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 17 раз и оно понравилось 1 посетителям.