添加main方法,方便测试

This commit is contained in:
轩辕龙儿 2022-10-26 10:02:04 +08:00
parent a7e783e361
commit 3123313dc4
16 changed files with 153 additions and 40 deletions

View File

@ -2,5 +2,11 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP1.py
def solution():
s = "Hello World!"
print(s)
if __name__ == "__main__":
solution()

View File

@ -2,6 +2,12 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP10.py
def solution():
n1 = input()
n2 = input()
print(n1 + n2)
if __name__ == "__main__":
solution()

View File

@ -2,5 +2,11 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP11.py
def solution():
s = input()
print(len(s))
if __name__ == "__main__":
solution()

View File

@ -2,7 +2,13 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP12.py
def solution():
s = input()
print(s.lower())
print(s.upper())
print(s.title())
if __name__ == "__main__":
solution()

View File

@ -2,5 +2,11 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP13.py
def solution():
s = input()
print(s.strip())
if __name__ == "__main__":
solution()

View File

@ -2,5 +2,11 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP14.py
def solution():
s = input()
print(s * 100)
if __name__ == "__main__":
solution()

View File

@ -2,5 +2,11 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP15.py
def solution():
s = input()
print(s[0:10])
if __name__ == "__main__":
solution()

View File

@ -2,14 +2,20 @@
# @author 轩辕龙儿
# @date 2022/10/26
# @file NP16.py
list = ["Allen", "Tom"]
for i in list:
def solution():
nameList = ["Allen", "Tom"]
for i in nameList:
print(
"{}, you have passed our interview and will soon become a member of our company.".format(
i
)
)
list.remove("Tom")
list.append("Andy")
for i in list:
nameList.remove("Tom")
nameList.append("Andy")
for i in nameList:
print("{}, welcome to join us!".format(i))
if __name__ == "__main__":
solution()

View File

@ -3,7 +3,14 @@
# @date 2022/10/25
# @file NP2.py
def solution():
s1 = "Hello World!"
s2 = "Hello Nowcoder!"
print(s1)
print(s2)
if __name__ == "__main__":
solution()

View File

@ -2,5 +2,15 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP3.py
def solution():
s1 = "Hello World!"
s2 = "Hello Nowcoder!"
print(s1)
print(s2)
if __name__ == "__main__":
solution()
s = input()
print(s)

View File

@ -2,6 +2,16 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP4.py
def solution():
s1 = "Hello World!"
s2 = "Hello Nowcoder!"
print(s1)
print(s2)
if __name__ == "__main__":
solution()
num = int(input())
print(num)
print(type(num))

View File

@ -2,5 +2,15 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP5.py
def solution():
s1 = "Hello World!"
s2 = "Hello Nowcoder!"
print(s1)
print(s2)
if __name__ == "__main__":
solution()
name = input()
print("I am %s and I am studying Python in Nowcoder!" % name)

View File

@ -2,5 +2,15 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP6.py
def solution():
s1 = "Hello World!"
s2 = "Hello Nowcoder!"
print(s1)
print(s2)
if __name__ == "__main__":
solution()
num = float(input())
print("%0.2f" % num)

View File

@ -2,5 +2,11 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP7.py
def solution():
num = float(input())
print(int(num))
if __name__ == "__main__":
solution()

View File

@ -2,7 +2,13 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP8.py
def solution():
a = int(input())
num = float(a)
print(num)
print(type(num))
if __name__ == "__main__":
solution()

View File

@ -2,6 +2,12 @@
# @author 轩辕龙儿
# @date 2022/10/25
# @file NP9.py
def solution():
num16 = input()
num10 = int(num16, 16)
print(num10)
if __name__ == "__main__":
solution()