General Flashcards

(45 cards)

1
Q

What is a function?

A

Block or organised, reusable code that is used to perform a single, relation action.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give an 3 examples of pythons built-in functions

A

abs()- Returns the absolute value of a number

all()-Returns True if all items in an iterable object are true

any()- Returns True if any item in an iterable object is true

ascii()-Returns a readable version of an object. Replaces none-ascii characters with escape character

bin()-Returns the binary version of a number

bool()-Returns the boolean value of the specified object

bytearray()-Returns an array of bytes

bytes()-Returns a bytes object

callable()-Returns True if the specified object is callable, otherwise False

chr()-Returns a character from the specified Unicode code.

classmethod()-Converts a method into a class method

compile()-Returns the specified source as an object, ready to be executed

complex()-Returns a complex number

delattr()-Deletes the specified attribute (property or method) from the specified object

dict()-Returns a dictionary (Array)

dir()-Returns a list of the specified object’s properties and methods

divmod()-Returns the quotient and the remainder when argument1 is divided by argument2

enumerate()-Takes a collection (e.g. a tuple) and returns it as an enumerate object

eval()-Evaluates and executes an expression

exec()-Executes the specified code (or object)

filter()-Use a filter function to exclude items in an iterable object

float()-Returns a floating point number

format()-Formats a specified value

frozenset()-Returns a frozenset object

getattr()-Returns the value of the specified attribute (property or method)

globals()-Returns the current global symbol table as a dictionary

hasattr()-Returns True if the specified object has the specified attribute (property/method)

hash()-Returns the hash value of a specified object

help()-Executes the built-in help system

hex()-Converts a number into a hexadecimal value

id()-Returns the id of an object

input()-Allowing user input

int() -Returns an integer number

isinstance()-Returns True if a specified object is an instance of a specified object

issubclass()-Returns True if a specified class is a subclass of a specified object

iter()-Returns an iterator object

len()-Returns the length of an object

list() -Returns a list

locals()-Returns an updated dictionary of the current local symbol table

map()-Returns the specified iterator with the specified function applied to each item

max()-Returns the largest item in an iterable

memoryview()-Returns a memory view object

min()-Returns the smallest item in an iterable

next()-Returns the next item in an iterable

object()-Returns a new object

oct()-Converts a number into an octal

open()-Opens a file and returns a file object

ord()-Convert an integer representing the Unicode of the specified character

pow()-Returns the value of x to the power of y

print()-Prints to the standard output device

property()-Gets, sets, deletes a property

range()-Returns a sequence of numbers, starting from 0 and increments by 1 (by default)

repr()-Returns a readable version of an object

reversed()-Returns a reversed iterator

round()-Rounds a numbers

set()-Returns a new set object

setattr()-Sets an attribute (property/method) of an object

slice()-Returns a slice object

sorted()-Returns a sorted list

staticmethod()-Converts a method into a static method

str() -Returns a string object

sum()-Sums the items of an iterator

super()-Returns an object that represents the parent class

tuple()-Returns a tuple

type()-Returns the type of an object

vars()-Returns the __dict__ property of an object

zip() -Returns an iterator, from two or more iterators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give an example of client side programs

A

1) Javascript
2) VBScript
3) HTML
4) CSS
5) AJAX

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Give an example of server-side program

A

1) PHP
2) C++
3) Java and JSP
4) Python
5) Ruby on Rails

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to you concatenate strings?

A

print() with commas or without to make them one string you can also use the + function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you add a space at the end of each work in a print statement

A

print (‘work’, end=’ ‘)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How could you add a space in between two strings when printing?

A

print(‘word 1’, ‘word 2’, sep=’ ‘)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an int? give an example

A

A positive whole number 1, 2,3,4…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a float? give an example

A

A decimal number. 1.1, 1.2, 1.3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the type() function do?

A

confirms the value something i.e. type(1), would be an int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the arithmetic operator for addition

A

+

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the arithmetic operator for subtraction

A

-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the arithmetic operator for multiplication

A

*

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the arithmetic operator for division?

A

/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is integer division? What is the arithmetic operator for integer division?

A

Dividing and returning the nearest int. //

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the arithmetic operator for exponent (calculating a number to the power of another number?)

A

**

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is modulus? What is the arithmetic operator for modulus?

A

Dividing and returning the remainder after division %

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is booleans value? how do you call?

A

bool() and it is true of false value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does a not operator return?

A

the opposite of a value

20
Q

what is the comparison operator for not equal to?

21
Q

what is the comparison operator for equal to

22
Q

what is the comparison operator for more than

23
Q

what is the comparison operator for less than

24
Q

what is the comparison operator for less than or equal ?

25
what is the comparison operator for more than or equal?
>=
26
In a string how would you use the escape character and what is it?
to stop items breaking the code and making the next character to be treated as ordinary- it is a \
27
What does casting achieve?
converts one type to another i.e int(), round()
28
How do you add comments to scripts
#
29
How do you ask for user input?
input("question you would like user to answer)
30
how do you confirm if inputs are a number?
.isnumeric
31
What is pycharm
PyCharm is a dedicated Python Integrated Development Environment (IDE) providing a wide range of essential tools for Python developers, tightly integrated to create a convenient environment for productive Python, web, and data science development.
32
What does string.capitalize() do ?
capitalizes first letter of string
33
What does string.startswith(prefix) do?
determines if string starts with prefix
34
What does string.endswith(suffix) do?
determines if string ends with suffix
35
What does string.isupper() do?
determines if all characters in the string are uppercase
36
What does string.islower() do?
determines if all characters in the string are lowercase
37
What does string.find(str) do?
determines if str occurs in string
38
what does string.index(str) do?
determines index of str in string
39
What does string.replace(old, new) do?
replaces all occurrences of old in string with new
40
What does string.strip() do?
trims whitespace from beginning and end of string
41
What does string.upper() do?
returns uppercased string from given string
42
What does string.lower() do?
returns lowercased string from given string
43
What is syntax?
The grammar and structure of code
44
What is semantics?
What the code will do when it is run
45
What is memory management
How efficient the code is