GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — code_snippets/String-Formatting/formatting.py at master · Roopa28/code_snippets

Expand file tree

/

formatting.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
77 lines (41 loc) · 1.57 KB
/

formatting.py

Copy path

File metadata and controls

77 lines (41 loc) · 1.57 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
person = {'name': 'Jenn', 'age': 23}
# sentence = 'My name is ' + person['name'] + ' and I am ' + str(person['age']) + ' years old.'
# print(sentence)
# sentence = 'My name is {} and I am {} years old.'.format(person['name'], person['age'])
# print(sentence)
# sentence = 'My name is {0} and I am {1} years old.'.format(person['name'], person['age'])
# print(sentence)
# tag = 'h1'
# text = 'This is a headline'
# sentence = '<{0}>{1}</{0}>'.format(tag, text)
# print(sentence)
sentence = 'My name is {0} and I am {1} years old.'.format(person['name'], person['age'])
print(sentence)
class Person():
def __init__(self, name, age):
self.name = name
self.age = age
p1 = Person('Jack', '33')
sentence = 'My name is {0.name} and I am {0.age} years old.'.format(p1)
print(sentence)
# sentence = 'My name is {name} and I am {age} years old.'.format(name='Jenn', age='30')
# print(sentence)
# sentence = 'My name is {name} and I am {age} years old.'.format(**person)
# print(sentence)
# for i in range(1, 11):
# sentence = 'The value is {}'.format(i)
# print(sentence)
# pi = 3.14159265
# sentence = 'Pi is equal to {}'.format(pi)
# print(sentence)
sentence = '1 MB is equal to {} bytes'.format(1000**2)
print(sentence)
import datetime
my_date = datetime.datetime(2016, 9, 24, 12, 30, 45)
# print(my_date)
# March 01, 2016
sentence = '{:%B %d, %Y}'.format(my_date)
print(sentence)
# March 01, 2016 fell on a Tuesday and was the 061 day of the year.
sentence = '{:%B %d, %Y} fell on a {} and was the {} day of the year'.format(my_date)
print(sentence)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.