Intro to Abstraction Flashcards
How to print current time in Python?
Import time module and run time.ctime() function: import time print ("This program started on "+time.ctime())
How to open a web browser in a Python program?
Import a webbrowser module and run webrowser.open (:httm://…”) function
How to suspend a program in Python?
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 to stop a running program running from idle?
Press Crtl +C in a shell of running program
How Wiki defines Abstraction in programming?
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.
which module in Python allow to work with the operating system?
import os
how to list files in a certain directory in Python?
import os
os.listdir(r”path”)
how to display current directory?
import os
os.getcwd()
how to change working directory?
import os
os.chdir(r”path”)
how to “translate” a string?
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 to rename a file?
import os
os.rename(old name, new name)
what is an example of a module that allows draw graphics?
import turtle
what would this code do:
import turtle
brad=turtle.Turtle
it would import a module turtle, then create an instance of a class Turtle (note the upper case), named brad
what is the essence of a class in Python?
a class is like a blueprint of a building that will allow build different buildings (but also similar) based on this blueprint