Intro to Abstraction Flashcards

1
Q

How to print current time in Python?

A
Import time module and run time.ctime() function:
import time
print ("This program started on  "+time.ctime())
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to open a web browser in a Python program?

A

Import a webbrowser module and run webrowser.open (:httm://…”) function

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

How to suspend a program in Python?

A

Import a time module and run time.sleep(X) function. X - is any number in seconds - time for which you want to suspend the program.

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

How to stop a running program running from idle?

A

Press Crtl +C in a shell of running program

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

How Wiki defines Abstraction in programming?

A

In computer science, abstraction is a technique for managing complexity of computer systems. It works by establishing a level of complexity on which a person interacts with the system, suppressing the more complex details below the current level.

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

which module in Python allow to work with the operating system?

A

import os

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

how to list files in a certain directory in Python?

A

import os

os.listdir(r”path”)

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

how to display current directory?

A

import os

os.getcwd()

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

how to change working directory?

A

import os

os.chdir(r”path”)

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

how to “translate” a string?

A

string.translate(table, list of characters to be removed),
where “table” translates one set of characters into another set of characters. In not necessary, have “None” there. the second argument removes specified characters from the string.

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

how to rename a file?

A

import os

os.rename(old name, new name)

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

what is an example of a module that allows draw graphics?

A

import turtle

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

what would this code do:
import turtle
brad=turtle.Turtle

A

it would import a module turtle, then create an instance of a class Turtle (note the upper case), named brad

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

what is the essence of a class in Python?

A

a class is like a blueprint of a building that will allow build different buildings (but also similar) based on this blueprint

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