Python

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is a REPL?

Read Evaluate Print Loop

What is SciPy?

Scientific Python.

Top python automation tools

Selenium, Pywinauto, Behave, Robot frameworks.

What is PyPI?

Stands for Python Publication Index. A repository of software for the Python programming language.

How to make multi line statements

To continue the statement, you can use {} [] ; or \

How do you create new lines automatically when typing strings?

Use 3 quotes at the start and end """ """

Matplotlib, Seaborn, Altair (best one of the 3)

Visualization libraries. Matplotlib can plot anything but harder to plot complicated things. Altair cons: plotting complex machine learning models and having more than 5000 rows

What is a programming paradigm?

A way to classify a language based on its features. ex object-oriented. https://en.wikipedia.org/wiki/Programming_paradigm

blocks

Blocks begin when the indentation increases. Blocks can contain other blocks. Blocks end when the indentation decreases to zero or to a containing block's indentation.

Name 3 web development framesworks for each: website, API, App (CRM, ERP)

Web Framework: Django, TurboGears, Web2py Micro Web Framework: Flask, Bottle, Pyramid CMS: Plone, Django-cms, Mezzanine

What is type coercion

When the data type of a value is changed IMPLICITLY through mixed-mode arithmetic

When are back slashes used?

In strings where you need to use a quotation mark, \n creates a new line. Backslashes can also be used to escape tabs, arbitrary Unicode characters, and various other things that can't be reliably printed. These characters are known as escape characters.

blocks and indentations

Python indentation is a way of telling a Python interpreter that the group of statements belongs to a particular block of code. A block is a combination of all these statements. Block can be regarded as the grouping of statements for a specific purpose

Suppose you want to use the function inv(), which is in the linalg subpackage of the scipy package. You want to be able to use this function as follows: my_inv([[1,2], [3,4]]) Which import statement will you need in order to run the above code without an error?

from scipy.linalg import inv as my_inv

top 15 python libraries

https://www.digitalvidya.com/blog/python-library/

Syntax for how to import a specific module of a package

import module from package

code to make a numpy array from a previous array

import numpy as np np_name=np.array(PreviousArrayName)

Syntax for how to Import a Package

import package_name

if, else-if, else statement in python

name = 'Carol' age = 3000 if name == 'Alice': print('Hi, Alice.') elif age < 12: print('You are not Alice, kiddo.') else: print('You are not Alice, grannie.')

sys.exit()

terminates the program

What is an identifier?

the name of a variable, function, class, module or other object.

What is blender?

video game development tool, open source, built-in game engine, built-in physics engine, uses logic bricks to simplify programming

Break statement

while True: print('Please type your name.') name = input() if name == 'your name': break print('Thank you!')

while loop

spam = 0 while spam < 5: print('Hello, world.') spam = spam + 1

for loop

for x in range(0, 3):

Takes in N test cases

#accept the count of test cases given in the the 1st line t = int(input()) #Run a loop to accept 't' inputs for i in range(t): #accept an integer N in each test case N = int(input()) #output the number mirror for each test case print(N)

Takes in N test cases on multiple lines

#accept the count of test cases given in the the 1st line t = int(input()) #run a loop to accept 't' inputs for i in range(t): #accept 2 integers on the 1st line of each test case A, B = map(int,input().split()) #accept 3 integers on the 2nd line of each test case C, D, E = map(int,input().split()) #output the 5 integers on a single line for each test case print(A, B, C, D, E)

Test cases with multiple types of input

#accept the count of testcases given in the the 1st line t = int(input()) #run a loop to accept 't' testcases for i in range(t): #accept 2 integers on the 1st line of each test case A, B = map(int,input().split()) #accept 1 string on the 2nd line of each test case C = input() #output the 2 integers and 1 string on a single line for each test case print(A, B, C)

Logical operators

&& [and] || [or] ! [not] nand nor

20 % 6

2

20 / 6

20.33333333333

20 // 6

3

How to create an exponent 3^2

3**2

Output of 12/3

4.0 Floats are created when dividing any two integers, running an operation on two floats, or on a float and an integer.

== vs =

== determines if its equal and = assigns a value

map function

A function that generates an output list from an input list by applying a function to each element in the input list. a, b, c = map(int, input().split())

How to exit out of an infinite loop

CTRL+C

Naming conventions:

Class names start with an uppercase letter. All other identifiers start with a lowercase letter. Starting an identifier with a single leading underscore indicates that the identifier is private. Starting an identifier with two leading underscores indicates a strong private identifier. If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.

What do you need to know for Python Professional 2 cert?

Creating and Distributing Packages, Design Patterns, IPC, Network Programming, and Python-MySQL Database Access.

How to avoid unicode error when getting to a file using line cache

Either do 2 backslashes or put an r (raw string) before the location. "C:\\Users\\Eric\\Desktop\\beeline.txt" r"C:\Users\Eric\Desktop\beeline.txt"

Continue statement

It returns the control to the beginning of the while loop.. The continue statement rejects all the remaining statements in the current iteration of the loop and moves the control back to the top of the loop. The continue statement can be used in both while and for loops

What is numpy?

NumPy is the fundamental package for scientific computing with Python. It contains among other things: a powerful N-dimensional array object sophisticated (broadcasting) functions tools for integrating C/C++ and Fortran code useful linear algebra, Fourier transform, and random number capabilities Besides its obvious scientific uses, NumPy can also be used as an efficient multi-dimensional container of generic data. Arbitrary data-types can be defined. This allows NumPy to seamlessly and speedily integrate with a wide variety of databases.

What do you need to know for Python Professional 1 cert?

PCPP-32-1 certification reflects your experience and programming skills in the following areas: Advanced OOP, GUI Programming, PEP conventions, Text File Processing, Communicating with a program\'s environment as well as maths, science, and engineering modules.

Select the entire second column of an array with numpy as np

Pay attention to the last part of the ex. Ex. np_weight_lb=np_baseball[:,1]

What is pip?

Pip is a package manager for installing and uninstalling packages, finding packages published to the Python Publication Index (PYPI), manages requirements for scripts and applications, manages dependencies for packages and projects, can track packages as a group (package group)

What is Mat-plotlib

Plotting library

Reserved words part 1 https://betterprogramming.pub/all-33-reserved-keywords-in-python-98e55f6c8ded

and = for boolean statements as = aliasing assert = used when debugging code. The assert keyword lets you test if a condition in your code returns True, if not, the program will raise an AssertionError break = loop control (terminate) statement class = creates class continue = Loop control statement that skips the rest of the code block to loop again def = creates a function del = deletes elif = else if else = if/else statement except: used to catch and handle the exception(s) that are encountered in the try clause

compare commands

cmp(file1, file2[, shallow]) cmpfiles(dir1, dir2, common[, shallow]) dircmp(dir1, dir2 [, ignore[, hide]])

Reserved words part 2

exec = used for the dynamic execution of Python programs which can either be a string or object code finally = always executed after leaving the try statement. · finally block is used to deallocate the system resources. for = for loop from = idk global = allows us to modify the variable outside of the current scope. It is used to create a global variable and make changes to the variable in a local context if = if/else statement import = import modules/libraries in = idk is = bool test if two variables refer to the same object lambda = creates small anonymous functions and can take any number of arguments, but can only have one expression

print this is fun 5 times

for i in range (5): print("This is fun!")

Reserved words part 3

not = bool expression or = bool expression pass = used as a placeholder for future code. print = displays/outputs raise = used to bring up the current exception in an exception handler so that it can be handled further up the call stack. raises error return = makes functions send Python objects back to the caller code try = use try/except is when you have a code block to execute that will sometimes run correctly and sometimes not, depending on conditions you can't foresee at the time you're writing the code. while = while loop with = resource management and exception handling particularly used in file streams yield = Used in generator functions in place of return. Can produce a sequence of values instead of 1 value

Numpy commands for mean, median, standard deviation, and correlation with Numpy as np

np.mean(), np.median(), np.std(), np.corrcoef()

Syntax for printing text

print("") You can also use single quotes

syntax to print

print() and for strings print("") or print('')


संबंधित स्टडी सेट्स

LUOA Survey of the Bible: Module 4: Major Prophets & the Intertestamental Period

View Set

欢乐伙伴 5B 第12课(听写)

View Set

Microeconomics: Exam 2 (CH 4, 19, 20, Appendix F)

View Set

NUAS240T - Chapter 20 - Nursing Management of the Pregnancy at Risk: Selected Health Conditions and Vulnerable Populations

View Set

Defenses, Strict Liability, and Damages

View Set

Cosmetology State board/most missed questions

View Set

driver's ed module 7 (distracted driving)

View Set

Kaplan - Customer Information, Risk and Suitability, Product Information

View Set