Introduction of Python
Introduction of Python
compile execute
source code byte code output
Hello.java Hello.class
interpret
source code output
Hello.py
Win 9x/NT/2000
OS/2
PalmOS
Windows CE
Acorn/RISC OS
BeOS
Amiga
VMS/OpenVMS
QNX
VxWorks
Psion
Python has also been ported to the Java and .NET virtual machines.
== If the value of two operands is equal, then the condition becomes true.
!= If the value of two operands is not equal, then the condition becomes true.
<= The condition is met if the first operand is smaller than or equal to the second
operand.
>= The condition is met if the first operand is greater than or equal to the second
operand.
> If the first operand is greater than the second operand, then the condition
becomes true.
< If the first operand is less than the second operand, then the condition
becomes true.
Amount: $150.75
# another example
print('pratik', 'geeksforgeeks', sep='@')
name = 'Tushar'
age = 23
print(f"Hello, My name is {name} and I'm {age} years old.")
add = num + 5
# Output
print("The sum is %d" %add)
# printing values
print("Sum of", num1, "and", num2 , "is", sum)
Sum of 15 and 12 is 27
Sum of 15 and 12 is 27
# second string
secondString = "PyThOn Is AwEsOmE!"
if(firstString.upper() == secondString.upper()):
print("The strings are same.")
else:
print("The strings are not same.")
# example string
string = "THIS SHOULD BE LOWERCASE!"
print(string.lower())
# string with numbers
# all alphabets should be lowercase
string = "Th!s Sh0uLd B3 L0w3rCas3!"
print(string.lower())
# second string
secondString = "PyThOn Is AwEsOmE!"
if(firstString.lower() == secondString.lower()):
print("The strings are same.")
else:
print("The strings are not same.")
print(lowercased_string)
# Output: python
Saturday is a weekend
Three
Give input of numbers from 1 to 3
May
‘Give an input as an integer from 1 to 12’
match day:
case "Saturday" | "Sunday":
print(f"{day} is a weekend.")
case "Monday" | "Tuesday" | "Wednesday" | "Thursday" |
"Friday":
print(f"{day} is a weekday.")
case _:
print("That's not a valid day of the week.")
Monday is a weekday.