Wednesday 14 September 2022

Class 11 - Informatics Practices - Python Snippets (Set-2) #Class11Python #cbseClass11 #Class11ComputerScience #Python #eduvictors

Class 11 - Informatics Practices - Python Snippets (Set-2)

Class 11 - Informatics Practices - Python Snippets (Set-2) #Class11Python #cbseClass11 #Class11ComputerScience #Python #eduvictors


Write Python Programs for the following problem statements:

1. Write a program in python to input marks in 5 subjects from the user and display the average marks.

2. Write a program in python to read details like name, class, age of a student and then print the details firstly in same line and then in separate lines.

3. Write a program in python to input a number and print its first five multiples.

4. Write a program to read a number n and print n, n² , n³ and n⁴

5. Write a program that generates the following output: 5 @ 10 @ 9



Snippet 1: Write a program in python to input marks in 5 subjects from the user and display the average marks. 

# Write a program in python to input marks in 5 subjects 
# from the user and display the average marks.

print("Enter marks out of 50 for the following subjects:")
sub1 = int(input("Maths:"))
sub2 = int(input("English:"))
sub3 = int(input("Pol Science:"))
sub4 = int(input("Geography:"))
sub5 = int(input("Informatics:"))
avg = (sub1 + sub2 + sub3 + sub4 + sub5)/5

print("Your average marks are:", avg)


Program output:
Class 11 - Informatics Practices - Python Snippets (Set-2) #Class11Python #cbseClass11 #Class11ComputerScience #Python #eduvictors



Snippet 2
Write a program in python to read details like name, class, age of a student and then print the details firstly in same line and then in separate lines.


# python snippet 2 by eduvictors.com
# Write a program in python to read details like name,
# class, age of a student and then print the details firstly in
# same line and then in separate lines.

stud_name = input("Enter you name:")
stud_class = input("Enter your class:")
stud_age = int(input("Enter your age in years:"))

print(stud_name, stud_class, stud_age)
print("Student Name:", stud_name)
print("Student Class:", stud_class)
print("Student Age:", stud_age)


Output: 
Class 11 - Informatics Practices - Python Snippets (Set-2) #Class11Python #cbseClass11 #Class11ComputerScience #Python #eduvictors




Snippet 3
Write a program in python to input a number and print its first five multiples.

# Snippet 3 by eduvictors.com
# Write a program in python to input a number and print
# its first five multiples.

n = int(input("Enter an integer: "))
print("First five multiples of", n, "are")
print(n, n * 2, n * 3, n * 4, n * 5)


Output:

Class 11 - Informatics Practices - Python Snippets (Set-2) #Class11Python #cbseClass11 #Class11ComputerScience #Python #eduvictors




Snippet 4: Write a program to read a number n and print n, n² , n³ and n⁴


# Snippet 4 by eduvictors.com
# Write a program to read a number n and print n, n² , n³ and n⁴

n = int(input("Enter an integer: "))
print(n, n ** 2, n ** 3, n ** 4)

Output:
Class 11 - Informatics Practices - Python Snippets (Set-2) #Class11Python #cbseClass11 #Class11ComputerScience #Python #eduvictors




Snippet 5Write a program that generates the following output: 5 @ 10 @ 9

# Snippet 5 by eduvictors.com
# Write a program that generates the following output:
# 5 @ 10 @9

n = 5
print(n, n * 2, n * 2 - 1, sep=' @ ')


Output:
 



Class 11 - Informatics Practices - Python Snippets (Set-2) #Class11Python #cbseClass11 #Class11ComputerScience #Python #eduvictors

👉See Also:

No comments:

Post a Comment

We love to hear your thoughts about this post!

Note: only a member of this blog may post a comment.