当前位置:网站首页>Day3 data type and Operator jobs

Day3 data type and Operator jobs

2022-06-26 04:59:00 The story of Ula

day3 Data types and Operator jobs

choice question

  1. print(100 - 25 * 3 % 4) What should be output ? (B)

    A. 1

    B. 97

    C. 25

    D. 0

  2. Which of the following statements is wrong (A).

    A. Except for dictionary types , All standard objects can be used for Boolean testing

    B. The Boolean value of an empty string is False

    C. The Boolean value of an empty list object is False

    D. The value is 0 The Boolean value of any numeric object of is False

  3. Python Unsupported data types are (A).

    A. char

    B. int

    C. float

    D. list

  4. ( multi-select )n = 6784, You can get 7 The way to do this is (C,D).

    A. n / 1000 % 100

    B. n % 1000 / 100

    C. n // 100 % 10

    D. n // 10 % 100 // 10

  5. Run the following program , When entering... From the keyboard 12, The result of the operation is (A).

    x = (input())
    print(type(x))
    

    A. <class 'str'>

    B. <class 'int'>

    C. error

    D. class 'dict'

  6. The operation result of the following expression is ( D ) .

    a = 100
    b = False
    print(a * b > -1)
    

    A. False

    B. 1

    C. 0

    D.True

Completion

  1. stay Python The empty type is (None).
  2. The function name to view the type of data in the variable is (type()).
  3. It is known that x = 3 == 3, After execution , Variable x The value of is (True).
  4. It is known that x = 3, Then execute the statement x += 6 after ,x The value of is (9).
  5. expression 3 ** 2 The value of is (9), expression 3 * 2 The value of is (6), expression 4 ** 0.5 The value of is (2.0).

Programming questions

  1. Write to determine whether a number can be simultaneously 3 and 7 Divisible conditional statement , And print the corresponding results .

     for example : Input  21  Print  True,  Input  9  Print  False.
    print(num % 7 == 0 and num % 3 == 0)
    
  2. Write to determine whether a number can be 3 perhaps 7 to be divisible by , But not both 3 perhaps 7 Divisible conditional statement , And print the corresponding results .

     for example : Input  14  Print  True,  Input  4  Print  False,  Input  21  Print  False.
    print((num % 7 == 0 or num % 3 == 0) and (not num % 21 == 0))
    
  3. Enter year , Write code to judge whether the entered year is a leap year , And print the corresponding results .( It's a leap year condition : Can be 4 Divisible but not by 100 Divisible or capable of being divisible by 400 Divisible year )

     for example : Input  2020  Print  True,  Input  2011  Print  False
    print(year % 4 == 0 and year % 100 != 0 or year % 400 == 0)
    
  4. Suppose today's class time is 15678 second , Programming to calculate the class time today is how many hours , How many minutes? , How many seconds ; With ‘XX when XX branch XX second ’ It's expressed in a different way .

     for example :  Time  67  second   —> 0  when  1  branch  7  second 
    time = 15678
    
    hour = time // 3600
    minuta = time % 3600 // 60
    second = time % 60
    
    print('{}  when {}  branch {}  second '.format(hour, minuta, second))
    
  5. Define two variables to save a person's height and weight , Programming to determine whether the person's body is normal !

    The formula : weight (kg)/ height (m) The square value of stay 18.5 ~ 24.9 It's normal .

     for example :  Enter the weight : 55,  Enter the height :1.55,  Output : True
    weight = int(input(' Please enter the weight :'))
    height = float(input(' Please enter height ( rice ):'))
    
    BMI = weight / (height ** 2)
    print(18.5 <= BMI <= 24.5)
    

Short answer

  1. Python What are the built-in data types ?

    1. int( integer )
    2. float( floating-point )
    3. complex( The plural )
    4. bool( Boolean type )
    5. str( character string )
    6. list( list )
    7. dict( Dictionaries )
    8. set( aggregate )
    9. tuple( Tuples )
  2. Write your thoughts about today ⽇ Where there are questions in the teaching content of the day ⽅ Fang ( Or knowledge points that feel difficult ).

    nothing

原网站

版权声明
本文为[The story of Ula]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180509132343.html