Python Projects for Beginners a ten-Week Bootcamp Approach to Python Programming



Download 2,61 Mb.
bet101/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   97   98   99   100   101   102   103   104   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

File Modes in Python


Table 6-2 shows a few more file modes that you can use in Python.
Table 6-2. File Modes

Mode

Description

‘r’
‘w’
‘x’
‘a’
‘b’
‘+’

This is the default mode. it opens the file for reading only. opens file for writing. if file doesn’t exist, it creates one.
Creates a new file. if file exists, the operation fails.
open in append mode. if file doesn’t exist, it creates one.
open in binary mode.
Will open a file for reading and writing. Good for updating.










THURSDAY EXERCISES

  1. User Input: ask a user for their favorite number, and save it to a text file.

  2. Data Dumping: Using the dictionary of following data, save the information to a csv file with the keys as the headers and the values as the rows of data:

>>> data = {
'name' : ['Dave', 'Dennis', 'Peter', 'Jess'],
'language': ['Python', 'C', 'Java', 'Python']
}

Today we learned how to work with text and CsV files. There are two methods for working with files, each has their own purpose, but generally the with statement is easier to work with.
Friday: Creating a User Database with CSV Files
For this week’s project, we’ll be building a replica of a user database with CSV files. We’ll be able to take input and allow users to log in/log out/register.
To follow along with this lesson, let’s continue from our previous notebook file
Week_06” and add a markdown cell at the bottom that says, “Friday Project: Creating a

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   97   98   99   100   101   102   103   104   ...   200




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish