CNM - C4

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/16

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

17 Terms

1
New cards

define darcy’s flow as a function

q = k*A*h/L

define, name, list args, new line with 4 spaces, function, new line, return output

<p>define, name, list args, new line with 4 spaces, function, new line, return output</p>
2
New cards
<p>give the code for calling this function if:</p><ul><li><p>k = 0.3</p></li><li><p>A = 5.2</p></li><li><p>h = 1.7</p></li><li><p>L = 0.3</p></li></ul><p></p>

give the code for calling this function if:

  • k = 0.3

  • A = 5.2

  • h = 1.7

  • L = 0.3

knowt flashcard image
3
New cards

what do you have to use to get flow rate as an array from this function

a for loop and args as arrays

<p>a for loop and args as arrays </p>
4
New cards
<p>how do you use a keyword argument in a function - modify this code as an example </p>

how do you use a keyword argument in a function - modify this code as an example

knowt flashcard image
5
New cards

what is the difference between variables defined inside and outside a function

Scope

  • variables defined inside a function are in the local scope and can’t be accessed outside of it

  • variables defined outside of a function have global scope and can be accessed anywhere

so should have dif names

6
New cards

what is pandas

  • a module like numpy is

  • a module that allows us to work with tables of data

  • used for stats, graphs, etc

  • import pandas as pd

7
New cards

what is a dataframe

  • a dataframe is to pandas what an array is to numpy

  • dataframes hold more types of data than arrays

  • can access data through labels rather than position

  • helpful with time series data

8
New cards
<p>what dataframe would this code produce</p>

what dataframe would this code produce

knowt flashcard image
9
New cards
<p>how to pull this section of the dataframe df</p>

how to pull this section of the dataframe df

df.loc — meaning locate

<p>df.loc — meaning locate</p>
10
New cards

line of code to import data from a file

knowt flashcard image
11
New cards

how do you add a new column to a dataframe

eg a new column which sums the x column value and y column value in each row and multiplies this by 2

knowt flashcard image
12
New cards
<p>line of code to apply the function to the dataframe</p>

line of code to apply the function to the dataframe

knowt flashcard image
13
New cards
<p>this is a dataframe of the rainfall and other values in tyne</p><p></p><p>what is a line of code to plot the precipitaion in tyne from 01/01/1999 to 01/02/1999</p>

this is a dataframe of the rainfall and other values in tyne

what is a line of code to plot the precipitaion in tyne from 01/01/1999 to 01/02/1999

knowt flashcard image
14
New cards

What is a module in Python and how can you create your own?


A module is a separate file containing extra functionality, that you can create by saving a script with functions as a .py file and importing it

15
New cards

What is a file mode in Python, name 4 types and what they do

A file mode tells Python how a file should be opened and what operations are allowed.

"r" – Read only

"r+" – Read and write

"w" – Write only (deletes current content)

"a" – Append (keep current content and add to it)

open("file.txt", mode) - how to use - insert one of the above as ‘mode’

16
New cards

What does the following code do?

file = open("open_me.txt", "w")

file.write("Hello")

file.close()

Replaces the contents of open_me.txt with "Hello"

17
New cards

Why do we use a while loop in this code instead of a for loop?


Because for loops cannot calculate change

Explore top flashcards