
Python scripts can be executed in two ways:
Suppose I want to execute script1.py
We can open the script1.py in IDE editor & run the script in the frontmost window of the python IDE by hitting the run all button.
Second way is using command prompt by making sure PATH is set appropriately directly type script name else type
>>>python script1.py
To set up the database in Django, follow these steps:
1. Install the database adapter (e.g., `psycopg2` for PostgreSQL).
2. In your Django project, open `settings.py`.
3. Locate the `DATABASES` setting and configure it with your database details, like this:
```python
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql', # or 'sqlite3', 'mysql', etc.
'NAME': 'your_database_name',
'USER': 'your_username',
'PASSWORD': 'your_password',
'HOST': 'localhost', # or your database host
'PORT': '5432', # or your database port
}
}
```
4. Run `python manage.py migrate` to create the necessary database tables.
5. Optionally, create a superuser with `python manage.py createsuperuser` for admin access.
• Shallow copy is used when a new instance type gets created and it keeps the values that are copied in the new instance. Whereas, deep copy is used to store the values that are already copied.
• Shallow copy is used to copy the reference pointers just like it copies the values. These references point to the original objects and the changes made in any member of the class will also affect the original copy of it. Whereas, deep copy doesn’t copy the reference pointers to the objects. Deep copy makes the reference to an object and the new object that is pointed by some other object gets stored. The changes made in the original copy won’t affect any other copy that uses the object.
• Shallow copy allows faster execution of the program and it depends on the size of the data that is used. Whereas, deep copy makes it slower due to making certain copies for each object that is been called.
```csharp
using System;
class Animal
{
public virtual void Speak()
{
Console.WriteLine("Animal speaks");
}
}
class Dog : Animal
{
public override void Speak()
{
Console.WriteLine("Dog barks");
}
}
class Cat : Animal
{
public override void Speak()
{
Console.WriteLine("Cat meows");
}
}
class Program
{
static void Main(string[] args)
{
Animal myDog = new Dog();
Animal myCat = new Cat();
myDog.Speak(); // Output: Dog barks
myCat.Speak(); // Output: Cat meows
}
}
```
The .NET Framework is a software development platform developed by Microsoft that provides a large library and supports various programming languages, primarily C# and VB.NET. It enables developers to build and run applications on Windows, offering features like memory management, security, and interoperability with other languages and technologies. The framework includes the Common Language Runtime (CLR) for executing code and the .NET Class Library for building applications.