Qual função é usada para abrir um arquivo em Python para escrita, criando o arquivo se ele não existir?

Manipulação de Arquivos em Python

Quiz
•
Information Technology (IT)
•
University
•
Hard

CRISTINA CO
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
open("arquivo.txt", "r")
open("arquivo.txt", "w")
open("arquivo.txt", "a")
open("arquivo.txt", "x")
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Se você quiser adicionar novos dados ao final de um arquivo sem sobrescrever o conteúdo existente, qual modo de abertura você deve usar?
A) r
B) w
C) a
D) x
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Qual comando é usado para escrever dados em um arquivo após ele ter sido aberto para escrita?
arquivo.write("Texto")
arquivo.append("Texto")
arquivo.add("Texto")
arquivo.print("Texto")
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Ao ler um arquivo linha por linha, qual método retorna uma lista onde cada elemento é uma linha do arquivo?
arquivo.read()
arquivo.readlines()
arquivo.readline()
arquivo.splitlines()
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
O que o código a seguir faz? with open("dados.txt", "r") as arquivo: conteudo = arquivo.read()
Lê o arquivo `dados.txt` linha por linha
Lê todo o conteúdo do arquivo `dados.txt` e armazena na variável `conteudo`
Cria um arquivo chamado `dados.txt`
Escreve dados no arquivo `dados.txt`
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Qual a saída do código abaixo? dados = [10, 20, 30, 40] print(sum(dados) / len(dados))
A) 25
B) 20
C) 100
D) 40
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Considere o código abaixo. Qual será a saída? texto = "Python é incrível" with open("texto.txt", "w") as arquivo: arquivo.write(texto) with open("texto.txt", "r") as arquivo: print(arquivo.read()) A) Python é incrível B) Erro, pois o arquivo está no modo de leitura C) texto.txt D) Nada, pois o arquivo está vazio
A) Python é incrível
B) Erro, pois o arquivo está no modo de leitura
C) texto.txt
D) Nada, pois o arquivo está vazio
Create a free account and access millions of resources
Similar Resources on Quizizz
10 questions
BD 06 SQL DDL

Quiz
•
University
10 questions
QUIZ 2 HTV

Quiz
•
12th Grade - University
14 questions
Teste de SQL: Tabelas e Inserções

Quiz
•
10th Grade - University
15 questions
Fundamentos Essenciais da Ciberseguranca - SEC7 | S1

Quiz
•
University
10 questions
Conhecimentos sobre o App Inventor

Quiz
•
9th Grade - University
10 questions
Quiz de Seg. da Informação

Quiz
•
University
7 questions
SEI'24

Quiz
•
University
13 questions
Parcial 1 Reparación y Soporte- 5to BACO - I Unidad Forma A

Quiz
•
10th Grade - University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade