Computer Science, asked by nc4223246, 2 months ago

What will be the output of above Python code?
str1="6/4"
print("str1")

Answers

Answered by riyanshityagi1607
4

Answer:

str1

Explanation:

Since in print statement, str1 is written inside double quotes so it will simply print str1 directly.

Answered by BrainlyYoda
2

The output of the Python códe will be str1

Explanation

Alphabets, words, or other characters when enclosed between single quotation marks (' ') or double quotation marks (" ") are called strings.

In this códe,

str1="6/4"

print("str1")

str1 is assigned a string i.e. "6/4"

In this print("str1") on the output screen you will get output as str1 because it's a string not a variable.

Some more ways to change outputs by doing changes in códe are as follows

1.

str1 = "6/4"

print(str1)

Output

6/4

2.

str1 = 6/4

print("str1")

Output

str1

3.

str1 = 6/4

print(str1)

Output

1.5

Extra Information

print() function will print the output to the console.

Examples of print() statement

print("Hello World")

Output

Hello World

print(5/2)

Output

2.5

x = ("apple", "banana", "cherry")

print(x)

Output

('apple', 'banana', 'cherry')

Python is created by Guido van Rossum and came into existence in 1991. It is a high-level and general programming language. It is a very lucid programming language as it has a good language construct and object-oriented approach. It is dynamically typed and garbage-collected.

Similar questions