-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathString Formatting.py
More file actions
47 lines (41 loc) · 759 Bytes
/
String Formatting.py
File metadata and controls
47 lines (41 loc) · 759 Bytes
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
######## String length, uppercase, lowercase
a = input("Enter a string with uppercase and lowercase: ")
print(a.upper())
print(a.lower())
print(len(a))
'''
Input:
Hello World!
Output:
HELLO WORLD!
hello world!
12
'''
##### Separate string with a character
print("Welcome", "to", "python", "programming", sep="*")
'''
Output:
Welcome*to*python*programming
'''
################################
name = input()
age = int(input())
print(name, "is" , age, "years old!")
print('%s is %d years old!' %(name, age))
'''
Input:
Rezwan
20
Output:
Rezwan is 20 years old!
Rezwan is 20 years old!
'''
##################################
a = float(input())
print("Price of this t-shirt is %.9f" % a)
'''
Input:
855.75
Output:
Price of this t-shirt is 855.750000000
'''