0% found this document useful (0 votes)
2 views1 page

Python Structure

The document outlines key points for handling data types in Python, emphasizing the need to specify data types for numeric inputs. It provides a sample program that takes marks for three subjects, calculates the total and average, and determines if the student passes or fails based on the average. The document includes specific input syntax for integers and strings, along with a complete Python solution for the described problem.

Uploaded by

rohanalikhan611
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Python Structure

The document outlines key points for handling data types in Python, emphasizing the need to specify data types for numeric inputs. It provides a sample program that takes marks for three subjects, calculates the total and average, and determines if the student passes or fails based on the average. The document includes specific input syntax for integers and strings, along with a complete Python solution for the described problem.

Uploaded by

rohanalikhan611
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python structure

Points to remember:
 Always write data type for numbers for eg int or float before input, because python
use str data type by default.
 Syntax of input for int or float data type is : int( input(“ your prompt here “))
 Syntax of input for str data type is : input(“ your prompt here “)
Example question:
A student appears in three subjects. The school wants a program that:
 Takes marks of three subjects English, Urdu and Maths
 Calculates the total and average
 Displays Pass if average is 50 or above, otherwise Fail
Python Solution:

Variable Data type Input statement

englishmarks = int(input("Enter marks of English: ")) Prompt


urdumarks = int(input("Enter marks of Urdu: "))
mathsmarks = int(input("Enter marks of Maths: "))
total = englishmarks + urdumarks + mathsmarks
average = total / 3
print("Total:", total)
print("Average:", average)
if average >= 50:
print("Result: Pass")
else:
print("Result: Fail")

You might also like