This document provides an overview of the Python programming language, including its history, key features, syntax examples, and common uses. It also discusses how Python can be used under Linux and some potential issues.
The document discusses programming for fun and enjoyment. It provides tips on using Vim and Ruby for fun programming projects. It also discusses Ruby programming concepts like classes and threads. Finally, it promotes programming meetups and brigades as a way to socially engage with other programmers.
Python Workshop - Learn Python the Hard WayUtkarsh Sengar
This document provides an introduction to learning Python. It discusses prerequisites for Python, basic Python concepts like variables, data types, operators, conditionals and loops. It also covers functions, files, classes and exceptions handling in Python. The document demonstrates these concepts through examples and exercises learners to practice char frequency counting and Caesar cipher encoding/decoding in Python. It encourages learners to practice more to master the language and provides additional learning resources.
Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive standard library.
A slightly modified version of original "An introduction to Python
for absolute beginners" slides. For credits please check the second page. I used this presentation for my company's internal Python course.
This document discusses file handling in Python. It begins by explaining that files allow permanent storage of data, unlike standard input/output which is volatile. It then covers opening files in different modes, reading files line-by-line or as a whole, and modifying the file pointer position using seek(). Key points include opening files returns a file object, reading can be done line-by-line with for loops or using read()/readlines(), and seek() allows changing the file pointer location.
This document provides an overview and introduction to Python programming. It covers setting up Python, background on the language, basic syntax like printing, variables, operators, control structures, functions, and data structures. It encourages participation and practicing the concepts by following along. The goal is to teach the fundamentals of Python in an interactive class format.
The document discusses files and operations on files in C. It covers:
1. There are two types of files - sequential and random. Sequential files are accessed sequentially like cassettes while random files allow non-sequential access like CDs.
2. Common file operations include read, write, and append. To perform operations the file pointer must be declared, the file opened, the operation done, and the file closed.
3. Functions to write to sequential files include fprintf(), fputc(), and fputs(). Functions to read include fscanf(), fgetc(), and fgets(). Examples are given to demonstrate writing and reading data from files.
The document contains code snippets for several Python programs that demonstrate various Python features:
- The First.py program prints lines and gets user input
- The list_comp.py program shows looping vs list comprehension to create lists
- The fav_movies.py program demonstrates reading from and writing to files
- The get_particular_line.py program reads a specific line from a file
- The zip_length.py program reads files from a zip archive and prints their lengths
- The details.py program gets system details like name and IP address
- The password_gen.py program generates a random 10 character password
This document introduces Python for network engineers, covering an overview of Python, what tasks it can perform like network automation, how to run Python interactively and with files, differences between Python and shell scripting, Python data types, modules, and includes an example Python program to login to a switch and retrieve interface configuration using Telnet.
This document discusses metaprogramming in Julia. It describes how Julia code is processed at compile time, including lexical analysis, syntax analysis, semantic analysis, intermediate code generation, optimization, and code generation. It also discusses how macros allow generating new Julia code at compile time and can be used to implement syntactic abstractions like decorators. Finally, it mentions how generated functions allow specializing method implementations based on types of arguments passed at runtime.
This document presents an overview of file operations and data parsing in Python. It covers opening, reading, writing, and closing files, as well as using regular expressions to parse text data through functions like re.search(), re.findall(), re.split(), and re.sub(). Examples are provided for reading and writing files, manipulating file pointers, saving complex data with pickle, and using regular expressions to match patterns and extract or replace substrings in texts. The document aims to introduce Python tools for working with files and parsing textual data.
Python is a high-level, interpreted programming language that is designed to be easy to read and write. It has a clear syntax using English keywords and its code is often shorter than languages like C++ and Java. Python is widely used for web development, software development, science, and machine learning. It has a large standard library and can be extended through modules. Some key data structures in Python include lists, tuples, and dictionaries.
PyCon 2013 : Scripting to PyPi to GitHub and MoreMatt Harrison
This document discusses various aspects of developing and distributing Python projects, including versioning, configuration, logging, file input, shell invocation, environment layout, project layout, documentation, automation with Makefiles, packaging, testing, GitHub, Travis CI, and PyPI. It recommends using semantic versioning, the logging module, parsing files with the file object interface, invoking shell commands with subprocess, using virtualenv for sandboxed environments, Sphinx for documentation, Makefiles to automate tasks, setuptools for packaging, and GitHub, Travis CI and PyPI for distribution.
This document provides an overview of Python for Unix and Linux System Administration by Noah Gift and Jeremy M. Jones. It includes information about related O'Reilly titles, conferences, and online resources from O'Reilly such as oreilly.com and oreillynet.com. It also discusses the Safari Bookshelf online reference library and upcoming O'Reilly conferences.
Follow me on Twitter at http://www.twitter.com/cballou or checkout my startup at http://www.pop.co.
In this presentation we will cover the best features and additions in PHP 5.5. You can look forward to the following:
* Support for generators has been added via the yield keyword
* Usage of the new finally keyword in try-catch blocks
* An overview and examples of the new password hashing API
* The foreach control structure now supports unpacking nested arrays into separate variables via the list() construct
* empty() supports arbitrary expressions such as closures returning false
* array and string literal dereferencing
* The Zend Optimiser+ opcode cache (via the new OPcache extension)
The document discusses file input and output in Python. It covers opening files, reading the entire file or line by line, writing to files, and closing files. It also covers if/elif/else conditional statements, comparison operators, and examples of problems and solutions involving file I/O and conditional logic.
This document provides an overview of the Python programming language. It discusses why Python was created, its key features like being an interpreted, dynamically typed language with indentation that counts. It also lists Python's core keywords and datatypes like numbers, strings, lists, dictionaries, tuples, files and other types. Finally, it outlines some of Python's basic operators like arithmetic, relational, bitwise, assignment and logical operators.
This document provides an overview of functions and file handling in Python. It discusses defining user-defined functions with the def keyword, including passing arguments, default arguments, keyword arguments, and variable number of arguments. It also covers recursion, anonymous functions, and attributes of file objects. For file handling, it explains opening, reading, writing, and appending files, as well as the different file modes.
This document provides an introduction to programming in C and using Unix commands. It discusses functions for input/output like printf, scanf, fopen, fclose, fscanf, and fprintf. Pipes are realized as file descriptors that link output to input. The sendmail command allows transmission of email from C programs by writing to a pipe opened with popen. Overall it covers basic I/O operations in C and how to interface with Unix commands like sendmail.
Getting started in Python presentation by Laban KGDSCKYAMBOGO
Python Overview and getting started in Python Language. It includes on how to install, run it and carrying out some simple python codes in different environments(IDLEs)
This document discusses file handling functions in C including fopen(), fclose(), getc(), putc(), fscanf(), fprintf(), getw(), putw(), fseek(), ftell(), and rewind() for reading, writing, and manipulating data in files. It also covers file opening modes in C such as r, w, a, r+, w+, a+, rb, wb, ab, rb+, wb+, and ab+ for reading, writing, and updating text and binary files.
Turning Your Iterators Up to 11: New Features for Complex Iterator Implementa...Accumulo Summit
1) The document discusses new features for complex iterator implementations in Apache Accumulo, including stateful iterators, deep copying iterators, multi-threading iterators, and implementing the YieldingKeyValue interface for long running scans.
2) It provides examples of using iterators for pre-fetching data and implementing processing pipelines.
3) The document also covers best practices for debugging, testing, and monitoring iterators using metrics.
A file is a collection of related data that a computer treats as a single unit. Files allow data to be stored permanently even when the computer is shut down. C uses the FILE structure to store attributes of a file. Files allow for flexible data storage and retrieval of large data volumes like experimental results. Key file operations in C include opening, reading, writing, and closing files. Functions like fopen(), fread(), fwrite(), fclose() perform these operations.
This document provides an overview of how to use the UNIX operating system. It discusses logging in, the home directory, common commands like ls and cd, copying and deleting files, pipes, input/output redirection, shell variables, job control, and quoting special characters. The document is intended to help new UNIX users get started with basic file management and command line tasks.
Outlines of this lecture:
- What is stream?
- File Output Stream Class
- File Input Stream Class
- Byte Array Output Stream Class
- Sequence Input Stream Class
- File Reader Class
- File Writer Class
- Scanner with String
DEFINICION DE MEMBRANA PLASMATICA O CELULAR - FUNCIONES - ENDOCITOSIS - EXOCITOSIS - CARACTERISTICAS DE LA MEMBRANA PLASMATICA - DIFICION DE POTENCIAL DE ACCION - GRAFICAS DE POTENCIAL DE ACCION
Jonathan Phillips is seeking a position as a GIS/remote sensing analyst utilizing his experience in map development, design, and imagery analysis. He has worked as a research assistant at the University of Toledo where he mentored students, conducted surveys, digitized and mapped data, and collaborated on projects. Phillips has a Bachelor's degree in Adolescent Young Adult Social Studies and is completing his Master's degree in Geography and Planning at the University of Toledo with a focus in GIS and remote sensing. He has skills in various GIS and remote sensing software as well as statistical and modeling programs.
The document contains code snippets for several Python programs that demonstrate various Python features:
- The First.py program prints lines and gets user input
- The list_comp.py program shows looping vs list comprehension to create lists
- The fav_movies.py program demonstrates reading from and writing to files
- The get_particular_line.py program reads a specific line from a file
- The zip_length.py program reads files from a zip archive and prints their lengths
- The details.py program gets system details like name and IP address
- The password_gen.py program generates a random 10 character password
This document introduces Python for network engineers, covering an overview of Python, what tasks it can perform like network automation, how to run Python interactively and with files, differences between Python and shell scripting, Python data types, modules, and includes an example Python program to login to a switch and retrieve interface configuration using Telnet.
This document discusses metaprogramming in Julia. It describes how Julia code is processed at compile time, including lexical analysis, syntax analysis, semantic analysis, intermediate code generation, optimization, and code generation. It also discusses how macros allow generating new Julia code at compile time and can be used to implement syntactic abstractions like decorators. Finally, it mentions how generated functions allow specializing method implementations based on types of arguments passed at runtime.
This document presents an overview of file operations and data parsing in Python. It covers opening, reading, writing, and closing files, as well as using regular expressions to parse text data through functions like re.search(), re.findall(), re.split(), and re.sub(). Examples are provided for reading and writing files, manipulating file pointers, saving complex data with pickle, and using regular expressions to match patterns and extract or replace substrings in texts. The document aims to introduce Python tools for working with files and parsing textual data.
Python is a high-level, interpreted programming language that is designed to be easy to read and write. It has a clear syntax using English keywords and its code is often shorter than languages like C++ and Java. Python is widely used for web development, software development, science, and machine learning. It has a large standard library and can be extended through modules. Some key data structures in Python include lists, tuples, and dictionaries.
PyCon 2013 : Scripting to PyPi to GitHub and MoreMatt Harrison
This document discusses various aspects of developing and distributing Python projects, including versioning, configuration, logging, file input, shell invocation, environment layout, project layout, documentation, automation with Makefiles, packaging, testing, GitHub, Travis CI, and PyPI. It recommends using semantic versioning, the logging module, parsing files with the file object interface, invoking shell commands with subprocess, using virtualenv for sandboxed environments, Sphinx for documentation, Makefiles to automate tasks, setuptools for packaging, and GitHub, Travis CI and PyPI for distribution.
This document provides an overview of Python for Unix and Linux System Administration by Noah Gift and Jeremy M. Jones. It includes information about related O'Reilly titles, conferences, and online resources from O'Reilly such as oreilly.com and oreillynet.com. It also discusses the Safari Bookshelf online reference library and upcoming O'Reilly conferences.
Follow me on Twitter at http://www.twitter.com/cballou or checkout my startup at http://www.pop.co.
In this presentation we will cover the best features and additions in PHP 5.5. You can look forward to the following:
* Support for generators has been added via the yield keyword
* Usage of the new finally keyword in try-catch blocks
* An overview and examples of the new password hashing API
* The foreach control structure now supports unpacking nested arrays into separate variables via the list() construct
* empty() supports arbitrary expressions such as closures returning false
* array and string literal dereferencing
* The Zend Optimiser+ opcode cache (via the new OPcache extension)
The document discusses file input and output in Python. It covers opening files, reading the entire file or line by line, writing to files, and closing files. It also covers if/elif/else conditional statements, comparison operators, and examples of problems and solutions involving file I/O and conditional logic.
This document provides an overview of the Python programming language. It discusses why Python was created, its key features like being an interpreted, dynamically typed language with indentation that counts. It also lists Python's core keywords and datatypes like numbers, strings, lists, dictionaries, tuples, files and other types. Finally, it outlines some of Python's basic operators like arithmetic, relational, bitwise, assignment and logical operators.
This document provides an overview of functions and file handling in Python. It discusses defining user-defined functions with the def keyword, including passing arguments, default arguments, keyword arguments, and variable number of arguments. It also covers recursion, anonymous functions, and attributes of file objects. For file handling, it explains opening, reading, writing, and appending files, as well as the different file modes.
This document provides an introduction to programming in C and using Unix commands. It discusses functions for input/output like printf, scanf, fopen, fclose, fscanf, and fprintf. Pipes are realized as file descriptors that link output to input. The sendmail command allows transmission of email from C programs by writing to a pipe opened with popen. Overall it covers basic I/O operations in C and how to interface with Unix commands like sendmail.
Getting started in Python presentation by Laban KGDSCKYAMBOGO
Python Overview and getting started in Python Language. It includes on how to install, run it and carrying out some simple python codes in different environments(IDLEs)
This document discusses file handling functions in C including fopen(), fclose(), getc(), putc(), fscanf(), fprintf(), getw(), putw(), fseek(), ftell(), and rewind() for reading, writing, and manipulating data in files. It also covers file opening modes in C such as r, w, a, r+, w+, a+, rb, wb, ab, rb+, wb+, and ab+ for reading, writing, and updating text and binary files.
Turning Your Iterators Up to 11: New Features for Complex Iterator Implementa...Accumulo Summit
1) The document discusses new features for complex iterator implementations in Apache Accumulo, including stateful iterators, deep copying iterators, multi-threading iterators, and implementing the YieldingKeyValue interface for long running scans.
2) It provides examples of using iterators for pre-fetching data and implementing processing pipelines.
3) The document also covers best practices for debugging, testing, and monitoring iterators using metrics.
A file is a collection of related data that a computer treats as a single unit. Files allow data to be stored permanently even when the computer is shut down. C uses the FILE structure to store attributes of a file. Files allow for flexible data storage and retrieval of large data volumes like experimental results. Key file operations in C include opening, reading, writing, and closing files. Functions like fopen(), fread(), fwrite(), fclose() perform these operations.
This document provides an overview of how to use the UNIX operating system. It discusses logging in, the home directory, common commands like ls and cd, copying and deleting files, pipes, input/output redirection, shell variables, job control, and quoting special characters. The document is intended to help new UNIX users get started with basic file management and command line tasks.
Outlines of this lecture:
- What is stream?
- File Output Stream Class
- File Input Stream Class
- Byte Array Output Stream Class
- Sequence Input Stream Class
- File Reader Class
- File Writer Class
- Scanner with String
DEFINICION DE MEMBRANA PLASMATICA O CELULAR - FUNCIONES - ENDOCITOSIS - EXOCITOSIS - CARACTERISTICAS DE LA MEMBRANA PLASMATICA - DIFICION DE POTENCIAL DE ACCION - GRAFICAS DE POTENCIAL DE ACCION
Jonathan Phillips is seeking a position as a GIS/remote sensing analyst utilizing his experience in map development, design, and imagery analysis. He has worked as a research assistant at the University of Toledo where he mentored students, conducted surveys, digitized and mapped data, and collaborated on projects. Phillips has a Bachelor's degree in Adolescent Young Adult Social Studies and is completing his Master's degree in Geography and Planning at the University of Toledo with a focus in GIS and remote sensing. He has skills in various GIS and remote sensing software as well as statistical and modeling programs.
Conocer mediante un instrumento basado en una metodología científica y técnicas estadísticas que garanticen un alto nivel de validez, confianza y calidad de la información, los niveles salariales y sus componentes, así como otros datos relevantes para los propósitos de la organización.
¿Deseas más información o capacitación sobre este tema? Contáctanos:
Mail: [email protected]
LinkedIn: linkedin.com/company/1389187
FB: facebook.com/DIRHMx/
Twitter: twitter.com/DIRHMx
There are three key signs that regulators and operators should pay attention to regarding safety culture:
1. Detecting procedural inadequacies, such as documentation not being reviewed or revised on schedule, which indicates weaknesses in management.
2. Analyzing patterns of recurring problems to identify root causes that were not adequately addressed by corrective actions.
3. Monitoring for signs of organizational insularity where different facilities do not communicate and learn from each other.
Female faculty members awareness about retirement planning avenuesDr. Gargi Pant Shukla
Retirement planning is an integral part of financial planning for any individual. Every individual looks forward to spending the post retirement years in the lap of luxury. A person needs to take challenging investment decisions in order to optimally plan for retirement. These decisions as per finance theories have been motivated by reasoning while unfortunately the intuition aspect has been portrayed in a negative manner by behavioural finance advocates. The research is an attempt to study the awareness of female faculty member towards retirement planning avenue. In this paper we had analyzed the attitude & awareness of female faculty members about retirement planning avenues. Only 10% of the population in India goes for the retirement planning or some social security. In this paper we are more focused towards retirement planning, retirement planning avenues and the awareness of female faculty members towards these avenues.
Shaun Watkiss describes liking 10 images from their final gallery for various reasons. The images include portraits, angles hiding faces, vibrant colors inside an umbrella, yellow vibrancy against black, a guitarist looking out as train tracks recede, well-lit portraits, innovative lighting and positioning, their first light painting photos, and well-positioned lighting for a music magazine photoshoot.
This document consists of a biology exam for the Cambridge International General Certificate of Secondary Education. The exam contains 7 sections with a total of 21 questions testing knowledge of topics including protein digestion, lactose intolerance, DNA structure and protein synthesis, classification of organisms, the kidney and excretion, plant adaptations, blood cells, HIV infection, and wetland ecosystems. Students are required to answer all questions, which include filling in tables, labeling diagrams, short answers, and longer explanations.
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
Python
Language
is uesd in engineeringStory adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they s
This document provides an overview of the basics of the Python programming language. It discusses Python's history and features, data types like numbers, strings, lists, tuples and dictionaries. It also covers Python concepts like variables, operators, control flow statements and functions. Specific topics covered include Python interpreters, comments, variables and scopes, data structures, conditional statements like if/else, and exceptions handling.
This document provides an introduction to the Python programming language. It discusses why Python is easy to learn, relatively fast, object-oriented, strongly typed, widely used and portable. It then provides instructions on getting started with Python on Mac, including how to start the Python interpreter and run a simple "Hello World" program. It also demonstrates using the Python interpreter interactively to test code. The document explains the basic Python object types of numbers, strings, lists, tuples, dictionaries and files. It introduces the concepts of literals, variables and the import command. It provides examples of using command line arguments in Python programs.
Python is an easy to learn, object-oriented programming language that is widely used for scientific computing. It allows interactive testing of code through its interpreter interface. A user's first Python program prints "hello, world!" by saving a line of text with the .py extension and running it with the Python interpreter. Python defines six basic object types - numbers, strings, lists, tuples, dictionaries, and files. Variables store references to objects, and objects can be written directly as literals or accessed via variables. Important Python packages must be imported before their functions can be used. Command line arguments provide a way to input information into programs.
The document introduces Python as a simple, beautiful, and easy to learn programming language. It is open source and can be used for tasks like text handling, system administration, GUI programming, web applications, databases, scientific applications, games, and natural language processing. Python has a simple syntax without semicolons and uses indentation for code blocks. It supports object oriented programming, functions, modules, exceptions, and many data types including lists, tuples, dictionaries, strings and files. The document provides examples of basic Python concepts and how to use built-in modules, create your own modules, handle files, integrate with databases, and build graphical user interfaces.
- The document discusses Python programming concepts such as data types, variables, operators, and syntax. It provides examples of Python code for variables, comments, strings, numbers, and more.
- Python is a popular programming language used for web development, software development, mathematics, and more. It runs on different platforms and has a simple, readable syntax.
- Key features of Python include dynamic typing, automatic memory management, and an intuitive syntax that uses indentation rather than brackets.
This document provides an introduction to the Python programming language. It discusses what Python is, its history and creator, why it is popular, who uses it, and how to get started with the syntax. Key topics covered include Python's readability, dynamic typing, standard library, and use across many industries. The document also includes code examples demonstrating basic Python concepts like variables, strings, control flow, functions, and file input/output.
Presentation on using the Arrow library for enhanced Functional Programming in the Kotlin Language. Delivered at the Northern Ireland Developer Conference 2018.
The basics of Python are rather straightforward. In a few minutes you can learn most of the syntax. There are some gotchas along the way that might appear tricky. This talk is meant to bring programmers up to speed with Python. They should be able to read and write Python.
This document provides an introduction to basic Python concepts including data types, control flow statements, and graphing with matplotlib. It includes examples of working with numbers, strings, lists, dictionaries, conditionals, loops, functions, histograms, and pie charts. The document demonstrates how to get started with Python interactive shells, perform basic math operations and string manipulations, use built-in data types, write functions, and create plots and charts.
This document provides an introduction to the Python programming language over 30 minutes. It covers basic Python concepts like variables, data types, conditionals, loops, functions, imports, strings, lists, tuples, sets, dictionaries, and classes. Code examples are provided to demonstrate how to use these features. The document encourages learners to continue learning Python through online documentation and resources.
This document provides an introduction to the Python programming language over 30 slides. It covers key Python concepts like variables, data types, conditionals, loops, functions, imports, strings, lists, tuples, sets, dictionaries, classes and input/output. Examples are given for each concept to demonstrate how it works in Python. The document concludes by encouraging the reader to continue learning Python through online documentation and resources.
Gurukul Skills Schedule for the Month of March
Time Cohort-10 Cohort-11 Cohort-12
8.00 to 09.25 Revision Revision Revision
5 Minutes Short Break
9.30 to 11.30 Chartered Accountants Chartered Accountants ENGLISH/SOFT SKILLS
15 Minutes Short Break
11.45 to 01.45 ICT ENGLISH/SOFT SKILLS R&A
45 Minutues Lunch Break
2.30 to 04.30 ENGLISH/SOFT SKILLS R&A ICT
15 Minutes Short Break
4.45 to 06.30 R&A ICT ACCOUNTS
5 Minutes Short Break
6.35 to 08.00 Assingments Assingments Assingments
The document discusses several key points about Python:
1. It summarizes praise for Python from programmers and companies like Google, NASA, and CCP Games, highlighting Python's simplicity, compactness, and ability to quickly develop applications.
2. It introduces common Python concepts like strings, lists, sequences, namespaces, polymorphism, and duck typing. Strings can be manipulated using slicing and methods. Lists and other sequences support indexing, slicing, and iteration.
3. Python uses name-based rather than type-based polymorphism through duck typing - an object's capabilities are defined by its methods and properties rather than its class.
Biopython is a set of freely available Python tools for bioinformatics and molecular biology. It provides features like parsing bioinformatics files into Python structures, a sequence class to store sequences and features, and interfaces to popular bioinformatics programs. Biopython can be used to address common bioinformatics problems like sequence manipulation, searching for primers, and running BLAST searches. The current version is 1.53 from December 2009 and future plans include updating the multiple sequence alignment object and adding a Bio.Phylo module.
This presentation about Python Interview Questions will help you crack your next Python interview with ease. The video includes interview questions on Numbers, lists, tuples, arrays, functions, regular expressions, strings, and files. We also look into concepts such as multithreading, deep copy, and shallow copy, pickling and unpickling. This video also covers Python libraries such as matplotlib, pandas, numpy,scikit and the programming paradigms followed by Python. It also covers Python library interview questions, libraries such as matplotlib, pandas, numpy and scikit. This video is ideal for both beginners as well as experienced professionals who are appearing for Python programming job interviews. Learn what are the most important Python interview questions and answers and know what will set you apart in the interview process.
Simplilearn’s Python Training Course is an all-inclusive program that will introduce you to the Python development language and expose you to the essentials of object-oriented programming, web development with Django and game development. Python has surpassed Java as the top language used to introduce U.S. students to programming and computer science. This course will give you hands-on development experience and prepare you for a career as a professional Python programmer.
What is this course about?
The All-in-One Python course enables you to become a professional Python programmer. Any aspiring programmer can learn Python from the basics and go on to master web development & game development in Python. Gain hands on experience creating a flappy bird game clone & website functionalities in Python.
What are the course objectives?
By the end of this online Python training course, you will be able to:
1. Internalize the concepts & constructs of Python
2. Learn to create your own Python programs
3. Master Python Django & advanced web development in Python
4. Master PyGame & game development in Python
5. Create a flappy bird game clone
The Python training course is recommended for:
1. Any aspiring programmer can take up this bundle to master Python
2. Any aspiring web developer or game developer can take up this bundle to meet their training needs
Learn more at https://www.simplilearn.com/mobile-and-software-development/python-development-training
Daniel Greenfeld gave a presentation titled "Intro to Python". The presentation introduced Python and covered 21 cool things that can be done with Python, including running Python anywhere, learning Python quickly, introspecting Python objects, working with strings, lists, generators, sets and dictionaries. The presentation emphasized Python's simplicity, readability, extensibility and how it can be used for a wide variety of tasks.
Distributed defense against disinformation: disinformation risk management an...Sara-Jayne Terp
This document discusses distributed defense against disinformation through cognitive security operations centers (CogSecCollab). It proposes a multi-pronged approach involving platforms, law enforcement, government, and other actors to address the complex problem of online disinformation. Key aspects include establishing disinformation security operations centers to conduct threat intelligence, incident response, risk mitigation, and enablement activities like training, tools, and processes. The centers would use frameworks to model disinformation campaigns and share indicators across heterogeneous teams in a collaborative manner. Simulations, red teaming, and other techniques are recommended to test defenses and learn from examples.
Risk, SOCs, and mitigations: cognitive security is coming of ageSara-Jayne Terp
This document discusses cognitive security and disinformation risk assessments. It outlines three layers of security - physical, cyber, and cognitive. It describes various disinformation strategies and risks, including different types of misleading information like disinformation, misinformation, and malinformation. It then discusses approaches for assessing and managing disinformation risks, including analyzing the information, threat, and response landscapes in a country. It provides frameworks for classifying disinformation incidents and objects. Finally, it discusses how to set up a cognitive security operations center (CogSOC) to conduct near real-time monitoring, analysis, and response to disinformation threats.
disinformation risk management: leveraging cyber security best practices to s...Sara-Jayne Terp
This document discusses leveraging cybersecurity best practices to support cognitive security goals related to disinformation and misinformation. It outlines three layers of security - physical, cyber, and cognitive security. It then provides examples of cognitive security risk assessment and mapping the risk landscape. Next, it discusses working together to mitigate and respond to risks through proposed cognitive security operations centers. Finally, it provides a hypothetical example of conducting a country-level risk assessment and designing a response strategy. The document advocates adapting frameworks and standards from cybersecurity to help conceptualize and coordinate cognitive security challenges and responses.
This document discusses cognitive security, which involves defending against attempts to intentionally or unintentionally manipulate cognition and sensemaking at scale. It covers various topics related to cognitive security including actors, channels, influencers, groups, messaging, and tools used in disinformation campaigns. Frameworks are presented for analyzing disinformation incidents, adapting concepts from information security like the cyber kill chain. Response strategies are discussed, drawing from fields like information operations, crisis management, and risk management. The need for a common language and ongoing monitoring and evaluation is emphasized.
2021 IWC presentation: Risk, SOCs and Mitigations: Cognitive Security is Comi...Sara-Jayne Terp
This document discusses cognitive security and disinformation risk assessments. It outlines three layers of security - physical, cyber, and cognitive. It describes various disinformation strategies and risks, including different types of misleading information like disinformation, misinformation, and malinformation. It then discusses approaches for assessing and managing disinformation risks, including analyzing the information, threat, and response landscapes in a country. It provides frameworks for classifying disinformation incidents and objects. Finally, it discusses how to set up a cognitive security operations center (CogSOC) to conduct near real-time monitoring, analysis, and response to disinformation threats.
This document discusses distributed defense against disinformation through cognitive security operations centers (CogSecCollab). It proposes a multi-pronged approach involving platforms, law enforcement, government, and other actors to address the complex problem of online disinformation. Key aspects include establishing disinformation security operations centers to conduct threat intelligence, incident response, risk mitigation, and enablement activities. The centers would use frameworks like AMITT to analyze disinformation techniques, track narratives and artifacts, and share intelligence. A variety of tactics are outlined, including detecting, denying, disrupting, and deceiving disinformation actors, as well as developing counter-narratives. Machine learning and automation could help with tasks like graph analysis, text analysis, and
1) The document discusses frameworks for understanding and responding to disinformation, including the AMITT and ATT&CK frameworks.
2) It describes various types of actors involved in spreading disinformation and proposes establishing Disinformation Security Operations Centers to facilitate collaboration between response efforts.
3) The goals of a CogSec SOC are outlined as informing about ongoing incidents, neutralizing disinformation, preventing future incidents, supporting organizations, and acting as a clearinghouse for incident data.
This document discusses lessons learned from the CTI League's Disinformation Team in responding to disinformation incidents related to COVID-19. It outlines key aspects of disinformation response including identifying common COVID-19 narratives, understanding motivations like money and geopolitics, and evolving tactics used by disinformation actors. It also describes the incident response process involving triaging incidents, conducting analysis to understand the situation, and considering options for countermeasures. Collaboration is emphasized as critical to effectively countering this complex, global problem.
1. The document outlines plans for an Information Sharing and Analysis Organization (ISAO) focused on countering misinformation.
2. It proposes building a global infrastructure and connecting public and private stakeholders to facilitate information sharing and developing collaborative capabilities to define, disseminate and apply best practices for cognitive security.
3. The ISAO would identify risks, protect information systems, detect threats and incidents, respond with countermeasures, and help recovery through lessons learned - extending the MITRE ATT&CK framework to analyze misinformation campaigns and techniques.
This document summarizes a presentation about social engineering at scale on the internet. The presentation discusses how social media platforms like Facebook have been used by groups to spread misinformation and manipulate public opinion at a massive scale through inauthentic accounts and posts. It also examines common human vulnerabilities that are exploited, such as biases and emotions. The presentation then outlines some responses from different groups to address this issue, including tech companies, journalists, and politicians. It concludes by suggesting ways to better design systems to reduce manipulation and abuse while coexisting with social bots.
The document discusses social engineering at scale on social media platforms like Facebook, the vulnerabilities it exploits in human cognition, and various responses to the spread of misinformation and disinformation online. It notes how certain Facebook groups have achieved massive shares and interactions while spreading untruths, and outlines cognitive biases and effects that make misinformation spread widely. Responses discussed include fact-checking organizations, changes by tech companies and social networks, and efforts by journalists, politicians, and hackers. It suggests this issue significantly changes the nature of the internet and human interactions online.
This document discusses belief hacking and how beliefs can be influenced through the use of algorithms, data analytics, and artificial intelligence on social networks. It describes how beliefs can be modeled and adjusted by optimizing for what people want to believe, using propaganda techniques to undermine opposing views, and leveraging social contagion to spread ideas. The document warns that while misinformation can be disruptive, understanding the systems already in place to influence beliefs is needed before attempting to counter or limit their effects.
This document discusses risks and mitigations when releasing data. It defines risk as the probability of something happening multiplied by the resulting cost or benefit. There are risks of physical harm, legal harm, reputational harm, and privacy breaches to data subjects, collectors, processors, and those releasing the data. Risk levels can be low, medium, or high. The document provides strategies for mitigating risks such as considering partial data releases, including locals to assess risks in local languages/contexts, and being aware of how data may interact with other datasets. It emphasizes the responsibility to do no harm when releasing datasets.
computer organization and assembly language : its about types of programming language along with variable and array description..https://www.nfciet.edu.pk/
AI Competitor Analysis: How to Monitor and Outperform Your CompetitorsContify
AI competitor analysis helps businesses watch and understand what their competitors are doing. Using smart competitor intelligence tools, you can track their moves, learn from their strategies, and find ways to do better. Stay smart, act fast, and grow your business with the power of AI insights.
For more information please visit here https://www.contify.com/
By James Francis, CEO of Paradigm Asset Management
In the landscape of urban safety innovation, Mt. Vernon is emerging as a compelling case study for neighboring Westchester County cities. The municipality’s recently launched Public Safety Camera Program not only represents a significant advancement in community protection but also offers valuable insights for New Rochelle and White Plains as they consider their own safety infrastructure enhancements.
This comprehensive Data Science course is designed to equip learners with the essential skills and knowledge required to analyze, interpret, and visualize complex data. Covering both theoretical concepts and practical applications, the course introduces tools and techniques used in the data science field, such as Python programming, data wrangling, statistical analysis, machine learning, and data visualization.
Mieke Jans is a Manager at Deloitte Analytics Belgium. She learned about process mining from her PhD supervisor while she was collaborating with a large SAP-using company for her dissertation.
Mieke extended her research topic to investigate the data availability of process mining data in SAP and the new analysis possibilities that emerge from it. It took her 8-9 months to find the right data and prepare it for her process mining analysis. She needed insights from both process owners and IT experts. For example, one person knew exactly how the procurement process took place at the front end of SAP, and another person helped her with the structure of the SAP-tables. She then combined the knowledge of these different persons.
How iCode cybertech Helped Me Recover My Lost Fundsireneschmid345
I was devastated when I realized that I had fallen victim to an online fraud, losing a significant amount of money in the process. After countless hours of searching for a solution, I came across iCode cybertech. From the moment I reached out to their team, I felt a sense of hope that I can recommend iCode Cybertech enough for anyone who has faced similar challenges. Their commitment to helping clients and their exceptional service truly set them apart. Thank you, iCode cybertech, for turning my situation around!
[email protected]
8. Python in the Terminal Window
3 ways to run the python interpreter from the
terminal window:
• type ‘python’
• type ‘ipython’
• type ‘python helloworld.py’
16. First, Bugz!
Beware the quote characters! If you cut and paste code from text files (like
these slides), you might see one of these error messages:
“SyntaxError: Non-ASCII character 'xe2' in file helloworld.py on line 1”
"SyntaxError: invalid character in identifier"
This happens because the symbols “ and ” above aren’t the same as the ones
in your code editor. It’s annoying, but easily fixed: just delete them and type “
and ” in the right places in the editor.
17. Comments
# This is a comment
print('Hello World!') # this is a comment too
26. Dictionaries
iso3166 = {'SLE': 'Sierra Leone', 'NGA': 'Nigeria', 'LBR': 'Liberia' }
iso3166['LBR']
iso3166.keys()
'NGA' in iso3166
'USA' in iso3166
27. Dictionary Iterators
iso3166 = {'SLE': 'Sierra Leone', 'NGA': 'Nigeria', 'LBR': 'Liberia' }
for key, val in iso3166.items():
print('The key is: {}'.format(key))
print('The value for this key is: {}'.format(val))
29. Getting input from the user
user_text = input('Give me some text> ')
lower_text = user_text.lower()
text_length = len(user_text)
print('Your text is {}, its length is {}'.format(user_text, text_length))
30. Libraries
• Pieces of code that do something you need
–e.g. the CSV library helps you read and write CSVs
• To include a library, use this in your code:
import libraryname
31. Getting input from a CSV file
import csv
fin = open('example_data/ebola-data-db-format.csv', 'r')
csvin = csv.reader(fin)
headers = next(csvin)
for row in csvin:
print(‘{}’.format(row))
fin.close()
32. Conditionals
import csv
fin = open('example_data/ebola-data-db-format.csv', 'r')
csvin = csv.reader(fin)
for row in csvin:
if row[1] == 'Liberia':
print('Found a {} datapoint about Liberia!'.format(row[2]))
fin.close()
33. More Help with Python
http://learnpythonthehardway.org/book/
Lots of other suggestions in the “course reading list” file
(google folder “Reference”)
35. iPython Notebook
In the terminal window:
• ‘cd’ to the directory containing the code
example files (.ipynb files)
• Type “ipython notebook”
• Run each code cell in the example files
36. (optional) Reading CSVs
If you already know Python and iPython:
Find a variety of CSV files; try reading each of them into python, and see if you
get any errors or strange behaviours. Bonus points if you find CSV files
containing accents or multiple languages.
Editor's Notes
#2: Today we’re looking at a programming language that’s used a lot by data scientists (and that many of the code examples will be written in). Some of the example code in the rest of these sessions will be in Python, so it will help for you to be able to read and understand what’s happening in that code.
#3: So let’s begin. Here are the 6 things we’ll talk about today.
#4: Before we talk about python, it helps to define it a bit.
#5: See http://learnpythonthehardway.org/book/ and https://www.python.org/ for way more about Python.
#6: We’ll cover the basics of Python in this session. The aim is to a) get you some useful tools, and b) not have you scared by something that looks like this.
The toolset for this course (Python, R, offline tools) was chosen so you can still do something useful when you have no internet / have low bandwidth. There are many other tools out there if you have the bandwidth to run then, but at some point in your career you’ll find yourself somewhere like Arusha in Tanzania, desperately hoping that the page you need will load. We’ve based this toolkit on trying to minimise that experience. Plus it’s cool being able to do things for yourself!
#7: That was your first python code. You opened up the ipython interpreter, then typed in ‘commands’ (‘1+2’) and got back outputs (‘3’). Then, because we’re tidy, you closed the python interpreter again.
We met several important things here. You met objects: “1” and “2.5” are numbers (“1” is an integer number; “2.5” is a floating point number); and “‘hello world!’” is a string.
You also met an operator: “+” and a function: print().
* Operators do basic things to pairs of objects (or sometimes to single objects). For instance, “+” adds together the objects to the left and right of it. You’ll meet arthmetic operators (+ add, - subtract, * multiply, / divide) and logical operators (of which more soon).
* Functions are pieces of pre-written code that (usually) do something that needs to be done often, like sending a friendly message.
#8: So you have some Python code - maybe written in these slides, maybe in a .py or .ipynb file. Let’s look at some of the ways you can run that code.
#9: ‘python’ runs the python interpreter. ‘ipython’ runs a version of the python interpeter that’s slightly friendlier to new users, e.g. it has better help.
‘python helloworld.py’ runs the python interpreter on a file called ‘helloworld.py’. If that file contains a set of python commands (e.g. “print(“Hello World!”)”), you’ll see the output of those commands. You can do the same thing with ipython, e.g. ‘ipython helloworld.py’.
There’s a file called helloworld.py in your course notes. Try running it, then editing it (any text editor will do, although some, like Sublimetext, are set up to point out any coding errors to you), and running it again.
There are other ways to run Python code (e.g. from another program), but we won’t be doing that in this course.
#10: Ipython notebooks are files that contain both formatted text and code; depending on how you set up your notebooks, they can run code written in Python, R or several other languages.
#11: All the code examples (both Python and R) for this course are in iPython notebooks, so you’ll need to know how to open one.
cd (“change directory”) is the terminal window command to change directory.
“cd ~” takes you to your ‘top’ directory, where typing “ls” (mac) or “dir” (windows) will show you directories like Desktop, Downloads or Documents.
“cd dir1/dir2/dir3” takes you ‘down’ directories, to dir3 which is below dir2 which is below dir1. This is the terminal equivalent of starting in one directory, then clicking on dir1, dir2 then dir3.
“cd ..” takes you ‘up’ directories: for instance, “cd ..” in dir3 will take you to dir2.
“pwd” (mac) or “dir” (windows) will show you which directory you are in at the moment. If you get lost, “cd ~”.
#12: iPython starts with the Dashboard view. This lists all the files in the directory that you called iPython from, including directories. If you accidentally delete this view, open a web browser and type “localhost:8888” in the address window to get back to it.
Things you need to know about in here:
The “New” button on the top right hand side. Click on this, then “Python 3”, to create a new iPython notebook file.
The file listing. Click on any file or directory to open it.
The current directory (the grey bar above the files list): click on this to go back up from a directory.
#13: And this is what you see when you open an iPython file.
The grey boxes are called ‘cells’.
You create a new cell by clicking ‘Insert’ on the top menu.
You change the cell type (to ‘Markdown’, or ‘Code’) by clicking the box that currently says ‘Code’
You run a cell by clicking in the cell, then clicking ‘cell’ -> ‘run cells’.
You change your file’s name by clicking the name to the right of jupyter
You save your shiny new file by clicking ‘File’ -> ‘Save and Checkpoint’.
#15: Don’t panic if your notebook looks like this when you open it. iPython has helpfully converted your markup cells into the way you’d see them if you printed the notebook. To edit any of these cells, click in the cell (you should then see the markdown code, ready to edit).
#16: Variables are one of the basic building blocks of Python code. We’ll look at some of these - what they look like, what they can do.
#17: But before we start, let’s talk about bugs. Bugs are errors that either stop your code from running, or make it run in ways that you weren’t expecting.
You will meet many bugs when you’re coding. Don’t let them scare you: dealing with bugs is just one of the features of coding. You can do things to make this easier: for instance, if you use an editor like sublimetext to write your code, it has handy features like changing the colour of your code when you write something incorrectly. do this…
#18: Coders leave messages for each other (and themselves) in their code: these are called comments. They’re there for humans to read, and are completely ignored by the python interpreter.
The comments you’ll see in this course are mostly the ones that start with the ‘#’ symbol. Everything from the ‘#’ to the end of the line it’s on is a comment.
You *might* see magic comments in python files, e.g.
#!/usr/bin/python
# -*- coding: utf-8 -*-
These tell the interpreter which type of file this is (python), and which character set it uses (remember the problem with ‘“‘ earlier?). utf-8 is a very commonly-used character set.
#19: Variables are places where you put objects that you don’t want to keep typing out. You do this because
you don’t have to keep typing “Hello World” when you use it several times in your code
it’s easier to read your code and see what’s going on
it’s harder to make mistakes (e.g. if you put “10” everywhere in your code, and change your mind, then you might change some but not all of those “10”s to “11s”… if you put x=10 and then use x everywhere, you only have to change one thing).
Variables have “types” that tell the interpreter what can be done with them (e.g. you can multiply numbers together, but you can’t do that with strings). Here are some common variable types:
String: a set of characters, which could be letters, numbers or symbols. Strings can be as long as you like - in some datasets (e.g. reading in book texts) you’ll see strings thousands of characters long.
Boolean: can be either True or False. Useful for when you want to do one thing if something is true (e.g. x == 10), and something else if it isn’t.
Numbers: a number. This include integers (e.g. 10), and floating-point number (e.g. 15.523).
Note how I reused the same variable name for two numbers. Try typing my_number = 10, then print(my_number), then my_number=15.523, then print(my_number) in ipython.
#20: Strings are a bit special. A string is made out of characters (e.g. “H” or “r”), so it makes sense to ask things like:
len(string): how many characters are there in this string?
my_string[4]: what’s the 5th character in this string? (NB python counts from 0, not 1, e.g. my_string[0] is H).
#21: Remember, functions are pieces of code that (often) do something that gets repeated lots. We already met the function “print()”. Here are some more functions.
Functions generally have 3 parts: the function name (e.g. “len”), the function arguments (e.g. “my_string”) that tell the function what to do its thing on, and the the function return (e.g. stringlength), which is the variable (or variables) that the function puts its results into.
You can use ‘string formatting’ to put other variables (numbers, other strings etc) into a string. Here, we’ve put a number (15.2) and a string (“Hello World!”) into a new string, and printed it. print(“{}”.format(x)) is very very useful for printing out more-complicated variables, where a simple print(x) will fail.
#22: You can write your own functions using the keyword “def”. Here, we’ve created a function (my_function) that takes an argument called my_text, adds some more text to it, puts that new text into variable new_text, and returns new_text to the person who called the function.
Then we use the function. We call my_function with the argument “sara likes “: my_text is now set to “sara likes “ before we add “bananas” to it. The function returns “sara likes bananas”, which is put into the variable new_sentence.
#23: A collection is a group of python objects. We’re going to look at two collections here: lists, and dictionaries.
#24: A list is an ordered set of python objects. Here, rowvals is a list that contains numbers.
Lists are ordered, e.g. rowvals[3] will always give you the 4th object in rowvals (currently “6”). This might seem wrong to you - you may be asking why it doesn’t give you the 3rd object in the list. The reason is that all counting in Python starts at zero, so the “indices” for the objects in this list are 0,1,2,3,4,5,6,7 and 8.
You can’t use an index larger than the last index in the list: typing rowvals[9] will give you an error message. But you will sometimes see negative indices.
rowvals[3] and max(rowvals) will both return an object to you, that you can ‘assign’ to a new variable.
#25: Some functions will change the object they’re applied to. list.sort() is one of these.
rowvals.sort() changes the contents of rowvals itself. Try running this code to see how this happens.
#26: So sometimes you want to do something to every item in a list. Repeating the same command for alist[0], alist[1], alist[2] and alist[3] would be tiresome (and even more tiresome if you have 1000 items in your list), so we use iterators.
An iterator (e.g. “for”) selects each item in a list in turn, and applies your code to it. For instance, in the code above, the line “for item in alist” selects each object in alist, calls that object “item” then runs the code “print(item)” on it.
Note the 4 spaces before print(item). This is how Python groups code together: the spaces tell the Python interpreter that print(item) and print(item+2) are run on the items from alist, but “print(I’m done now)” isn’t. This can be very annoying at first, but makes sense after a while.
The enumerate function can be very useful when you’re iterating over lists. This allows you to use both the index of an item, and the item in your loops. An example of this is:
for index, item in enumerate(alist):
print(“the list item at index {} is {}”.format(index, item))
#27: A python list is a collection that’s indexed by numbers (0,1,2,etc). A python dictionary is a container that’s indexed by anything you want to use. In this example, we’ve used ISO3166 country codes as indices, and the names of countries as the items in the list.
Dictionaries are unordered, so iso3166[0] doesn’t make sense. But because we’ve created the indices SLE, NGA, LBR, we can use any of these to access the item connected with that index, e.g. iso3166[‘NGA’]. If we want to see all the indices (aka “keys”) in a dictionary, we use the “keys” function, e.g. iso3166.keys().
If we want to know if a key is in a dictionary, we can ask, for example using “‘NGA’ in iso3166”
#28: We can also iterate over dictionary keys, as seen here. Don’t forget those 4 spaces!
Speaking of spaces… you’ll notice that I’ve added spaces here and there to make the code more readable. You can do this in most places, but there are code format rules (“style guides”) that Python coders follow so they don’t confuse each other - most Python coders use PEP8 https://www.python.org/dev/peps/pep-0008/ - which, amongst other things, tells coders to use 4 (not 1,2,3,5 or anything else) spaces as indents.
Some text editors, like Sublime Text (https://www.sublimetext.com), have ways to switch on these rules so the text editor colour-highlights any time you’re breaking a rule.
#29: At some point, we’re going to need to pull data into our code: this might be input from the code’s user, or from a datafile, or from an API (application programming interface: more on that soon). Here’s how.
#30: You might want to ask the user for input (e.g. the name of the csv file they want your code to process). The function “input()” does this.
#31: First, a brief note about libraries. Places to look for libraries include:
* https://docs.python.org/3/library/ (you already have these)
* https://pypi.python.org/pypi
#32: Here, we’re using the Python library “CSV” to read in the contents of a CSV file.
First, we need to tell our code to use the CSV library (“import CSV”)
Then we tell it which file to open (“open()”), and that we’re reading from (not writing to) a file (“‘r’”).
We’ve opened the file for input, but that’s not enough if we want to treat this file as a CSV file (instead of a text file, or Excel, json, xml etc). To do this, we create a CSV reader object, using “csv.reader()”. This object (that we’ve called “csvin”) knows about commands like “next()” (get me the next row of data from the csv, and put it into a list object), and that “for row in csvin” will loop over each remaining row in the CSV file, and input it as a list.
The rest is grabbing each row in the CSV file, and printing out that row. When you’re done, fin.close() closes the link between this program and the file pointed at by the variable ‘fin’.
Later in the course, you'll see other, shorter, ways to read in a CSV file (dictreader, and pandas.read_csv), but this is development data, and the CSV library can often read in difficult CSV files that other methods fail on.
#33: Sometimes we’ll want to process only some of the data that we see. In this case, we’re only interested in data about Liberia, so we test to see if the second entry in the row is ‘Liberia’. This test (if a == b) is called a conditional statement, because running the rows nested below the “if” statement (“nested” = using another 4 spaces, to show that the “print()” statement belongs to the “if” one) is conditional on whether the statement “row[1] == ‘Liberia’” is true.
The conditions you’ll see in code include:
a == b: a’s value is the same as b’s value
a != b: a’s value is not the same as b’s value
a < b: a is smaller than b
a > b: a is bigger than b
a<= b: a is smaller than or equal to b
a >= b: a is bigger than or equal to b
Beware the “==” in a conditional statement. “==” is used to test similarity; “=” is used to set the value of the thing on its left to the value of the thing on its right. Python will let you use either of these in a condition.
#34: We’ve just skimmed through the basics of Python - enough so you don’t get lost when I start showing example code. If you want to know more, there are lots of courses listed in the course reading list; IMHO the best of these is Jeff Knupp’s Learn Python the Hard Way (available online for free).
#35: Your exercises were all built into the class. But if you want more…
#36: The iPython notebooks (that you downloaded from github) are there for you to learn more about the subjects in each class. Go play with them: take copies, edit the code and see what happens.
#37: And make a list of those strange behaviours so we can talk about them in the next class.