校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
计算的世界,除了二进制与十进制,使用最多的就是十六进制了,现在使用input读入一个十六进制的数字,输出它的十进制数字是多少?
input读入一个十六进制数字,按照字符串的形式包括数字0-9、字母A-F。
输出读入数字的十进制大小。
输入:
A
复制输出:
10
pp=str(input())
bk=[]
for i in pp:
if i=='A':
i=10
if i=='B':
i=11
if i=='C':
i=12
if i=='D':
i=13
if i=='E':
i=14
if i=='F':
i=15
bk.append(int(i))
l=len(bk)
sum=0
for i in range(0,l):
sum=sum+bk[i]*(16**(l-1-i))
print(sum)
NP10 牛牛最好的朋友们
name1=input()
name2=input()
print(name1+name2)
NP11 单词的长度
pp=input()
print(len(pp))
NP12 格式化输出(二)
pp=input()
print(pp.lower())
print(pp.upper())
print(pp.title())
NP13 格式化输出(三)
pp=input()
print(pp.strip())
NP14 不用循环语句的重复输出
牛牛正在学习Python,他想多次输出朋友的名字,但是因为还没有学习循环语句,他不知道该怎么输出,你能够帮助他将输入的朋友的名字重复输出100次吗?(提示:不可以使用循环或者递归语句,使用字符串 * 运算)
输入一个字符串。
输出重复100次之后的字符串,字符串之间没有间隔。
输入:
Hello
复制输出:
HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello
pp=input()
k=''
for i in range(0,100):
k=k+pp
print(k)
NP15 截取用户名前10位
pp=input()
l=len(pp)
p=''
if l >10:
pp=pp[0:10]
print(pp)
NP16 发送offer
offer_list=['Allen','Tom']
print("Allen, you have passed our interview and will soon become a member of our company.")
print("Tom, you have passed our interview and will soon become a member of our company.")
offer_list[1]='Andy'
print("Allen, welcome to join us!")
print("Andy, welcome to join us!")
NP17 生成列表
pp=input().split(" ")
print(pp)
p=input().split(' ')
k=[]
for i in p:
i=int(i)
k.append(i)
print(k)
pp=input().split(" ")
l=len(pp)
print(l)
pp=input().split(" ")
pp.append('Allen')
print(pp)
pp=input().split(' ')
pp.insert(0,'Allen')
print(pp)
pp=input().split(" ")
del pp[0]
print(pp)
pp=input().split(" ")
pk=input()
pp.remove(pk)
print(pp)
pp=input().split(" ")
for i in range(0,3):
pp.pop()
print(pp)
my_list=['P','y','t','h','o','n']
pp=sorted(my_list)
print(pp)
print(my_list)
my_list.sort(reverse=True)
print(my_list)
num=[3,5,9,0,1,9,0,3]
num.reverse()
print(num)
name = ['Niumei', 'YOLO', 'Niu Ke Le', 'Mona']
friends=[]
friends.append(name)
food=['pizza', 'fish', 'potato', 'beef']
friends.append(food)
number=[3, 6, 0, 3]
friends.append(number)
print(friends)
k=input()
pp=[]
for i in range(0,4):
p=(int(k[i])+3)%9
pp.append(p)
b=pp[0]
pp[0]=pp[2]
pp[2]=b
a=pp[1]
pp[1]=pp[3]
pp[3]=a
print(f'{pp[0]}{pp[1]}{pp[2]}{pp[3]}')
stack = [1, 2, 3, 4, 5]
pp=int(input())
stack.pop()
print(stack)
stack.pop()
print(stack)
stack.append(pp)
print(stack)
queue = [1, 2, 3, 4, 5]
k1=int(input())
queue.pop(0)
print(queue)
queue.pop(0)
print(queue)
queue.append(k1)
print(queue)
group_list=['Tom', 'Allen', 'Jane', 'William', 'Tony']
print(group_list[:2])
print(group_list[1:4])
print(group_list[3:])
x=int(input())
y=int(input())
print(x+y)
print(x-y)
x=int(input())
y=int(input())
print(x*y)
print(x**y)
x=int(input())
y=int(input())
print(int((x-x%y)/y),int(x-((x-x%y)/y)*y))
a=x/y
print("%.2f" % a)
x,y=input().split()
print(x==y)
x,y=input().split()
print(x>y)
print(x
k,x,y=input().split()
print(k<=x)
print(k>=y)
x,y=map(int,input().split())
print(f"{x and y}\n{x or y}\n{not x}\n{not y}")
s1=input()
s2=input()
print(s1==s2)
print(s1.lower()==s2.lower())
pp=input()
p=input()
print(p in pp)
x,y=map(int,input().split())
print(f"{x & y}\n{x|y}")
x,y,z,k=map(int,input().split())
print((x+y)*(z-k))
x=input()
if x==1:
print("Hello World!")
else:
print("Erros!")
my_list=[]
if my_list:
print("my_list is not empty!")
else:
print("my_list is empty!")
current_users=['Niuniu','Niumei','GURR','LOLO']
new_users=['GurR','Niu Ke Le','LoLo','Tuo Rui Chi']
for i in new_users:
if i in current_users or i.upper() in current_users:
print("The user name "+ i +" has already been registered! Please change it and try again!")
else:
print('Congratulations, the user name '+ i+' is available!')
dish={'pizza':10,'rice':2,'yogurt':5,'oth':8}
p=input()
if p not in dish:
p='oth'
print(dish[p])
score={"A":4.0,"B":3.0,"C":2.0,"D":1.0,"F":0,}
sum1=0
num=0
a=0
while 1:
x=input()
if x=='False':
break
y=int(input())
num=num+y
sum1=sum1+ score[x]*y
a=sum1/num
print("%.2f" % a)
name=input()
password=input()
if name=="admis":
if password=="Nowcoder666":
print("Welcome!")
else:
print("user id or password is not correct!")
else:
print("user id or password is not correct!")
my_list=['P', 'y', 't', 'h', 'o', 'n']
print("Here is the original list:")
print(my_list)
print()
print("The number that my_list has is:")
print(len(my_list))
users_list=['Niuniu','Niumei','Niu Ke Le']
for ii in users_list:
print("Hi, "+ii+"! Welcome to Nowcoder!")
print( "Happy Programmers' Day to everyone!")
a=[]
for i in range(10,51):
a.append(i)
print(a)
print(a[0] ,a[-1])
pp=[int(i) for i in input().split()]
l=len(pp)
sum1=0
for i in pp:
sum1=sum1+i
print(f"{sum1} {int(sum1)/l:.1f}")
my_list=list(range(0,19,2))
for i in my_list:
print(i)
my=list(range(0,51,5))
del my[0]
for i in my:
print(i)
my_list=[]
for i in range(1,11):
my_list.append(2**i)
for i in my_list:
print(i)
list=[i for i in range(0,10)]
print(list)
list1=['apple', 'ice cream', 'watermelon', 'chips', 'hotdogs','hotpot']
while list1:
list1.pop()
print(list1)
users_list=['Niuniu','Niumei','HR','Niu Ke Le','GURR' ,'LOLO' ]
for i in users_list:
if i =='HR':
print("Hi, HR! Would you like to hire someone?")
else:
print( 'Hi, '+i+'! Welcome to Nowcoder!')
list1=[3, 45, 9, 8, 12, 89, 103, 42, 54, 79]
pp=int(input())
for i in list1:
if i==pp:
break
else:
print(i)
for i in range(1,16):
if i==13:
continue
else:
print(i,end=" ")
list1=[[1,2,3],[4,5,6],[7,8,9]]
n=int(input())
for i in range(0,3):
for j in range(0,3):
list1[i][j]=list1[i][j]*n
print(list1)
name1=input()
name2=input()
t=(name1,name2)
print(t)
entry_form=('Niuniu','Niumei')
print(entry_form)
try:
entry_form[1]='Niukele'
except TypeError:
print('The entry form cannot be modified!')
name=tuple(input().split())
print(name[0:3])
mimi=('Tom', 'Tony', 'Allen', 'Cydin', 'Lucy', 'Anna')
pp=input()
print(mimi)
if pp in mimi:
print('Congratulations!')
else:
print('What a pity!')
nn=(1,2,3,4,5)
print(nn)
print(len(nn))
mm=(6,7,8,9,10)
print(nn+mm)
print(len(nn+mm))
operators_dict={"<":"less than","==":"equal",}
print('Here is the original dict:')
pp=sorted(operators_dict)
for i in pp:
# print()
print('Operator '+i+' means '+operators_dict[i]+'.')
operators_dict['>']='greater than'
print()
print('The dict was changed to:')
p=sorted(operators_dict)
for i in p:
# print()
print('Operator '+i+' means '+operators_dict[i]+'.')
survey_list=['Niumei','Niu Ke Le','GURR','LOLO']
result_dict={'Niumei': 'Nowcoder','GURR': 'HUAWEI',}
for i in survey_list:
if i in result_dict.key():
print('Hi, '+i+'! Thank you for participating in our graduation survey!')
else:
print('Hi, '+i+'! Could you take part in our graduation survey?')
my_dict_1={'name': 'Niuniu','Student ID': 1,}
my_dict_2={'name': 'Niumei','Student ID': 2,}
my_dict_3={'name': 'Niu Ke Le','Student ID': 3,}
dict_list=[]
dict_list.append(my_dict_1)
dict_list.append(my_dict_2)
dict_list.append(my_dict_3)
for i in dict_list:
print(i['name']+"'s student id is "+str(i['Student ID'])+'.')
cities_dict={'Beijing': {'Capital': 'China'},
'Moscow': {'Capital': 'Russia'},
'Paris': {'Capital': 'France'},}
p=sorted(cities_dict)
for i in p:
# print(cities_dict[i])
print(i+' is the capital of '+cities_dict[i]['Capital']+'!')
result_dict={'Allen': ['red', 'blue', 'yellow'],
'Tom': ['green', 'white', 'blue'],
'Andy': ['black', 'pink'],}
pp=sorted(result_dict)
for i in pp:
print(i+"'s favorite colors are:")
for j in result_dict[i]:
print(j)
key=input().split()
value=input().split()
dict1=dict(zip(key,value))
print(dict1)
dict1={'a': ['apple', 'abandon', 'ant'],
'b': ['banana', 'bee', 'become'],
'c': ['cat', 'come'],
'd': 'down'}
p=input()
for i in dict1[p]:
print(i,end=" ")
dict1={'a': ['apple', 'abandon', 'ant'],
'b': ['banana', 'bee', 'become'],
'c': ['cat', 'come'],
'd': 'down'}
le=input()
word=input()
dict1[le]=word
print(dict1)
pp=input()
l=len(pp)
dict1={}
for i in range(0,l):
if pp[i] not in dict1:
dict1[pp[i]]=1
else:
dict1[pp[i]]+=1
print(dict1)
pp=[int(i) for i in input().split()]
print(max(pp))
print(min(pp))
pp=[int(i) for i in input().split()]
num=sum(pp)
print(num)
p=int(input())
print(abs(p))
p=input()
print(ord(p))
pp=int(input())
print(hex(pp))
x=int(input())
print(bin(x))
x,y=input().split()
x=int(x)
y=int(y)
print(pow(x,y))
print(pow(y,x))
pp=[int(i) for i in input().split()]
print(pp.count(0))
pp=input().split()
print(pp.index('NiuNiu'))
pp=input()
print(pp.isalpha())
print(pp.isdigit())
print(pp.isspace())
pp=input()
if 'NiuNiu' in pp:
print(pp.find('NiuNiu'))
else:
print(-1)
pp=input()
print(pp.count("Niu"))
pp=input().split()
print(pp)
pp=[]
while 1:
x=input()
if x=='0':
break
pp.append(x)
print(" ".join(pp))
p=input()
print(p.replace('*','b'))
p=float(input())
print(round(p,2))
p=input()
print(eval(p))
p=input().split()
pp=set(p)
pp=sorted(pp)
print(pp)
def cal(x,y):
return x-y
p=int(input())
q=int(input())
print(cal(p,q))
print(cal(q,p))
p=int(input())
def fn(n):
if n==1:
return 2
if n==2:
return 3
else:
return fn(n-1)+fn(n-2)
print(fn(p))
import math
r=[1, 2, 4, 9, 10, 13]
for i in r:
print("%.2f" %(4*math.pi*i**2))
class Student:
def __init__(self,name,num,mark,level):
self.name=name
self.num=num
self.mark=mark
self.level=level
def __str__(self):
return (self.name+"'s student number is "+self.num+","+" and his grade is "+self.mark+". He submitted "+str(len(self.level.split()))+" assignments, each with a grade of "+self.level)
name1=input()
num1=input()
mark1=input()
level1=input()
stu=Student(name1,num1,mark1,level1)
print(stu)
name=input()
salary=int(input())
class Employee:
def __init__(self,name,salary,age=None):
self.name=name
self.salary=salary
self.age=age
def printclass(self):
try:
if self.age==None:
print("Error! No age")
else:
print(f"{self.name}'salary is {self.salary}, and his age is {self.age}")
except Exception as e:
return e
e=Employee(name,salary)
e.printclass()
e.age=int(input())
e.printclass()
name=input()
salary=int(input())
class Employee:
def __init__(self,name,salary):
self.name=name
self.salary=salary
def printclass(self):
try:
print(f"{self.name}'salary is {self.salary}, and his age is {self.age}")
except :
print(hasattr(e,'age'))
e=Employee(name,salary)
e.printclass()
setattr(e,'age',int(input()))
e.printclass()
class Coordinate:
def __init__(self,x,y):
self.x=x
self.y=y
def __str__(self):
print(f"({self.x}, {self.y})")
def __add__(self,Coordinate1):
return Coordinate(self.x+Coordinate1.x,self.y+Coordinate1.y)
x1,y1=list(map(int,input().split()))
c1=Coordinate(x1,y1)
x2,y2=list(map(int,input().split()))
c2=Coordinate(x2,y2)
c=c1.__add__(c2)
c.__str__()
import re
str1=input()
result=re.match("https://www", str1, re.I)
print(result.span())
import re
pp=input()
print(re.sub('\D','',pp))
import re
s=input()
r=re.match('[0-9-]+',s)
print(r.group())