• 2022-06-05
    题目:给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。x = int(input("input a number:"))a = x // 10000________________c = x % 1000 // 100d = x % 100 // 10e = x % 10if a != 0: print ("there are 5 ",e,d,c,b,a)elif b != 0: print ("there are 4 ",d,c,b,a)elif c != 0: print ("there are 3 ",e,d,c)elif d != 0: print ("there are 2 ",e,d)else: print ("there are 1",e)
    A: b = x // 10000 // 1000
    B: b = x % 10000 // 1000
    C: b = x // 10000 % 1000
    D: b = x % 10000 % 1000
  • B

    内容

    • 0

      下列程序段的输出结果是_____。 x = 10 if x > 5: y = 2 * x elif x > 3: y = 3 * x elif x > 1: y = 4 * x else: y = x print(y)

    • 1

      如下代码可以实现当输入6的时候输出x>5,输入4的时候输出 3<x<=5,输入1的时候输出x<=3 x = int(input()) if x>5: print("x>5") elif x>3: print("3<x<=5") print("x<=3")

    • 2

      【单选题】2.以下 if 语句语法正确的是( )。 A. if(x>0) print(x) Else print(-x) B. If x>0 print(x) else print(-x) C. if x>0: Print(x) Else print(-x) D. if x>0: Print(x) else:print(-x) A. if(x>0)   

    • 3

      Which of the following are NOT valid if/else statements in Python, assuming x and y are defined appropriately: A: if x < y: print('foo') else: print('bar') B: if x < y and x > 10: print('foo') C: if x < y: print('foo'); print('bar'); print('baz') D: if x < y: print('foo') elif y < x: print('bar') else: print('baz')

    • 4

      设有下面的语句:Print IIf(x>0, 1, IIf(x<0,-1, 0))与此语句输出结果不同的程序段是______。 A: If x>0 Then x=1 ElseIf x<0 Then x=-1 End If Print x B: If x>0 Then Print 1 ElseIf x<0 Then Print-1 Else Print 0 End If C: Select Case x Case Is>0 Print 1 Case Is<0 Print-1 Case Else Print 0 End Select D: If x<>0 Then If x>0 Then Print 1 ElseIf x<0 Then Print-1 Else Print 0 End If