Tài Liệu Ôn Tập Olympic Tin Học Quốc Tế HKICO 2023 Python

57 164 6
Tài Liệu Ôn Tập Olympic Tin Học Quốc Tế HKICO 2023  Python

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Tài liệu Tin học ôn tập của Ngôn ngữ Python cho các kỳ thi Olympic Tin Học Quốc tế, Các kỳ thi liên quan đến lập trình, máy tính quốc tế như HKICO, UET, CCO, IOI, IC3 Spark Challenge ...có cả đáp án ở cuối tài liệu

1 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 ĐỀ SỐ 1 Consider the following Python script: script.py When you click on the file using a Windows file explorer, the script executes but you are unable to see the output How would you fix that? A B There is no output as the script has an error C D There is nothing to output E None of the above What is the output of the following code? A JamesJamesJamesJamesJamesJames B JamesJamesJamesJamesJames C JamesJamesJamesJames D JamesJamesJames E Error: invalid syntax Analyze the given below code 10 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 A You cannot use print(self) as a function name B Program will print ‘Hello’ if we change print(d) to print(self.d) C Program has an error because class A does not have a constructor D Syntax Error E None of the above What will be the output of the following code? A TutorialsPoint B Website C ('TutorialsPoint' , 'website') D It will show an Error E None of the above Given the following function fun1() Please select the correct function calls A fun1(name=’Emma’, age=23) B fun1(name=’Emma’, 23) C fun1(‘Emma’, 23) D fun1(Emma, 23) E fun1(nam = Emma, age= 23) What is the output of the add() function call A 15 B C (8,7) D E Syntax Error is 100 in binary and 11 is 1011 What is the output of the following bitwise operators? 11 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 A 15 B 14 C 11 D 15 E 14 What is a correct syntax to output "Hello World" in Python? A echo("Hello World"); B p("Hello World") C print("Hello World") D echo "Hello World" E None of the above Refer to the following code for question to 10 Jack executed the code with the python interpreter What is the output? A There are some errors in the code so the output goes to error stream B Salary: 8000 C Salary: 12000 D Salary: E None of the above 10 If Jack wants to print “Salary: 12000 Salary: 8000” what will he do? A Add one more command line “print("Salary:", salary)” directly after “printSalary()” B Add one more command line “print("Salary:", salary)” directly before “printSalary()” C Add the command line “print("Salary:", salary)” to any position D Add the command line “printSalary()” to any position E None of the above 12 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 11 What is the output of the following code? A py B pyn C ynab D yn E pyna 12 What is the value of “Hello”.upper().capitalize()? A “Hello” B “hello” C “HELLO” D Runtime Error E None of the above 13 What is the statement evaluates the same to the statement below? A print ( 2*27*4) B print ( 2*3*4) C print ( 2*3**4) D print ( 2*3*3*4) E None of the above 14 Which method can be used to replace parts of a string? A replaceString() 15 C repl() D switch() E replaceStr() D (5, 10) E Syntax Error What is the value of res after executing this code A 15 16 B replace() B 10 C Which of the following is False? A B C [5] == [5] D E 13 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 17 What is the output of the following addition (+) operator A [10, 20, 30, 40] [10, 20, 30, 40] B [10, 20] [10, 20, 30, 40] C [10, 20, 30, 40] [10, 20] D [40, 30, 20, 10] [40, 30, 20, 10] E None of the above 18 Which of the following operators has the highest precedence? A not B & C * D + E - 19 What is the output of the expression print(-18 // 4)? A -4 B C -5 D E None of the above 20 What is the value of the var after the for loop completes its execution? A 20 B 21 C 10 D 30 E None of the above 14 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 ĐỀ SỐ Which of the following statements is true? A Python is an interpreted language B Python is a high-level programming language C Python is an object-oriented language D All of the above E None of the above What is output of: A foo\bar baz B foo\\barnbaz C foo\bar\nbaz D foo\\bar\nbaz E None of the above In the Python statement x = a + - b: • a and b are • a + - b is A operators, a statement B operands, an expression C operands, an equation D terms, a group E operators, an expression Suppose s is assigned as follows: All of the following expressions produce the same result except one Which one? A s[::5] B s[0] + s[-1] C s[::-1][::-5] D s[::-1][-1] + s[len(s)-1] E s[::-5] 15 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 What is the output of the following code? A B 4 C D E It doesn’t generate any output What is the output of the following code? A 0 B 1 C 2 D x y E None None What is the output of the following program? A B C 10 D 24 E Syntax Error 16 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 Which of the following operators has the lowest precedence? A ** B + C and D % E not What is the output of the following code? A The program gives an error because there is no constructor for class Test B Signature for the print method is incorrect, so an error is thrown C Python class D The above code will execute correctly on changing print(s) to print(self.s) E The program executed with errors 10 What will be the output of the following code? A counter is 101, number of times is B counter is 100, number of times is C counter is 100, number of times is 100 D counter is 101, number of times is 101 E counter is 0, number of times is 17 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 11 What gets printed? A B C D E 12 Which numbers are printed? A 2, 4, B 0, 1, 2, 4, 5, C 0, 1, 4, D 0, 1, 4, 5, 6, 7, 8, E 1, 2, 4, 5, 13 Consider the following code, What is the output? A B C D E 18 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 What is the value of the expression -20 // -7 % 3? A -1 B -2 C D E What is the output of the following program? def func(a = [], b = 2): a.extend(range(b)) return len(a) def main(): print(func(b = func())) main() A B C D E None of the above (including runtime error) Suppose there exists a file "a.py" in the working directory Which of the following expressions evaluates to True in Windows (after importing the correct modules)? import os import pathlib A os.stat("a.py").st_ctime == pathlib.Path("a.py").stat().st_birthtime B pathlib.Path("a.py").stat().st_birthtime == os.path.getctime("a.py") C os.path.getbirthtime("a.py") == pathlib("a.py").stat().st_birthtime D os.stat("a.py").st_ctime == os.path.getctime("a.py") E None of the above Which of the following expressions evaluates to True? A double(3.213322459373) == 3.213322459373 B float(3.2210593) == 3.2210593 C int(3.221) == 3.221 D All of the above E None of the above 51 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 10 What is the output of the following code? class A: a = @property def a(self): return eval(self. a) @a.setter def a(self, value): self. a = value a = A() b=2 c=3 a.a = "b + c" b=5 print(a.a) A B C D E None of the above 11 What is the value of the following expression? list(dict.fromkeys([3,2,2,1,1,2])) A { 3: 2, 2: 1, 1: } B [3, 2, 2, 1, 1, 2] C [3, 2, 1] D [(3, 2), (2, 1), (1, 2)] E None of the above 12 What is the output of the following code? a = 100,000,000 print(str(a)[1]) A B C None D ( E None of the above 52 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 13 What is the output of the following code after user input "10" (without the quotes)? a = input() b = a + 20 print(b[1]) A B 1020 C None D 30 E None of the above 14 What is the value of the following expression? len([range(5)][-2:]) A B C D -2 E None of the above 15 What is the output of the following code? class A: def enter (self): print(end="OK") def exit (self, a, b, c): print(end="HI") with A(): print(end="BYE") A OKHIBYE B HIOKBYE C OKBYEHI D HIBYEOK E None of the above 16 What is the output of the following code? for i in range(13): if i // -3 == -1: break print(i // -3) else: print("HI") 53 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 A B C -1 -1 -1 -2 -2 -2 -3 -3 -3 -4 -4 -4 HI D HI E None of the above 17 What is the output of the following program? import functools a = [1, 2, 3, 4, 5] print(functools.reduce(lambda x, y: x * y // 2, a)) A B C 7.5 D [1, 2, 3, 4, 5] E None of the above 18 What is the value of the following expression? list(filter(lambda x: x % 3, range(10)))[:-2][-2] A B C [0, 1, 4, 5, 7, 8] D [4, 5] E None of the above 19 What is the output of the following program? a = list(range(5), range(2)) a.reverse() print(a[0][0]) 54 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 A range(0, 5) B range(0, 2) C D E None of the above 20 What is the output of the following program? a=4 def func(a = 6): print(end=str(a)) a=2 a=3 func(a = 1) print(end=str(a)) A 61 B 42 C 13 D 11 E None of the above 55 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 ĐỀ SỐ Đề thi Vòng chung kết quốc gia năm học 2019 – 2020 What is the purpose of in code like? A Aesthetic consideration B The code would not executed without this definition C Prevent main() from being executed when imported as module D It is a programming convention as main() also presented in other languages like C/C++ or Java E None of the above Why can be executed without error but cannot? A Invalid type, number is not a string B Argument “output” for function print() only accepts list C end = “2” is omitted by print() function D All of the above E None of the above Does the following code have errors during execution? If so, what is it? A No, the code doesn’t have errors B Yes, unidentified syntax (semicolon) C Yes, integer cannot add with float D Yes, expression a + b does not have a left hand side operator E None of the above 56 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 What is the expected output of the following code? A B C D E None of the above What is the expected output of the following code? A abcd B dbce C edcb D dcea E None of the above What is the value of ? A B 10 C 170 D 495 E None of the above 57 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 The following code produces runtime error, What is the cause the interpreter would show? A Argument type for func() is indeterminate B Return type for func() is indeterminate C Unsupported operand types for ‘+’ D main() arguments is not supported E None of the above What could be filled in place of line in the following code (indicated with comments) so that the expected output is ? A B C D E None of the above 58 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 Refer to the following code for question to 11: There could be different implementations of fib method: I II III IV 59 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 Which implementation is fastest? A I B II C III D V E They have the same performance 10 Which implementation(s) consumes most memory during execution? A I & II B I C II & III D IV E No memory is needed at all 11 Implementation I doesn’t use for-loop, implementation II doesn’t use if, implementation III doesn’t invoke itself, implementation IV invoke itself once in each iteration Which of the following is a correct statement? A Implementation without for-loop is always the fastest B Implementation with less memory usage is always the fastest C Shorter the implementation, faster the execution D Recursion is always the fastest E None of the above 12 What is the expected output of the following code? A B C D E 60 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 Refer to the following code for question 13 to 15: 13 Which of the following is a correct statement describing the relationship of class A, B and C? A Class A inherits class B and C and invoking initializer of parent class B B Class B and C inherits class A and both class implicitly invoke initializer of class A C Class C is a subclass of class B and both are subclass of class A D The code is not correct and would produce syntax error E None of the above 14 What is the expected output of the code? A B C D The code has runtime error E None of the above 61 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 15 What is “c” in line is? And “self.c” in line 10? A Empty variable, integral variable B Class variable, instance variable C Member variable, constructor variable D The code is not correct syntax-wise E None of the above 16 What is the expected output of the following code? A B C D E None of the above Refer to the following code for question 17 to 18: 17 Expression not equal? in line evaluates to? If False, what is the reason they are A True B False, new list instances are created (and returned) each time func is invoked C False, variable i is modified between two func call so the values in the list are not the same D The code would result in runtime error E None of the above 62 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 18 What is the value of b in line 11? A B C D E None of the above 19 Given the code: Which of the following is equivalent to the expression ? A B C D All of the above E None of the above 20 Given the code: What is the value of the expression And its output: ? If False, what is the appropriate reason? A True B False, list a is consumed but b is not, because list a is not explicit C False, every instance of list does not equal (evaluate to True) in case of ‘==’ operator D False, values of elements are not equal in list a and b, they appear to be the same when printed out E None of the above 63 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 ĐÁP ÁN THAM KHẢO ĐỀ SỐ Câu Đáp án Câu Đáp án Câu Đáp án Câu Đáp án C A B B A 10 C A C C A 11 12 13 14 15 D C A B A 16 17 18 19 20 E A C C B ĐỀ SỐ Câu Đáp án Câu Đáp án Câu Đáp án Câu Đáp án D D B E B 10 B C C D B 11 12 13 14 15 A C D A A 16 17 18 19 20 C A C D B ĐỀ SỐ Câu Đáp án Câu Đáp án Câu Đáp án Câu Đáp án D A C A E 10 E C D D B 11 12 13 14 15 E B A D A 16 17 18 19 20 C C B D C ĐỀ SỐ Câu Đáp án Câu Đáp án Câu Đáp án Câu Đáp án B C D C D 10 C D C C E 11 12 13 14 15 D A A D D 16 17 18 19 20 C E D B D 64 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455 ĐỀ SỐ 5: Đề thi Vòng loại quốc gia năm học 2021 – 2022 Câu Đáp án Câu Đáp án Câu Đáp án Câu Đáp án C A B B B A C E 10 11 12 A C D D 13 14 15 16 A A E A ĐỀ SỐ 6: Đề thi Vòng chung kết quốc gia năm học 2021 – 2022 Câu Đáp án Câu Đáp án Câu Đáp án Câu Đáp án B A B A D 10 B C A D C 11 12 13 14 15 A E E D D 16 17 18 19 20 C B E B E ĐỀ SỐ 7: Đề thi Vòng loại quốc gia năm học 2020 – 2021 Câu Đáp án Câu Đáp án Câu Đáp án Câu Đáp án A C C E D 10 B B C C E 11 12 13 14 15 D A C D C 16 17 18 19 20 E A B E D ĐỀ SỐ 8: Đề thi Vòng chung kết quốc gia năm học 2020 – 2021 Câu Đáp án Câu Đáp án Câu Đáp án Câu Đáp án C A D B A 10 E D D B D 11 12 13 14 15 C B E A C 16 17 18 19 20 A B B E C ĐỀ SỐ 9: Đề thi Vòng chung kết quốc gia năm học 2019 – 2020 Câu Đáp án Câu Đáp án Câu Đáp án Câu Đáp án C E E B D 10 B C C B C 11 12 13 14 15 B C E E E 16 17 18 19 20 B A C D D 65 KỲ THI OLYMPIC TIN HỌC QUỐC TẾ HKICO (HongKong International Computational Olympiad) FERMAT Education: Số 6A1 tiểu khu Ngọc Khánh, Ba Đình, Hà Nội – 0961 603 003 / 0917 830 455

Ngày đăng: 26/07/2023, 10:42

Tài liệu cùng người dùng

Tài liệu liên quan