#9 PYTHON PROBLEMS AND SOLUTIONS ON IMPORT MODULES
Practice imports on Python.
Beginner Problems:
1
Import the math module and use it to calculate
the square root of a given number in a file called 1-square.py.
create another file called 1-imported.py, import the square.py
and use it to print the results.
2
write a program that that creates four fucntions; addition, subtraction,
multiplication, and division.
create another file and import the functions, use the functions to run
arithmetic problems and print them
List Operations:
Write a Python script that imports the math module and defines a list of numbers.
Use a list comprehension to calculate the square root of each number and store
the results in a new list. Print the original list and the list of square roots.
Importing Variables:
Create a Python script that defines variables for your name, age, and location.
Import these variables into another script and print a message using the imported
variables to introduce yourself.
Dictionaries and Imports:
Define a dictionary with information about books, such as titles and authors.
Save this dictionary in a file called books.py. In a new script, import the
dictionary from books.py and use it to print details about a specific book.
Module-Based Data Processing:
Create a Python module named data_generator.py that contains a function to
generate a list of 20 random numbers between 1 and 100. In a separate script,
import the data_generator module and use the generated data to create two lists
using list comprehensions: one with numbers less than 50 and another with numbers
greater than or equal to 50. Print all three lists.
Importing Temperature Converter:
Write a Python script that imports a module named temperature_converter.py.
This module contains functions to convert between Celsius and Fahrenheit
temperatures. Use the imported module to convert a user-input temperature
in one unit to the other. Ensure that error handling for invalid input is
handled within the temperature_converter module.
Enhancing User Profiles:
Define a dictionary that represents a user's profile with keys for name, age,
email, and city. Create a Python module named user_profile.py that contains a
function to import the user's profile. In a separate script, import the
user_profile module, ask the user for additional information like a phone
number, and update the dictionary with the new data. Finally, print the updated
profile.
Importing Number Guessing Game:
Create a Python script that imports a module named number_game.py. This
module generates a random number between 1 and 100 and implements a guessing
game. Import the module and use it to play the guessing game, tracking the
number of attempts and providing hints to the user. When the user guesses
correctly, print the number of attempts and the guessed number.
reach me at [email protected]
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «#9 PYTHON PROBLEMS AND SOLUTIONS ON IMPORT MODULES», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.