Learning has no end, we will never stop.
name = input()
print(name.lower())
print(name.upper())
print(name.title())
**Convert the elements in the variable "name" to lowercase, uppercase, and title case respectively.
Example:
Input:
niuNiu
Output:
niuniu
NIUNIU
Niuniu
I am a separator~
.strip() --- Remove whitespace from both ends
.lstrip() --- Remove whitespace from the left end
.rstrip() --- Remove whitespace from the right end
.replace(" ","") --- Remove all whitespace
.split() --- Split first, "".join() --- Then join
.join() example:
s1 = "-"
s2 = ""
seq = ("r", "u", "n", "o", "o", "b") # string sequence
print (s1.join( seq ))
print (s2.join( seq ))
I am a separator~
y = int(input())
y_2 = x/y
print('%0.2f'%y_2)
'%0.2f'%y_2 Round the result of y_2 to two decimal places and output
Example:
Input: 7
Output: 3.50
I am a separator~
name = input()
str1 = input()
if name == "admis" or str1 == "Nowcoder666":
print("Welcome!")
Custom variable format and usage example:
def hanshu(a):
for i in a:
print(2*int(i))
a = input().split()
hanshu(a)
Purpose: Define a function named "hanshu", pass arguments a and b to hanshu, and multiply them in the function "hanshu" and directly output the increased result
I am a separator~
A bit 'advanced' command:
**try ~ except ~
Purpose: Custom error display
Structure:
try:
<block1>
except <exception type a>:
<block2>
Example:
try:
a = eval(input())
print(a*2)
except NameError:
print("asd")