Python‎ > ‎str‎ > ‎

str.upper()


Introduction
Return the string to uppercase.

Syntax
str.upper()

Parameters
str=string

Example
The django web framework is used to create the application which convert the string into uppercase using str.upper method. The string_method_upper.py calls the string_method.views.py file to render the function.
Windows CMD commands for creating virtualenv, startproject, startapp, and running server.
  • virtualenv string
  • cd string
  • .\Scripts\activate
  • pip install django
  • python .\Scripts\django-admin.py startproject str
  • cd str
  • python manage.py runserver
  • python manage.py startapp string_methods
  • python manage.py startapp string_method_upper
  • python manage.py runserver



string_method_upper/views.py


def string_method_upper (request):
    return string_upper(request)

string_methods/views.py


def string_upper(request):
    return HttpResponse("Python is a simple, powerful and high-level programming language "
                        "and the logic and structure is consistent with the way we "
                        "reasons. ".upper())


urls.py

from string_methods.views import*
from string_method_upper.views import *

urlpatterns=patterns('', url(r'^string_method_upper/', string_method_upper),)

settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles','string_methods', 'string_method_upper',
)




Example
The output is:
 >>> "adil waseem".upper()
'ADIL WASEEM'
>>> "Adil Waseem".upper()
'ADIL WASEEM'
>>> 

str.isupper.__eq__(str.upper())
The return are following:
 >>> x="PYTHON LAKE".isupper()
>>> y="python lake".upper()
>>> x==y
False
>>> "PYTHON LAKE".isupper()==("python lake".upper())
False
>>> "PYTHON LAKE".isupper()
True
>>> "python lake".upper().__eq__("PYTHON LAKE")
True
>>> True.__eq__(True)
True
>>>


class.....: def.....: str.upper
The function returns with capitalizing the strings.
 class string_capitalize:
    def __init__(self,a,b):
   
               print(str.upper(a), str.upper(b))

        
x=input("Please enter your first name: ")
y=input("Please enter your second name: ")


string_capitalize(x,y)

>>> 
Please enter your first name: Adil
Please enter your second name: Waseeem
ADIL WASEEM
>>>

class.....: def __init__()......:...if str.upper()....
The function tested whether the string value is single word, or contain non-string values through input().
 class str_methods():
    def __init__(self, a,b,c):

        identifier=str.isidentifier(a)

        if str.isidentifier(a).__eq__(True):
            print("Full name should not contain special characters or numbers")
            
        else:
            print("Your full not name accepted")

        
      
        alpha=str.isalpha(b)
        
        if alpha.__ne__(False):
            print("Full name accepted")

            lower=str.lower(c)
            if lower.__eq__(str.lower(c)):
                 str.upper(c)
                 print("System convert your name to uppercase:", str.upper(c))
            else:
                 print("Your name accepted")

        else:
            print("Full name can't be one word")

                    

input_text=input("Please enter  your full name: ")

str_methods(input_text, input_text,input_text)
    
          

>>> 
Please enter your full name: Adil22
Full name should not contain special characters or numbers
Full name can't be one word
>>>        


Comments