Learning knows no bounds, 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
Example of .join():
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 Take the result of y_2 and output it with two decimal places
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 parameters 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' instruction:
**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")