-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyPractice.py
95 lines (64 loc) · 2.38 KB
/
pyPractice.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# FROM THE WEBSITE https://www.w3resource.com/python-exercises/
#
# Python Basic (Part -1) - Exercises, Practice, Solution
#
import datetime # for PROBLEM 3
import sys # for PROBLEM 2
import math # for problem 4
problemNo = 1
print("{}================= {} =================".format("\n", problemNo))
problemNo += 1
str = """Twinkle, twinkle, little star,
\tHow I wonder what you are!
\t\tUp above the world so high,
\t\tLike a diamond in the sky.
Twinkle, twinkle, little star,
\tHow I wonder what you are"""
print(str)
print("{}================= {} =================".format("\n", problemNo))
problemNo += 1
print("Python version")
print(sys.version)
print("Version info.")
print(sys.version_info)
# print(sys.__doc__)
print("{}================= {} =================".format("\n", problemNo))
problemNo += 1
now = datetime.datetime.now()
print("Current date and time: {}".format(now))
# date.strftime(format) returns a string representing the date,
# controlled by an explicit format string.
# Format codes referring to hours, minutes or seconds will see 0 values.
print(now.strftime("%Y-%m-%d %H:%M:%S"))
# NEED HELP IN THIS CODE
print("{}================= {} =================".format("\n", problemNo))
problemNo += 1
# import math module at the top of this program
radius = float(input("Enter a radius: ")) # input is string, concatenate it
print("Area = {}".format(math.pow(radius, 2) * math.pi))
print("{}================= {} =================".format("\n", problemNo))
problemNo += 1
full_name = input("Enter full name: ")
names = full_name.split()
if len(names) == 1:
print("Your name in reverse is: {}".format(names[0]))
else:
print("Your name in reverse is: {} {}".format(names[1], names[0]))
print("{}================= {} =================".format("\n", problemNo))
problemNo += 1
string = input("Enter input: ").split(",")
tuples = tuple(string)
print(string)
print(tuples)
print("{}================= {} =================".format("\n", problemNo))
problemNo += 1
color_list = ["Red", "Green", "White", "Black"]
print("{} {}".format(color_list[0], color_list[-1]))
print("{}================= {} =================".format("\n", problemNo))
problemNo += 1
exam_st_date = (11, 12, 2014)
print("The examination will start from: %i/%i/%i" % exam_st_date)
print("{}================= {} =================".format("\n", problemNo))
problemNo += 1
n = input("Enter a number n:")
print(6*n)