0% found this document useful (0 votes)
2 views

Record Files

The document contains a series of Python code snippets that demonstrate various programming concepts such as input handling, arithmetic operations, control flow, loops, and data structures. It includes examples for calculating sums, finding the greatest number, generating patterns, checking for Armstrong and palindrome numbers, determining prime numbers, calculating factorials, and managing dictionaries for countries and student records. Each code snippet is designed to illustrate specific functionalities and algorithms in Python.

Uploaded by

Aparna Suresh
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 views

Record Files

The document contains a series of Python code snippets that demonstrate various programming concepts such as input handling, arithmetic operations, control flow, loops, and data structures. It includes examples for calculating sums, finding the greatest number, generating patterns, checking for Armstrong and palindrome numbers, determining prime numbers, calculating factorials, and managing dictionaries for countries and student records. Each code snippet is designed to illustrate specific functionalities and algorithms in Python.

Uploaded by

Aparna Suresh
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
You are on page 1/ 5

#RecordFile_1

print("Welcome to python!!")

#RecordFile_2
x=float(input("enter a number: "))
y=float(input("enter a number:"))
z=float(input("enter a number"))
sum=x+y+z
print("The sum of three numbers=",sum)

#RecordFile_3
num1=float(input("enter a number"))
num2=float(input("enter a number"))
num3=float(input("enter a number"))
if num1>num2 and num1>num3:
print(num1,"is the greatest number")
elif num2>num1 and num2>num3:
print(num2, "is the greatest number")
else:
print(num3,"is the greatest")

#RecordFile_4
for i in range (1,6):
for j in range (1,i+1):
print("*", end=" ")
print()

#RecordFile_5
rows=int(input("enter number of rows"))
for row in range(1, rows+1):
for column in range(1,row+1):
print(column, end=" ")
print()

#RecordFile_6
x=float(input("enter a number:"))
n=int(input("enter a number:"))
s=0
for i in range(n+1):
s=x**n
print("Sum of Exponents=",s)

#RecordFile_7
num=int(input("enter a 3 digit number:"))
temp=num
sum=0
digit=0
while temp>0:
digit=temp%10
sum=sum+digit**3
temp=temp//10
if (sum==num):
print("The Number is Armstrong")
else:
print("The Number is NOT Armstrong")

#RecordFile_8
n=int(input("enter a number"))
temp=n
rev=0
while n>0:
digit=n%10
rev=rev*10+digit
n=n//10
if (temp==rev):
print("The Number is Palindrome")
else:
print("The Number is NOT Palindrome")

#RecordFile_9
num=int(input("enter a number")
if num>1:
for i in range(2,num):
if (num%i)==0:
print(num,"is NOT prime")
break
else:
print(num,"is prime")

#RecordFile_10
num=int(input("enter a number:"))
factorial=1
if num<0:
print("Factorial does not exist for negative numbers")
elif num==0:
print("Factorial of 0 is 1")
else:
for i in range(1, num+1):
factorial=factorial*i
print("The factorial of ",num,"is", factorial)

#Record File_11
num=int(input("enter a number: "))
if num>1:
for i in range(2, num):
if (num%i)==0:
print("The number is NOT a prime number")
break
else:
print("The number IS a prime number")

#RecordFile_12
num=int(input("enter the value if 'n': "))
a=0
b=1
sum=0
count=1
print("Fibbonacci Series: ", end=" ")
while (count<=num):
print(sum, end=" ")
count+=1
a=b
b=sum
sum=a+b

#RecordFile_14
s=input("enter a string: ")
vowels=consonents=uppercase=lowercase=0
for i in s:
if i in ('A','E','I','O','U','a','e','i','o','u'):
vowels=vowels+1
else:
consonents=consonents+1
if i.isupper():
uppercase=uppercase+1
if i.islower():
lowercase=lowercase+1
print()
print("The number of vowels in",s,"is",vowels)
print("The number of consonents in",s,"is",consonents)
print("The number of uppercase in",s,"is",uppercase)
print("The number of lowercase in",s,"is",lowercase)

#RecordFile_15
str1=input("enter a string: ")
str2=str1[::-1]
if str1==str2:
print("The str",str1," is palindrome")
else:
print("The str",str1," is not palindrome")

#RecordFile_19
country_dict=dict()
n=int(input("enter no of countries u want to add to the table: "))
for i in range(n):
country=input("enter country name: ")
capital=input("enter capital name")
currency=input("enter currency")
country_dict[country]=capital,currency
print()
print("Country",'\t\t',"Capital",'\t\t',"Currency")
for country, c in country_dict.items():
print(country,'\t\t',c[0],'\t\t',c[1])
print()
cn=input("enter the name of the country u wish to view details of: ")
if cn in country_dict:
print(cn,country_dict[cn])
else:
print("the country does not exist in the dict...")

#RecordFile_20
classlist=dict()
n=int(input("the number of entries we wish to add: "))
for i in range(n):
rollno=int(input("enter your roll number: "))
name=input("enter your name: ")
marks=int(input("enter your marks: "))
classlist[rollno]=name,marks
print("RollNo",'\t\t',"Name",'\t\t',"Marks")
for rollno, c in classlist.items():
print(rollno,'\t\t',c[0],'\t\t',c[1])
print()
print("The Students who got above 75: ", end=" ")
for i in classlist:
if (classlist[i][1]>75):
print(classlist[i][0], end=" ")

You might also like