添加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 轩辕龙儿 # @author 轩辕龙儿
# @date 2022/10/25 # @date 2022/10/25
# @file NP1.py # @file NP1.py
s = "Hello World!"
print(s) def solution():
s = "Hello World!"
print(s)
if __name__ == "__main__":
solution()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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