-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathstrings_example_en.py
More file actions
54 lines (43 loc) · 1.14 KB
/
strings_example_en.py
File metadata and controls
54 lines (43 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from __future__ import print_function
#This file contains some examples for Python Strings
#What is Strings in python ?
#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.
#source of Definition https://www.tutorialspoint.com/python/python_strings.htm
#example 1
#added by @remon
str1 ="Hello World"
print(str1)
#example 2
#added by @remon
str2 ='Hello World 2'
print(str2)
#example 3
#added by @remon
str3 ="2018"
print(str3)
#example 4
#added by @tony.dx.3379aems5
str4 = "Hello 2 My friends 3"
num1 = int(str4[str4.find("2")])
num2 = int(str4[-1])
result = num1 + num2
print(result)
#example 5
#added by @Takeo. yassine messaoudi
str1 = "1 million arab coders "
a = str1.replace("m" , "M")
print (a)
#example 6
#added by @ammore5
#This example demonstrates how to concatenate two strings
str1 = "hi "
str2 = "there !"
print (str1 + str2)
#example 6
#added by @madforpython
#This example demonstrates how to reverse string
str5='Hey Contributers'
print(str5[::-1])