-
Notifications
You must be signed in to change notification settings - Fork 0
/
ch1.py
63 lines (45 loc) · 1.41 KB
/
ch1.py
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
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
#stringsرشته ها
quote="Hashem is the owner of the 'World'"
print(quote)
quote2 = 'not only the best one in the world but entire "galaxy"'
print(quote2)
#indexing
str1 = 'asparagus'
print(str1[0],str1[1])
print('asparagus'[0])
print('Hashem')
print(len(str1))
#string functions
name = 'Hashem'
print(name.lower())
print(name.upper())
print('Hashem'.upper())
print('today '+'is '+'Wed')
#repeat
print('Hashem ' * 5)
strHello = 'Hello '*2
#str function
nFriends = 5
print('hello to my '+ str(nFriends) + " friends")
#format
print('I said you {} times that you have not to go'.format('1000'))
#print('we are {0}, {1} and {2}.\n{2} is the latests'.format('Hashem','Sohrab','Kourosh'))
'''
#formatting output length to be equal; good for make tables look nice
print('{0:9},{1:12} is an engineer'.format('Hashem','Moradmand'))
print('{0:9},{1:12} is an actor'.format('Javad','Razavian'))
#formatting left < right > or middle ^ alignment
print('{0:>9},{1:>12} is an engineer'.format('Hashem','Moradmand'))
print('{0:>9},{1:>12} is an actor'.format('Javad','Razavian'))
#formatting output length to be equal; good for make tables look nice
print('{0:6},{1:1.2f} is an engineer'.format('Hashem', 1.82))
print('{0:6},{1:1.4f} is an actor'.format('Javad',1.6235))
#input function
name = input('enter your name: ')
print('your name is {}'.format(name))
'''