1) Trong Python, câu lệnh nào sau đây dùng để mở tệp đọc dữ liệu ? a) <tên biến tệp> = open(<tên tệp>, ["w"], [encoding = "'utf-8"]) b) <tên tệp> = open(<tên biến tệp>, ["r"], [encoding = "'utf-8"]) c) <tên tệp> = open(<tên biến tệp>, ["w"], [encoding = "'utf-8"]) d) <tên biến tệp> = open(<tên tệp>, ["r"], [encoding = "'utf-8"]) 2) Trong Python, câu lệnh nào sau đây dùng để mở tệp ghi dữ liệu ? a) <tên biến tệp> = open(<tên tệp>, ["r"], [encoding = "'utf-8"]) b) <tên tệp> = open(<tên biến tệp>, ["r"], [encoding = "'utf-8"]) c) <tên tệp> = open(<tên biến tệp>, ["w"], [encoding = "'utf-8"]) d) <tên biến tệp> = open(<tên tệp>, ["w"], [encoding = "'utf-8"]) 3) Trong Python, câu lệnh dùng để ghi chuỗi ký tự vào tệp là: a) <biến tệp>.readlines(<Chuỗi ký tự>) b) <tên tệp>.read(<Chuỗi ký tự>) c) <tên tệp>.write(<Chuỗi ký tự>) d) <biến tệp>.write(<Chuỗi ký tự>) 4) Cho tệp input.txt chứa nội dung sau: 3 8, để đọc 2 số nguyên ra 2 biến a, b ta sử dụng lệnh nào sau đây? a) f=open("input.txt","r"); a,b=map(int,f.readline().split()) b) f=open("input.txt","w"); a,b=map(int,f.readline().split()) c) f=open("input.txt","r"); a,b=int(f.readline().split()) d) f=open("input.txt","w"); a,b=int(map(f.readline().split())) 5) Cho tệp input.txt chứa hai số nguyên mỗi số một dòng, để đọc 2 số nguyên ra 2 biến a, b ta sử dụng lệnh nào sau đây? a) f=open("input.txt","r"); a,b=int(f.readline()),int(f.readline()) b) f=open("input.txt","r"); a,b=map(int,f.readline().split()) c) f=open("input.txt","w"); a,b=int(f.readline().split()) d) f=open("input.txt","w"); a,b=int(map(f.readline().split())) 6) Trong Python, câu lệnh dùng để đọc tất cả các ký tự trong tệp là: a) <biến tệp>.writelines( ) b) <tên tệp>.read( ) c) <tên tệp>.write( ) d) <biến tệp>.read( ) 7) Trong Python, câu lệnh dùng để đọc từng dòng của tệp văn bản là: a) <biến tệp>.writelines( ) b) <tên tệp>.read( ) c) <tên tệp>.write( ) d) <biến tệp>.readline( ) 8) Thao tác đóng tệp trong Python a) close( ).<biến tệp> b) close( ) c) <tên tệp>.close( ) d) <biến tệp>.close( ) 9) Với S=12345, để ghi giá trị biến S vào tệp “ketqua.txt” (biến tệp f) ta sử dụng lệnh nào sau đây? a) f.write(S) b) f.write(str(S)) c) f.read(S) d) write(f,S) 10) Tệp “data.inp” chứa N số nguyên trên cùng 1 dòng, mỗi số cách nhau 1 khoảng trống (Vd: 1 3 2 9 8 7 -5 3), để đọc N số trong tệp “data.inp” vào danh sách A, ta dùng lệnh nào sau đây? a) A=list(map(int,f.readline().split())) b) A=list(int(map(f.readline().split())) c) A=map(int,f.readline().split()) d) A=map(list,int(f.readline().split()))
0%
[PYTHON] ÔN TẬP KIỂU TỆP
Share
Share
by
Daodinhngoc
Show More
Edit Content
Embed
Like
More
Leaderboard
Show more
Show less
This leaderboard is currently private. Click
Share
to make it public.
This leaderboard has been disabled by the resource owner.
This leaderboard is disabled as your options are different to the resource owner.
Revert Options
Quiz
is an open-ended template. It does not generate scores for a leaderboard.
Log in required
Theme
Fonts
Log in required
Options
Switch template
Interactives
Show all
More formats will appear as you play the activity.
Restore auto-saved:
?