Skip to content

Instantly share code, notes, and snippets.

@kaniket7209
Created December 3, 2021 07:30
Show Gist options
  • Save kaniket7209/69fea1eac637b0098536fb597d841685 to your computer and use it in GitHub Desktop.
Save kaniket7209/69fea1eac637b0098536fb597d841685 to your computer and use it in GitHub Desktop.
Displaying past entries in the microBlog Project
1. As we know that for a python list , everytime when we restart our app , we loses everything from the list. So how can we prevent that .
Answer: We can use MongoDB
2. What does truncate() do in Python?
Answer: The truncate() method resizes the file to the given number of bytes. If the size is not specified, the current position will be used.
3. How do you truncate data in Python?
Answer: Python has two ways that remove all decimal digits from a number:
a) The math. trunc() function truncates the value of its argument to a whole number.
b) The int() function converts a number or string into an integer. During that process Python throws away the decimal part of the value.
4. How to enable development mode in flask ?
Answer: Write command-> export FLASK_ENV=development
1. Select the correct keyword to add data in tuples?
a) insert
b) append
c) add
d) None of the above
Answer: b)
2. How can we define tuples. Select the correct option from below
a) entries = {}
b) entries = {% %}
c) entries = []
d) entries = ()
Answer: c)
3. What will happen when we restart our app after adding data into tuples.
a) Data will remain in app
b) We will loose the data
c) Unpredictable
d) None of the above
Answer: b)
4. Which of the following is the correct syntax to truncate data from tuples in the html page.
a) {{ entry[0] , truncate(30, true) }}
b) {{ entry[0] | truncate(30, true) }}
c) {{ entry[0] | truncate{30, true} }}
d) {{ entry[0] | truncate[30, true] }}
Answer: b)
5. Can we run our app using 'flask run' command before activating venv?
a) Yes
b) No
Answer: b)
6. Which of the following command will enable debug mode "ON"
a) export FLASK_APP=app.py
b) export FLASK_ENV=development
c) pyenv 'Flask_APP=development'
d) export 'FLASK_APP=app.py'
Answer: b)
7. Which of the following statement is syntactically wrong. Choose the correct option
a) export FLASK_APP =app.py
b) export FLASK_APP = app.py
c) export FLASK_APP= app.py
d) All of the above
Answer: d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment