This document discusses file input and output in Python. It explains how to open files using the open() function, specifying the mode as either 'r' to read, 'w' to write and overwrite, or 'a' to append. It describes how to read files line by line using readline() or into a list using readlines(). Writing files is similar, using write() to write strings or writelines() to write iterables. Iterables are data structures like strings and lists that can be iterated over using a for loop. The document concludes with announcing upcoming homework and exam dates for the course.
A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order
What is sorting algorithm
The bubble sort
The selection sort
The insertion sort
The Quick sort
The Shell Sort
Data Structures are the programmatic way of storing data so that data can be used efficiently
Introduction to DSA
Advantages & Disadvantages
Abstract Data Type (ADT)
Linear Array List
Downloadable Resources
A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order
What is sorting algorithm
The bubble sort
The selection sort
The insertion sort
The Quick sort
The Shell Sort
Data Structures are the programmatic way of storing data so that data can be used efficiently
Introduction to DSA
Advantages & Disadvantages
Abstract Data Type (ADT)
Linear Array List
Downloadable Resources
In computer science, a data structure is a data organization, management, and storage format that enables efficient access and modification. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data. https://apkleet.com
<a href="https://apkleet.com" >games apk </a>
A doubly-linked list takes all the functionality of a singly-linked
list and extends it for bi-directional movement in a list. We can
traverse, in other words, a linked list from the rst node in the
list to the last node in the list; and we can traverse from the
last node in the list to the rst node in the list. In this sec-
tion, we will maintain our focus primarily on the dierences be-
tween a doubly-linked list and a singly-linked list. Operations
of a Doubly-Linked List Our list will include two constructors:
Node and DoublyList.
Link list is a second most commonly used general purpose storage structures after arrays
What is Link List
Advantages
Disadvantages
Java Implementation of a Link List
Applications
This material aims to enable students to:
1) Understanding queue concept
2) Understanding enqueue, dequeue, front, rear operation in a queue
3) Understanding working of queue
4) Knowing of queue application
This material aims to enable students to:
1) Understanding stack concept
2) Understanding push, pop, peek or top, isEmpty, isFull operation in a stack
3) Understanding working of stack
4) Knowing of stack application
In computer science, a data structure is a data organization, management, and storage format that enables efficient access and modification. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data. https://apkleet.com
<a href="https://apkleet.com" >games apk </a>
A doubly-linked list takes all the functionality of a singly-linked
list and extends it for bi-directional movement in a list. We can
traverse, in other words, a linked list from the rst node in the
list to the last node in the list; and we can traverse from the
last node in the list to the rst node in the list. In this sec-
tion, we will maintain our focus primarily on the dierences be-
tween a doubly-linked list and a singly-linked list. Operations
of a Doubly-Linked List Our list will include two constructors:
Node and DoublyList.
Link list is a second most commonly used general purpose storage structures after arrays
What is Link List
Advantages
Disadvantages
Java Implementation of a Link List
Applications
This material aims to enable students to:
1) Understanding queue concept
2) Understanding enqueue, dequeue, front, rear operation in a queue
3) Understanding working of queue
4) Knowing of queue application
This material aims to enable students to:
1) Understanding stack concept
2) Understanding push, pop, peek or top, isEmpty, isFull operation in a stack
3) Understanding working of stack
4) Knowing of stack application
Workshop slides which give an overview of python programming. The slides are accompanied by DIY (do it yourself) programs which can be found as in GitHub (https://github.com/bhalajin/blueprints)
1. Variables - Learn to conveniently store data in your Python programs!
2. Numbers - Learn how numbers work behind the scenes in your Python programs!
3. Strings - Master the written word and automate messages using text!
4. Logic and Data Structures - Teach your Python programs to think and decide!
5. Loops - Save time and effort, by making computers do the hard work for you!
6. Functions - Automate Tasks by Creating your very own Python Functions that you can use over and over!
7. OOP - Add Python to Your Resumé By Mastering Object-Oriented Programming, an industry-standard programming technique!
This is the speech Max Liu gave at Percona Live Open Source Database Conference 2016.
Max Liu: Co-founder and CEO, a hacker with a free soul
The slide covered the following topics:
- Why another database?
- What kind of database we want to build?
- How to design such a database, including the principles, the architecture, and design decisions?
- How to develop such a database, including the architecture and the core technologies for TiKV and TiDB?
- How to test the database to ensure the quality and stability?
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
1.4 modern child centered education - mahatma gandhi-2.pptx
CS151 FIle Input and Output
1. Computer Science 151
An introduction to the art of computing
File Input and Ouptut
Rudy Martinez
2. CS151 Spring 2019
Opening Files in Python
● Open() function
○ Returns a file object
○ myFile = open(‘filename’, ‘mode’)
■ Mode:
● ‘r’ - Read only
● ‘w’ - write, allows you to write and edit files
○ This will overwrite an existing file! Be careful.
● ‘a’ - append will add to the end of the file.
myfile=open(‘Moby_Dick_by_Mellville.txt’, ‘r’)
3. CS151 Spring 2019
Using a file object
myfile=open(‘Moby_Dick_by_Mellville.txt’, ‘r’)
● To read a single line.
○ myfile.readline()
■ This returns a string
● To read all lines into a list.
○ textList = myfile.readlines()
■ This returns a list
4. CS151 Spring 2019
How to read all lines
● textList = myfile.readlines()
● How do we go through a list?
○ For loop!
# Open file
myfile=open('/home/rudym/Downloads/Moby_Dick_by_Melville.txt', 'r')
# Load each line in file to list textList
textList = myfile.readlines()
# For loop to read and print each line
for i in range(0, len(textList), 1):
print(textList[i])
5. CS151 Spring 2019
Writing Files
● Writing files is similar to reading files.
● The main misstep is using ‘w’ instead of ‘a’ when you have a file you want to
add to.
○ ‘w’ will write over any file
○ ‘a’ will append to the end of the file preserving previous entries
outfile = open(‘Filename’, ‘w’)
6. CS151 Spring 2019
Writing files
● Also like read, there are two main functions for putting text into a file.
○ write(‘string’) - will write a passed string into the file and does not append a carriage return
○ writelines( string, list, or dictionary ) - takes anything that can be iterated
■ Iterables are strings, list and dictionaries
outfile = open(‘test.txt’, ‘w’)
for i in range(0, 10, 1):
outfile.write(str(i))
Output: 0123456789
outfile = open(‘test.txt’, ‘w’)
myString = ‘Hello Cruel World’
outfile.writelines(myString)
Output: Hello Cruel World
7. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[H]
8. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[He]
9. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hel]
10. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hell]
11. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello]
12. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello ]
13. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello C]
14. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Cr]
15. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Cru]
16. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Crue]
17. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Cruel]
18. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Cruel ]
19. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Cruel W]
20. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Cruel Wo]
21. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Cruel Wor]
22. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Cruel Worl]
23. CS151 Spring 2019
Iterables
● An iterable is any data structure that has an iterator
● What is an iterator?
○ An iterator is a pointer that walks any data structure.
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
myString H e l l o C r u e l W o r l d
[Hello Cruel World]
24. CS151 Spring 2019
For loops revisited!
Old For loop
for i in range(0, len(myString), 1):
print(myString[i])
Quick Loop
for i in myString:
print(i]
The two for loops below do the exact same thing, but one is short hand!
Why didn’t you teach us this first?!?*?
25. CS151 Spring 2019
To Sum it up
● Open returns a file object for reading and writing.
● Reading:
○ readline() - Single line of text
○ readlines() - All lines into list
● Writing:
○ writeline() - Single string to file
○ writelines() - An iterable to the file
26. CS151 Spring 2019
Friday
● 2/15 Homework 2 part A assigned
● 2/20 Homework 2 part A DUE! (5 days)
● 2/22 Homework 2 part B assigned
● 2/27 Homework 2 part B DUE! (5 days)
● 3/1 Homework 2 part C assigned
● 3/4 Exam Review!!!
● 3/6 Midterm Exam
● 3/29 Homework 2 part C DUE! (nearly a month)