## How to write a program to accepts a string from console and print the characters that have even indexes?

Example:

If the following string is given as input to the program:
H1e2l3l4o5
Then, the output of the program should be:
Hello

``````print("Please enter text to print::")
inputchars = input()

if inputchars:
string = ""
for i in inputchars:
if inputchars.index(i)%2 == 0:
string += str(i)

print('-------------------')
print("You Entered:", inputchars)
print("Result:")
print(string)``````
``````# OUTPUT::
H1e2l3l4o5
-------------------
You Entered: H1e2l3l4o5
Result:
Hello``````

## How to find the odd and even numbers using Python?

Here, In below code, user can enter two numbers to find the odd and even numbers between them. The number must be in between 1000 and 3000.

``````print("Please Enter the Number between 1000 and 3000")

print("Enter the First Number:")
first_number = input()

print("Enter the Second Number:")
second_number = input()

print("First Number: ", first_number)
print("Second Number: ", second_number)

if int(first_number) >= 1000 and int(second_number) <= 3000:
first_number = int(first_number)
second_number = int(second_number)

even_numbers= []
odd_numbers = []

for i in range(first_number,(second_number+1)):
if i%2 is 0:
even_numbers.append(str(i))
else:
odd_numbers.append(str(i))

else:
print("Please enter a number between 1000 and 3000")``````

## How to read or write files in Python?

Before any files to read we have to know how to Open & Close the files.

# Open Function:

we can open a file using python build in function open()

```file_object = open(file_name, file_access_mode )
```
• file_name = It is the file name or the full file path.
• file_access_mode = File access mode is to determine, open file for read, write , append etc.
 Modes Description r Opens a file for read only purpose. rb Open a file for reading only in binary format. r+ Open a file for both operation reading & writing. rb+ Open a file for both reading & writing in binary format. w Open a file for writing purpose only. It overwrites the existing file or otherwise create a new file. wb Opens a file for writing only in binary format. It overwrites the existing file or otherwise create a new file. a Opens a file for appending. ab Opens a file for appending in binary format. ab+ Opens a file for both appending & reading in binary format. w+ Opens a file for both reading & writing format. wb+ Opens a file for both reading & writing in binary format.

# Write Function:

``````
file_content = "This is my First Text."
file_object.write( file_content )
``````

```file_object.read()
```

# Rename Files:

```os.rename( old_file_name, new_file_name )
```

# Delete File:

``os.remove( file_name )``

# Close File:

``````
file_object.close()
``````

# File Object Attributes:

• file_object.closed
• file_object.mode
• file_object.softspace [ It is no longer supported in python 3.x ]
• file_object.name

Django media files not showing with Debug = False on production. It loads without css & media files like images.

This Code is Checked in Django version 2.1

In the url.py file add below code, to import the serve lib

``from django.views.static import serve``

Add the below codes in urls.py file (in settings.py containing directory)

``````if not settings.DEBUG:
urlpatterns += [
``updatedon = models.DateTimeField(auto_now=True,null=True)``